AIDK API Reference / aidk/mcp
aidk/mcp ​
AIDK MCP (Model Context Protocol) ​
Integration with MCP servers for external tool execution. MCP allows agents to use tools provided by external servers.
Features ​
- MCPClient - Connect to MCP servers
- MCPService - Manage multiple MCP connections
- Tool Discovery - Auto-discover tools from MCP servers
- Tool Components - Use MCP tools as JSX components
Quick Start ​
typescript
import { discoverMCPTools } from 'aidk/mcp';
// Discover tools from an MCP server
const tools = await discoverMCPTools({
server: {
command: 'npx',
args: ['-y', '@modelcontextprotocol/server-filesystem'],
},
});
// Use in an agent
const MyAgent = () => (
<>
<System>You can read and write files.</System>
{tools.map(tool => <Tool key={tool.name} tool={tool} />)}
</>
);See ​
- MCPClient - MCP server client
- MCPService - MCP connection manager
- discoverMCPTools - Tool discovery
Classes ​
| Class | Description |
|---|---|
| MCPClient | Wrapper around official MCP SDK Client Manages connections to multiple MCP servers |
| MCPService | MCP Service handles discovery and registration of MCP tools |
| MCPToolComponent | MCPToolComponent connects to an MCP server and registers its tools into the context. |
Interfaces ​
| Interface | Description |
|---|---|
| CreateMCPToolFromDefinitionOptions | Options for createMCPToolFromDefinition(). |
| CreateMCPToolOptions | Options for createMCPTool(). Extends MCPToolComponentProps but adds toolName for single-tool selection. |
| DiscoverMCPToolsOptions | Options for discoverMCPTools(). |
| MCPConfig | MCP server configuration |
| MCPServerConfig | Cursor-style MCP server configuration (simplified format) Used for both EngineConfig.mcpServers and MCPToolComponent config |
| MCPToolConfig | MCP tool configuration stored in metadata.mcpConfig. |
| MCPToolDefinition | MCP tool definition (from server) Matches the SDK's Tool type structure |
Type Aliases ​
| Type Alias | Description |
|---|---|
| MCPTransport | MCP transport types Note: 'websocket' maps to StreamableHTTP in the SDK |
Functions ​
| Function | Description |
|---|---|
| createMCPTool | Creates an MCP tool component that discovers and registers on mount. |
| createMCPToolFromDefinition | Creates an ExecutableTool from an MCP tool definition. |
| discoverMCPTools | Discovers all tools from an MCP server and creates ExecutableTools. |
| mcpSchemaToZod | Converts MCP JSON Schema to Zod schema. Basic conversion - supports common types. |
| MCPTool | Factory function for creating MCPToolComponent in JSX |
| mergeMCPConfig | Merges base config with runtime overrides. Runtime values take precedence. |
| normalizeMCPConfig | Normalizes Cursor-style config to full MCPConfig. |
| normalizeResult | Normalize MCP tool result to ContentBlock[]. |