AIDK API Reference / aidk/mcp / createMCPTool
Function: createMCPTool() ​
ts
function createMCPTool(options: CreateMCPToolOptions): (props?: Partial<CreateMCPToolOptions>) => Component;Defined in: packages/core/src/mcp/create-mcp-tool.ts:136
Creates an MCP tool component that discovers and registers on mount.
Use this when you need:
- Dynamic discovery at runtime
- Runtime configuration (auth tokens)
- JSX-based tool declaration
Parameters ​
| Parameter | Type |
|---|---|
options | CreateMCPToolOptions |
Returns ​
ts
new createMCPTool(props?: Partial<CreateMCPToolOptions>): Component;Parameters ​
| Parameter | Type |
|---|---|
props? | Partial<CreateMCPToolOptions> |
Returns ​
Examples ​
tsx
const ReadFile = createMCPTool({
server: 'filesystem',
config: { command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/path'] },
toolName: 'read_file',
});
function MyAgent() {
return (
<>
<ReadFile />
<Model />
</>
);
}tsx
const APITool = createMCPTool({
server: 'api',
config: { transport: 'sse', connection: { url: 'https://api.example.com/mcp' } },
toolName: 'query',
});
// Runtime config from user context
<APITool runtimeConfig={{ auth: { type: 'bearer', token: userToken } }} />