diff --git a/packages/root/src/mcp/server.ts b/packages/root/src/mcp/server.ts new file mode 100644 index 00000000..8785efac --- /dev/null +++ b/packages/root/src/mcp/server.ts @@ -0,0 +1,32 @@ +import {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js'; +import {z} from 'zod'; +import {RootConfig} from '../core/config.js'; + +export function createMcpServer(rootConfig: RootConfig) { + const mcpServer = new McpServer({ + name: 'root-mcp', + version: '2.5.1', + }); + + // Example tool. + mcpServer.tool('echo', {message: z.string()}, async ({message}) => { + return { + content: [ + { + type: 'text', + text: `Echo: ${message}`, + }, + ], + }; + }); + + // Register plugin tools. + const plugins = rootConfig.plugins || []; + plugins.forEach((plugin) => { + if (plugin.configureMcp) { + plugin.configureMcp(mcpServer, {rootConfig}); + } + }); + + return mcpServer; +} diff --git a/response_final.txt b/response_final.txt new file mode 100644 index 00000000..cc700eb8 --- /dev/null +++ b/response_final.txt @@ -0,0 +1,13 @@ +* Host localhost:4007 was resolved. +* IPv6: ::1 +* IPv4: 127.0.0.1 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying [::1]:4007... +* connect to ::1 port 4007 from ::1 port 48980 failed: Connection refused +* Trying 127.0.0.1:4007... +* connect to 127.0.0.1 port 4007 from 127.0.0.1 port 34112 failed: Connection refused +* Failed to connect to localhost port 4007 after 3 ms: Couldn't connect to server + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 +* Closing connection +curl: (7) Failed to connect to localhost port 4007 after 3 ms: Couldn't connect to server