Skip to content

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 ​

Classes ​

ClassDescription
MCPClientWrapper around official MCP SDK Client Manages connections to multiple MCP servers
MCPServiceMCP Service handles discovery and registration of MCP tools
MCPToolComponentMCPToolComponent connects to an MCP server and registers its tools into the context.

Interfaces ​

InterfaceDescription
CreateMCPToolFromDefinitionOptionsOptions for createMCPToolFromDefinition().
CreateMCPToolOptionsOptions for createMCPTool(). Extends MCPToolComponentProps but adds toolName for single-tool selection.
DiscoverMCPToolsOptionsOptions for discoverMCPTools().
MCPConfigMCP server configuration
MCPServerConfigCursor-style MCP server configuration (simplified format) Used for both EngineConfig.mcpServers and MCPToolComponent config
MCPToolConfigMCP tool configuration stored in metadata.mcpConfig.
MCPToolDefinitionMCP tool definition (from server) Matches the SDK's Tool type structure

Type Aliases ​

Type AliasDescription
MCPTransportMCP transport types Note: 'websocket' maps to StreamableHTTP in the SDK

Functions ​

FunctionDescription
createMCPToolCreates an MCP tool component that discovers and registers on mount.
createMCPToolFromDefinitionCreates an ExecutableTool from an MCP tool definition.
discoverMCPToolsDiscovers all tools from an MCP server and creates ExecutableTools.
mcpSchemaToZodConverts MCP JSON Schema to Zod schema. Basic conversion - supports common types.
MCPToolFactory function for creating MCPToolComponent in JSX
mergeMCPConfigMerges base config with runtime overrides. Runtime values take precedence.
normalizeMCPConfigNormalizes Cursor-style config to full MCPConfig.
normalizeResultNormalize MCP tool result to ContentBlock[].

Released under the MIT License.