UNPKG

@solana-agent-kit/adapter-mcp

Version:
50 lines (47 loc) 1.58 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Action, SolanaAgentKit } from 'solana-agent-kit'; import { z } from 'zod'; type MCPSchemaShape = { [key: string]: z.ZodType<any>; }; /** * Converts a Zod object schema to a flat shape for MCP tools * @param schema The Zod schema to convert * @returns A flattened schema shape compatible with MCP tools * @throws Error if the schema is not an object type */ declare function zodToMCPShape(schema: z.ZodTypeAny): { result: MCPSchemaShape; keys: string[]; }; /** * Creates an MCP server from a set of actions */ declare function createMcpServer(actions: Record<string, Action>, solanaAgentKit: SolanaAgentKit, options: { name: string; version: string; }): McpServer; /** * Helper to start the MCP server with stdio transport * * @param actions - The actions to expose to the MCP server * @param solanaAgentKit - The Solana agent kit * @param options - The options for the MCP server * @returns The MCP server * @throws Error if the MCP server fails to start * @example * import { ACTIONS } from "./actions"; * import { startMcpServer } from "./mcpWrapper"; * * const solanaAgentKit = new SolanaAgentKit(); * * startMcpServer(ACTIONS, solanaAgentKit, { * name: "solana-actions", * version: "1.0.0" * }); */ declare function startMcpServer(actions: Record<string, Action>, solanaAgentKit: SolanaAgentKit, options: { name: string; version: string; }): Promise<McpServer>; export { type MCPSchemaShape, createMcpServer, startMcpServer, zodToMCPShape };