mcpServers method
Sets MCP (Model Context Protocol) servers
Configures MCP servers that provide additional context and capabilities to the model. MCP servers can provide tools, resources, and other contextual information to enhance the model's capabilities.
Example:
final provider = await ai()
.anthropic((anthropic) => anthropic
.mcpServers([
AnthropicMCPServer.url(
name: 'file_server',
url: 'https://example.com/mcp',
),
AnthropicMCPServer.url(
name: 'database_server',
url: 'https://example.com/mcp2',
),
]))
.apiKey(apiKey)
.build();
Implementation
AnthropicBuilder mcpServers(List<AnthropicMCPServer> servers) {
_baseBuilder.extension('mcpServers', servers);
return this;
}