dynmcp 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../package.json","../src/proxy/index.ts","../src/proxy/tool-catalog.ts","../src/proxy/server.ts","../src/proxy/upstream-client.ts","../src/index.ts"],"sourcesContent":["import process from \"node:process\";\nimport { Command } from \"commander\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\nimport figlet from \"figlet\";\nimport chalk from \"chalk\";\nimport { startProxy } from \"./proxy/index.js\";\n\nconst cliBanner = chalk.bold.magentaBright(\n figlet.textSync(\"DYNAMIC MCP\", {\n font: \"Sub-Zero\",\n horizontalLayout: \"fitted\",\n verticalLayout: \"fitted\",\n }),\n);\n\nexport const cli = new Command(packageJson.name)\n .description(packageJson.description)\n .version(packageJson.version)\n .addHelpText(\"beforeAll\", cliBanner)\n .addHelpText(\"after\", \"\\nExample:\\n dynmcp -- npx -y chrome-devtools-mcp@latest\\n\")\n .allowExcessArguments(true)\n .passThroughOptions(true)\n .action(async () => {\n const separatorIndex = process.argv.indexOf(\"--\");\n\n if (separatorIndex === -1) {\n process.stderr.write(\n \"dynmcp: no upstream command provided.\\n\" +\n \"Usage: dynmcp -- <command> [args...]\\n\" +\n \"Example: dynmcp -- npx -y chrome-devtools-mcp@latest\\n\",\n );\n process.exit(1);\n }\n\n const [command, ...args] = process.argv.slice(separatorIndex + 1);\n\n if (command === undefined) {\n process.stderr.write(\n \"dynmcp: no upstream command provided.\\n\" +\n \"Usage: dynmcp -- <command> [args...]\\n\" +\n \"Example: dynmcp -- npx -y chrome-devtools-mcp@latest\\n\",\n );\n process.exit(1);\n }\n\n try {\n await startProxy(command, args);\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n });\n","{\n \"name\": \"dynmcp\",\n \"version\": \"0.0.1\",\n \"description\": \"Dynamic MCP context management tool for AI MCP-enabled agents and clients.\",\n \"author\": \"Brandon Burrus <brandon@burrus.io>\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"homepage\": \"https://github.com/brandonburrus/dynamic-discovery-mcp#readme\",\n \"keywords\": [\n \"mcp\",\n \"model-context-protocol\",\n \"ai\",\n \"agent\",\n \"proxy\",\n \"dynamic\",\n \"discovery\",\n \"tools\",\n \"llm\",\n \"cli\"\n ],\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/brandonburrus/dynamic-discovery-mcp.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/brandonburrus/dynamic-discovery-mcp/issues\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"dynmcp\": \"./dist/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsx src/index.ts\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"biome lint .\",\n \"format\": \"biome format --write .\",\n \"check\": \"biome check --write .\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"prepare\": \"husky\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.29.0\",\n \"boxen\": \"^8.0.1\",\n \"chalk\": \"^5.6.2\",\n \"commander\": \"^14.0.3\",\n \"enquirer\": \"^2.4.1\",\n \"fastmcp\": \"^4.0.1\",\n \"figlet\": \"^1.11.0\",\n \"figures\": \"^6.1.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.4.15\",\n \"@commitlint/cli\": \"^21.0.1\",\n \"@commitlint/config-conventional\": \"^21.0.1\",\n \"@types/node\": \"^25.9.0\",\n \"husky\": \"^9.1.7\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.22.2\",\n \"typescript\": \"^6.0.3\",\n \"vitest\": \"^4.1.6\"\n }\n}\n","import process from \"node:process\";\nimport { ToolCatalog } from \"./tool-catalog.js\";\nimport { ProxyServer } from \"./server.js\";\nimport { UpstreamClient } from \"./upstream-client.js\";\n\nexport async function startProxy(command: string, args: string[]): Promise<void> {\n let isShuttingDown = false;\n\n const shutdown = (exitCode: number): void => {\n if (isShuttingDown) return;\n isShuttingDown = true;\n\n upstreamClient\n .disconnect()\n .catch((error: unknown) => {\n process.stderr.write(\n `dynmcp: error during disconnect: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n })\n .finally(() => process.exit(exitCode));\n };\n\n const upstreamClient = new UpstreamClient({\n command,\n args,\n onTransportError: (error: Error) => {\n process.stderr.write(`Upstream MCP transport error: ${error.message}\\n`);\n shutdown(1);\n },\n });\n\n try {\n await upstreamClient.connect();\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n\n let tools: Awaited<ReturnType<UpstreamClient[\"listTools\"]>>;\n try {\n tools = await upstreamClient.listTools();\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n\n const catalog = new ToolCatalog(tools);\n const proxyServer = new ProxyServer({ catalog, upstreamClient });\n\n process.on(\"SIGINT\", () => shutdown(0));\n process.on(\"SIGTERM\", () => shutdown(0));\n process.stdin.on(\"end\", () => shutdown(0));\n process.stdin.on(\"close\", () => shutdown(0));\n\n await proxyServer.start();\n}\n","import type { UpstreamTool } from \"./upstream-client.js\";\n\nconst DISCOVER_TOOL_PREAMBLE = `Use this tool to look up the full schema of a tool before calling it with use_tool.\nCall discover_tool with a tool name from the list below to get its complete description,\ninput parameters, and output schema. Always discover a tool before using it.`;\n\nexport class ToolCatalog {\n readonly tools: ReadonlyMap<string, UpstreamTool>;\n readonly discoverToolDescription: string;\n\n constructor(upstreamTools: UpstreamTool[]) {\n const toolMap = new Map<string, UpstreamTool>();\n for (const tool of upstreamTools) {\n toolMap.set(tool.name, tool);\n }\n this.tools = toolMap;\n this.discoverToolDescription = buildDiscoverToolDescription(upstreamTools);\n }\n\n getToolDetails(toolName: string): string {\n const tool = this.tools.get(toolName);\n\n if (tool === undefined) {\n const sortedNames = [...this.tools.keys()].sort().join(\", \");\n return `Unknown tool: \"${toolName}\". Available tools: ${sortedNames}`;\n }\n\n return buildToolDetailsString(tool);\n }\n}\n\nfunction buildDiscoverToolDescription(tools: UpstreamTool[]): string {\n const sortedTools = [...tools].sort((a, b) => a.name.localeCompare(b.name));\n const toolLines = sortedTools.map(tool => `- ${tool.name}: ${tool.description}`).join(\"\\n\");\n\n return `${DISCOVER_TOOL_PREAMBLE}\\n\\n<tools>\\n${toolLines}\\n</tools>`;\n}\n\nfunction buildToolDetailsString(tool: UpstreamTool): string {\n const lines: string[] = [\n `Tool: ${tool.name}`,\n `Description: ${tool.description}`,\n \"\",\n \"Input Schema:\",\n JSON.stringify(tool.inputSchema, null, 2),\n ];\n\n if (tool.outputSchema !== undefined) {\n lines.push(\"\", \"Output Schema:\", JSON.stringify(tool.outputSchema, null, 2));\n }\n\n const annotationLines = buildAnnotationLines(tool);\n if (annotationLines.length > 0) {\n lines.push(\"\", \"Annotations:\", ...annotationLines);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction buildAnnotationLines(tool: UpstreamTool): string[] {\n if (tool.annotations === undefined) {\n return [];\n }\n\n const { annotations } = tool;\n const lines: string[] = [];\n\n if (annotations.title !== undefined) {\n lines.push(`- title: ${annotations.title}`);\n }\n if (annotations.readOnlyHint !== undefined) {\n lines.push(`- readOnlyHint: ${annotations.readOnlyHint}`);\n }\n if (annotations.destructiveHint !== undefined) {\n lines.push(`- destructiveHint: ${annotations.destructiveHint}`);\n }\n if (annotations.idempotentHint !== undefined) {\n lines.push(`- idempotentHint: ${annotations.idempotentHint}`);\n }\n if (annotations.openWorldHint !== undefined) {\n lines.push(`- openWorldHint: ${annotations.openWorldHint}`);\n }\n\n return lines;\n}\n","import process from \"node:process\";\nimport { FastMCP } from \"fastmcp\";\nimport { z } from \"zod\";\nimport packageJson from \"../../package.json\" with { type: \"json\" };\nimport type { ToolCatalog } from \"./tool-catalog.js\";\nimport type { UpstreamClient } from \"./upstream-client.js\";\n\ntype ProxyServerConfig = {\n catalog: ToolCatalog;\n upstreamClient: UpstreamClient;\n};\n\nexport class ProxyServer {\n private readonly catalog: ToolCatalog;\n private readonly upstreamClient: UpstreamClient;\n\n constructor({ catalog, upstreamClient }: ProxyServerConfig) {\n this.catalog = catalog;\n this.upstreamClient = upstreamClient;\n }\n\n async start(): Promise<void> {\n const server = new FastMCP({\n name: \"dynamic-discovery-mcp\",\n version: packageJson.version as `${number}.${number}.${number}`,\n });\n\n server.addTool({\n name: \"discover_tool\",\n description: this.catalog.discoverToolDescription,\n parameters: z.object({ tool_name: z.string() }),\n execute: async ({ tool_name }) => {\n return this.catalog.getToolDetails(tool_name);\n },\n });\n\n server.addTool({\n name: \"use_tool\",\n description: \"Use a tool that was previously discovered with the discover_tool tool.\",\n parameters: z.object({\n tool_name: z.string(),\n tool_input: z.record(z.string(), z.unknown()).default({}),\n }),\n execute: async ({ tool_name, tool_input }) => {\n if (!this.catalog.tools.has(tool_name)) {\n return this.catalog.getToolDetails(tool_name);\n }\n\n const result = await this.upstreamClient.callTool(tool_name, tool_input);\n return result;\n },\n });\n\n process.stderr.write(\"Starting dynamic-discovery-mcp server over stdio\\n\");\n await server.start({ transportType: \"stdio\" });\n }\n}\n","import process from \"node:process\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\";\nimport type { ContentResult } from \"fastmcp\";\n\nexport type ToolAnnotations = {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n};\n\nexport type UpstreamTool = {\n name: string;\n description: string;\n inputSchema: unknown;\n outputSchema?: unknown;\n annotations?: ToolAnnotations;\n};\n\ntype UpstreamClientConfig = {\n command: string;\n args: string[];\n onTransportError?: (error: Error) => void;\n};\n\nexport class UpstreamClient {\n private readonly command: string;\n private readonly args: string[];\n private readonly onTransportError: (error: Error) => void;\n private client: Client | null = null;\n private transport: StdioClientTransport | null = null;\n\n constructor({ command, args, onTransportError }: UpstreamClientConfig) {\n this.command = command;\n this.args = args;\n this.onTransportError =\n onTransportError ??\n ((error: Error) => {\n process.stderr.write(`Upstream MCP transport error: ${error.message}\\n`);\n });\n }\n\n async connect(): Promise<void> {\n this.transport = new StdioClientTransport({\n command: this.command,\n args: this.args,\n });\n\n this.transport.onerror = this.onTransportError;\n\n this.client = new Client({ name: \"dynamic-discovery-mcp\", version: \"1.0.0\" });\n await this.client.connect(this.transport);\n }\n\n async listTools(): Promise<UpstreamTool[]> {\n if (this.client === null) {\n throw new Error(\"Client is not connected. Call connect() first.\");\n }\n\n const result = await this.client.listTools();\n\n return result.tools.map(tool => {\n const upstreamTool: UpstreamTool = {\n name: tool.name,\n description: tool.description ?? \"\",\n inputSchema: tool.inputSchema,\n };\n\n if (tool.outputSchema !== undefined) {\n upstreamTool.outputSchema = tool.outputSchema;\n }\n\n if (tool.annotations !== undefined) {\n upstreamTool.annotations = {\n title: tool.annotations.title,\n readOnlyHint: tool.annotations.readOnlyHint,\n destructiveHint: tool.annotations.destructiveHint,\n idempotentHint: tool.annotations.idempotentHint,\n openWorldHint: tool.annotations.openWorldHint,\n };\n }\n\n return upstreamTool;\n });\n }\n\n async callTool(name: string, input: Record<string, unknown>): Promise<ContentResult> {\n if (this.client === null) {\n throw new Error(\"Client is not connected. Call connect() first.\");\n }\n\n return this.client.callTool({\n name,\n arguments: input,\n }) as Promise<ContentResult>;\n }\n\n async disconnect(): Promise<void> {\n if (this.client === null) {\n return;\n }\n\n await this.client.close();\n this.client = null;\n this.transport = null;\n }\n}\n","import { cli } from \"./cli.js\";\nimport process from \"node:process\";\n\nasync function main() {\n cli.parse(process.argv);\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,uBAAoB;AACpB,uBAAwB;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,QAAU;AAAA,EACV,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,UAAY;AAAA,EACZ,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,KAAO;AAAA,IACL,QAAU;AAAA,EACZ;AAAA,EACA,SAAW;AAAA,IACT,KAAK;AAAA,MACH,OAAS;AAAA,MACT,QAAU;AAAA,MACV,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP;AAAA,EACF;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,KAAO;AAAA,IACP,WAAa;AAAA,IACb,MAAQ;AAAA,IACR,QAAU;AAAA,IACV,OAAS;AAAA,IACT,MAAQ;AAAA,IACR,cAAc;AAAA,IACd,iBAAiB;AAAA,IACjB,SAAW;AAAA,EACb;AAAA,EACA,cAAgB;AAAA,IACd,6BAA6B;AAAA,IAC7B,OAAS;AAAA,IACT,OAAS;AAAA,IAC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,CAAC;;;AMlDH,IAAAC,uBAAoB;AAEpB,eAAe,OAAO;AACpB,MAAI,MAAM,qBAAAC,QAAQ,IAAI;AACxB;AAEA,KAAK;","names":["import_node_process","import_node_process","process","import_node_process","process","process","chalk","figlet","process","import_node_process","process"]}
1
+ {"version":3,"sources":["../src/cli.ts","../package.json","../src/proxy/index.ts","../src/config/schema.ts","../src/config/loader.ts","../src/proxy/transport-factory.ts","../src/proxy/tool-catalog.ts","../src/proxy/upstream-client.ts","../src/proxy/orchestrator.ts","../src/proxy/server.ts","../src/index.ts"],"sourcesContent":["import process from \"node:process\";\nimport { Command } from \"commander\";\nimport packageJson from \"../package.json\" with { type: \"json\" };\nimport figlet from \"figlet\";\nimport chalk from \"chalk\";\nimport { startProxy, startProxyFromConfig } from \"./proxy/index.js\";\n\nconst cliBanner = chalk.bold.magentaBright(\n figlet.textSync(\"DYNAMIC MCP\", {\n font: \"Sub-Zero\",\n horizontalLayout: \"fitted\",\n verticalLayout: \"fitted\",\n }),\n);\n\nexport const cli = new Command(packageJson.name)\n .description(packageJson.description)\n .version(packageJson.version)\n .addHelpText(\"beforeAll\", cliBanner)\n .addHelpText(\n \"after\",\n \"\\nExamples:\\n\" +\n \" dynmcp -- npx -y chrome-devtools-mcp@latest\\n\" +\n \" dynmcp --config ./mcp.json\\n\",\n )\n .option(\"-c, --config <path>\", \"Path to config file (JSON or YAML)\")\n .allowExcessArguments(true)\n .passThroughOptions(true)\n .action(async (_options, cmd) => {\n const separatorIndex = process.argv.indexOf(\"--\");\n const configPath = cmd.opts().config as string | undefined;\n\n if (separatorIndex !== -1) {\n const [command, ...args] = process.argv.slice(separatorIndex + 1);\n\n if (command === undefined) {\n process.stderr.write(\n \"dynmcp: no upstream command provided after --.\\n\" +\n \"Usage: dynmcp -- <command> [args...]\\n\",\n );\n process.exit(1);\n }\n\n try {\n await startProxy(command, args);\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n return;\n }\n\n try {\n await startProxyFromConfig(configPath);\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n });\n","{\n \"name\": \"dynmcp\",\n \"version\": \"0.1.0\",\n \"description\": \"Dynamic MCP context management tool for AI MCP-enabled agents and clients.\",\n \"author\": \"Brandon Burrus <brandon@burrus.io>\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"homepage\": \"https://github.com/brandonburrus/dynamic-discovery-mcp#readme\",\n \"keywords\": [\n \"mcp\",\n \"model-context-protocol\",\n \"ai\",\n \"agent\",\n \"proxy\",\n \"dynamic\",\n \"discovery\",\n \"tools\",\n \"llm\",\n \"cli\"\n ],\n \"engines\": {\n \"node\": \">=20.0.0\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/brandonburrus/dynamic-discovery-mcp.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/brandonburrus/dynamic-discovery-mcp/issues\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"dynmcp\": \"./dist/index.js\"\n },\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsx src/index.ts\",\n \"typecheck\": \"tsc --noEmit\",\n \"lint\": \"biome lint .\",\n \"format\": \"biome format --write .\",\n \"check\": \"biome check --write .\",\n \"test\": \"vitest run\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage\",\n \"prepare\": \"husky\"\n },\n \"dependencies\": {\n \"@modelcontextprotocol/sdk\": \"^1.29.0\",\n \"boxen\": \"^8.0.1\",\n \"chalk\": \"^5.6.2\",\n \"commander\": \"^14.0.3\",\n \"enquirer\": \"^2.4.1\",\n \"fastmcp\": \"^4.0.1\",\n \"figlet\": \"^1.11.0\",\n \"figures\": \"^6.1.0\",\n \"yaml\": \"^2.9.0\",\n \"zod\": \"^4.4.3\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.4.15\",\n \"@commitlint/cli\": \"^21.0.1\",\n \"@commitlint/config-conventional\": \"^21.0.1\",\n \"@types/node\": \"^25.9.0\",\n \"husky\": \"^9.1.7\",\n \"tsup\": \"^8.5.1\",\n \"tsx\": \"^4.22.2\",\n \"typescript\": \"^6.0.3\",\n \"vitest\": \"^4.1.6\"\n }\n}\n","import process from \"node:process\";\nimport { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\";\nimport { loadConfig } from \"../config/index.js\";\nimport { createTransport } from \"./transport-factory.js\";\nimport { Orchestrator } from \"./orchestrator.js\";\nimport { ToolCatalog } from \"./tool-catalog.js\";\nimport { ProxyServer } from \"./server.js\";\nimport { UpstreamClient } from \"./upstream-client.js\";\n\nexport async function startProxy(command: string, args: string[]): Promise<void> {\n let isShuttingDown = false;\n\n const transport = new StdioClientTransport({ command, args });\n\n const upstreamClient = new UpstreamClient({\n name: command,\n transport,\n onTransportError: (error: Error) => {\n process.stderr.write(`Upstream MCP transport error: ${error.message}\\n`);\n shutdown(1);\n },\n });\n\n const shutdown = (exitCode: number): void => {\n if (isShuttingDown) return;\n isShuttingDown = true;\n\n upstreamClient\n .disconnect()\n .catch((error: unknown) => {\n process.stderr.write(\n `dynmcp: error during disconnect: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n })\n .finally(() => process.exit(exitCode));\n };\n\n try {\n await upstreamClient.connect();\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n\n let tools: Awaited<ReturnType<UpstreamClient[\"listTools\"]>>;\n try {\n tools = await upstreamClient.listTools();\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n\n const catalog = ToolCatalog.fromFlat(tools);\n const proxyServer = new ProxyServer({\n catalog,\n callTool: (name, input) => upstreamClient.callTool(name, input),\n });\n\n process.on(\"SIGINT\", () => shutdown(0));\n process.on(\"SIGTERM\", () => shutdown(0));\n process.stdin.on(\"end\", () => shutdown(0));\n process.stdin.on(\"close\", () => shutdown(0));\n\n try {\n await proxyServer.start();\n } catch (error) {\n shutdown(1);\n throw error;\n }\n}\n\nexport async function startProxyFromConfig(configPath?: string): Promise<void> {\n let isShuttingDown = false;\n\n const config = loadConfig(configPath);\n\n const mcps = new Map<string, { transport: ReturnType<typeof createTransport> }>();\n for (const [name, entry] of Object.entries(config.mcp)) {\n mcps.set(name, { transport: createTransport(entry) });\n }\n\n const orchestrator = new Orchestrator({\n mcps,\n onTransportError: (mcpName: string, error: Error) => {\n process.stderr.write(`Upstream MCP \"${mcpName}\" transport error: ${error.message}\\n`);\n shutdown(1);\n },\n });\n\n const shutdown = (exitCode: number): void => {\n if (isShuttingDown) return;\n isShuttingDown = true;\n\n orchestrator\n .disconnectAll()\n .catch((error: unknown) => {\n process.stderr.write(\n `dynmcp: error during disconnect: ${error instanceof Error ? error.message : String(error)}\\n`,\n );\n })\n .finally(() => process.exit(exitCode));\n };\n\n try {\n await orchestrator.connect();\n } catch (error) {\n process.stderr.write(`dynmcp: ${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n }\n\n const proxyServer = new ProxyServer({\n catalog: orchestrator.catalog,\n callTool: (name, input) => orchestrator.callTool(name, input),\n });\n\n process.on(\"SIGINT\", () => shutdown(0));\n process.on(\"SIGTERM\", () => shutdown(0));\n process.stdin.on(\"end\", () => shutdown(0));\n process.stdin.on(\"close\", () => shutdown(0));\n\n try {\n await proxyServer.start();\n } catch (error) {\n shutdown(1);\n throw error;\n }\n}\n","import { z } from \"zod\";\n\nexport const MCP_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;\n\nconst mcpName = z.string().regex(MCP_NAME_PATTERN);\n\nconst stdioTransport = z\n .object({\n transport: z.literal(\"stdio\"),\n command: z.string(),\n args: z.array(z.string()).optional(),\n env: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\nconst httpUrl = z\n .string()\n .url()\n .refine(u => u.startsWith(\"http://\") || u.startsWith(\"https://\"), {\n message: \"URL must use http:// or https:// scheme\",\n });\n\nconst streamableHttpTransport = z\n .object({\n transport: z.literal(\"streamable-http\"),\n url: httpUrl,\n headers: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\nconst sseTransport = z\n .object({\n transport: z.literal(\"sse\"),\n url: httpUrl,\n headers: z.record(z.string(), z.string()).optional(),\n })\n .strict();\n\nconst transportConfig = z.discriminatedUnion(\"transport\", [\n stdioTransport,\n streamableHttpTransport,\n sseTransport,\n]);\n\nexport const mcpConfigSchema = z.object({\n mcp: z\n .record(mcpName, transportConfig)\n .refine(obj => Object.keys(obj).length > 0, { message: \"At least one MCP must be configured\" }),\n});\n\nexport type McpConfig = z.infer<typeof mcpConfigSchema>;\n","import { readFileSync } from \"node:fs\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { parse as parseYaml } from \"yaml\";\nimport { type McpConfig, mcpConfigSchema } from \"./schema.js\";\n\nconst AUTO_DISCOVER_NAMES = [\"mcp.json\", \".mcp.json\"] as const;\n\n/**\n * Resolves the config file path without loading or parsing it.\n *\n * @param explicitPath - If provided, resolves this path directly.\n * @returns The absolute path to the config file.\n * @throws If no config file is found at the explicit path or via auto-discovery.\n */\nexport function resolveConfigPath(explicitPath?: string): string {\n if (explicitPath) {\n const resolved = resolve(explicitPath);\n if (!existsSync(resolved)) {\n throw new Error(`Config file not found: ${resolved}`);\n }\n return resolved;\n }\n\n const cwd = process.cwd();\n for (const name of AUTO_DISCOVER_NAMES) {\n const candidate = resolve(cwd, name);\n if (existsSync(candidate)) {\n return candidate;\n }\n }\n\n const searched = AUTO_DISCOVER_NAMES.map(n => resolve(cwd, n)).join(\", \");\n throw new Error(`No config file found. Searched: ${searched}`);\n}\n\n/**\n * Loads, parses, and validates the dynmcp config file.\n *\n * @param explicitPath - If provided, loads from this path. Otherwise auto-discovers.\n * @returns The validated config object.\n * @throws On missing file, parse errors, or schema validation failures.\n */\nexport function loadConfig(explicitPath?: string): McpConfig {\n const configPath = resolveConfigPath(explicitPath);\n const raw = readFileSync(configPath, \"utf-8\");\n\n let content: unknown;\n try {\n content = isYamlFile(configPath) ? parseYaml(raw) : JSON.parse(raw);\n } catch (parseError) {\n const message = parseError instanceof Error ? parseError.message : String(parseError);\n throw new Error(`Failed to parse config file (${configPath}): ${message}`);\n }\n\n const result = mcpConfigSchema.safeParse(content);\n if (!result.success) {\n const formatted = result.error.issues\n .map(issue => ` - ${issue.path.join(\".\")}: ${issue.message}`)\n .join(\"\\n\");\n throw new Error(`Invalid config file (${configPath}):\\n${formatted}`);\n }\n\n return result.data;\n}\n\nfunction isYamlFile(filePath: string): boolean {\n return filePath.endsWith(\".yml\") || filePath.endsWith(\".yaml\");\n}\n","import { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\";\nimport { StreamableHTTPClientTransport } from \"@modelcontextprotocol/sdk/client/streamableHttp.js\";\nimport { SSEClientTransport } from \"@modelcontextprotocol/sdk/client/sse.js\";\nimport type { Transport } from \"@modelcontextprotocol/sdk/shared/transport.js\";\n\ninterface StdioTransportConfig {\n transport: \"stdio\";\n command: string;\n args?: string[];\n env?: Record<string, string>;\n}\n\ninterface StreamableHttpTransportConfig {\n transport: \"streamable-http\";\n url: string;\n headers?: Record<string, string>;\n}\n\ninterface SseTransportConfig {\n transport: \"sse\";\n url: string;\n headers?: Record<string, string>;\n}\n\nexport type McpTransportConfig =\n | StdioTransportConfig\n | StreamableHttpTransportConfig\n | SseTransportConfig;\n\nexport function createTransport(config: McpTransportConfig): Transport {\n switch (config.transport) {\n case \"stdio\":\n return new StdioClientTransport({\n command: config.command,\n args: config.args,\n env: config.env,\n });\n\n case \"streamable-http\":\n return new StreamableHTTPClientTransport(\n new URL(config.url),\n config.headers ? { requestInit: { headers: config.headers } } : undefined,\n );\n\n case \"sse\":\n return new SSEClientTransport(\n new URL(config.url),\n config.headers ? { requestInit: { headers: config.headers } } : undefined,\n );\n\n default: {\n const _exhaustive: never = config;\n return _exhaustive;\n }\n }\n}\n","import type { UpstreamTool } from \"./upstream-client.js\";\n\nconst DISCOVER_TOOL_PREAMBLE = `Use this tool to look up the full schema of a tool before calling it with use_tool.\nCall discover_tool with a tool name from the list below to get its complete description,\ninput parameters, and output schema. Always discover a tool before using it.`;\n\nexport class ToolCatalog {\n readonly tools: ReadonlyMap<string, UpstreamTool>;\n readonly discoverToolDescription: string;\n\n private constructor(tools: Map<string, UpstreamTool>, description: string) {\n this.tools = tools;\n this.discoverToolDescription = description;\n }\n\n static fromFlat(upstreamTools: UpstreamTool[]): ToolCatalog {\n const toolMap = new Map<string, UpstreamTool>();\n for (const tool of upstreamTools) {\n toolMap.set(tool.name, tool);\n }\n const description = buildFlatDescription(upstreamTools);\n return new ToolCatalog(toolMap, description);\n }\n\n static fromGrouped(groups: Map<string, UpstreamTool[]>): ToolCatalog {\n const toolMap = new Map<string, UpstreamTool>();\n for (const [mcpName, tools] of groups) {\n for (const tool of tools) {\n toolMap.set(`${mcpName}/${tool.name}`, tool);\n }\n }\n const description = buildGroupedDescription(groups);\n return new ToolCatalog(toolMap, description);\n }\n\n getToolDetails(toolName: string): string {\n const tool = this.tools.get(toolName);\n\n if (tool === undefined) {\n const sortedNames = [...this.tools.keys()].sort().join(\", \");\n return `Unknown tool: \"${toolName}\". Available tools: ${sortedNames}`;\n }\n\n return buildToolDetailsString(toolName, tool);\n }\n}\n\nfunction buildFlatDescription(tools: UpstreamTool[]): string {\n const sortedTools = [...tools].sort((a, b) => a.name.localeCompare(b.name));\n const toolLines = sortedTools.map(tool => `- ${tool.name}: ${tool.description}`).join(\"\\n\");\n\n return `${DISCOVER_TOOL_PREAMBLE}\\n\\n<tools>\\n${toolLines}\\n</tools>`;\n}\n\nfunction buildGroupedDescription(groups: Map<string, UpstreamTool[]>): string {\n const sortedMcpNames = [...groups.keys()].sort();\n const sections = sortedMcpNames.map(mcpName => {\n const tools = groups.get(mcpName)!;\n const sortedTools = [...tools].sort((a, b) => a.name.localeCompare(b.name));\n const toolLines = sortedTools\n .map(tool => `- ${mcpName}/${tool.name}: ${tool.description}`)\n .join(\"\\n\");\n return `${mcpName}:\\n${toolLines}`;\n });\n\n return `${DISCOVER_TOOL_PREAMBLE}\\n\\n<tools>\\n${sections.join(\"\\n\\n\")}\\n</tools>`;\n}\n\nfunction buildToolDetailsString(displayName: string, tool: UpstreamTool): string {\n const lines: string[] = [\n `Tool: ${displayName}`,\n `Description: ${tool.description}`,\n \"\",\n \"Input Schema:\",\n JSON.stringify(tool.inputSchema, null, 2),\n ];\n\n if (tool.outputSchema !== undefined) {\n lines.push(\"\", \"Output Schema:\", JSON.stringify(tool.outputSchema, null, 2));\n }\n\n const annotationLines = buildAnnotationLines(tool);\n if (annotationLines.length > 0) {\n lines.push(\"\", \"Annotations:\", ...annotationLines);\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction buildAnnotationLines(tool: UpstreamTool): string[] {\n if (tool.annotations === undefined) {\n return [];\n }\n\n const { annotations } = tool;\n const lines: string[] = [];\n\n if (annotations.title !== undefined) {\n lines.push(`- title: ${annotations.title}`);\n }\n if (annotations.readOnlyHint !== undefined) {\n lines.push(`- readOnlyHint: ${annotations.readOnlyHint}`);\n }\n if (annotations.destructiveHint !== undefined) {\n lines.push(`- destructiveHint: ${annotations.destructiveHint}`);\n }\n if (annotations.idempotentHint !== undefined) {\n lines.push(`- idempotentHint: ${annotations.idempotentHint}`);\n }\n if (annotations.openWorldHint !== undefined) {\n lines.push(`- openWorldHint: ${annotations.openWorldHint}`);\n }\n\n return lines;\n}\n","import process from \"node:process\";\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport type { Transport } from \"@modelcontextprotocol/sdk/shared/transport.js\";\nimport type { ContentResult } from \"fastmcp\";\n\nexport type ToolAnnotations = {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n};\n\nexport type UpstreamTool = {\n name: string;\n description: string;\n inputSchema: unknown;\n outputSchema?: unknown;\n annotations?: ToolAnnotations;\n};\n\ntype UpstreamClientConfig = {\n name: string;\n transport: Transport;\n onTransportError?: (error: Error) => void;\n};\n\nexport class UpstreamClient {\n private readonly transport: Transport;\n private readonly onTransportError: (error: Error) => void;\n private client: Client | null = null;\n\n constructor({ name, transport, onTransportError }: UpstreamClientConfig) {\n this.transport = transport;\n this.onTransportError =\n onTransportError ??\n ((error: Error) => {\n process.stderr.write(`[${name}] Upstream MCP transport error: ${error.message}\\n`);\n });\n }\n\n async connect(): Promise<void> {\n this.transport.onerror = this.onTransportError;\n this.client = new Client({ name: \"dynamic-discovery-mcp\", version: \"1.0.0\" });\n await this.client.connect(this.transport);\n }\n\n async listTools(): Promise<UpstreamTool[]> {\n if (this.client === null) {\n throw new Error(\"Client is not connected. Call connect() first.\");\n }\n\n const result = await this.client.listTools();\n\n return result.tools.map(tool => {\n const upstreamTool: UpstreamTool = {\n name: tool.name,\n description: tool.description ?? \"\",\n inputSchema: tool.inputSchema,\n };\n\n if (tool.outputSchema !== undefined) {\n upstreamTool.outputSchema = tool.outputSchema;\n }\n\n if (tool.annotations !== undefined) {\n upstreamTool.annotations = {\n title: tool.annotations.title,\n readOnlyHint: tool.annotations.readOnlyHint,\n destructiveHint: tool.annotations.destructiveHint,\n idempotentHint: tool.annotations.idempotentHint,\n openWorldHint: tool.annotations.openWorldHint,\n };\n }\n\n return upstreamTool;\n });\n }\n\n async callTool(name: string, input: Record<string, unknown>): Promise<ContentResult> {\n if (this.client === null) {\n throw new Error(\"Client is not connected. Call connect() first.\");\n }\n\n const result = await this.client.callTool({ name, arguments: input });\n return result as ContentResult;\n }\n\n async disconnect(): Promise<void> {\n if (this.client === null) {\n return;\n }\n\n await this.client.close();\n this.client = null;\n }\n}\n","import type { Transport } from \"@modelcontextprotocol/sdk/shared/transport.js\";\nimport type { ContentResult } from \"fastmcp\";\nimport { ToolCatalog } from \"./tool-catalog.js\";\nimport { UpstreamClient } from \"./upstream-client.js\";\n\nexport type OrchestratorConfig = {\n mcps: Map<string, { transport: Transport }>;\n onTransportError?: (mcpName: string, error: Error) => void;\n};\n\nexport class Orchestrator {\n private readonly config: OrchestratorConfig;\n private readonly clients: Map<string, UpstreamClient> = new Map();\n private toolCatalog: ToolCatalog | null = null;\n\n constructor(config: OrchestratorConfig) {\n this.config = config;\n }\n\n async connect(): Promise<void> {\n const groups = new Map<string, import(\"./upstream-client.js\").UpstreamTool[]>();\n\n try {\n for (const [mcpName, { transport }] of this.config.mcps) {\n const client = new UpstreamClient({\n name: mcpName,\n transport,\n onTransportError: (error: Error) => {\n this.config.onTransportError?.(mcpName, error);\n },\n });\n\n await client.connect();\n const tools = await client.listTools();\n\n this.clients.set(mcpName, client);\n groups.set(mcpName, tools);\n }\n } catch (error) {\n await this.disconnectAll();\n throw error;\n }\n\n this.toolCatalog = ToolCatalog.fromGrouped(groups);\n }\n\n get catalog(): ToolCatalog {\n if (this.toolCatalog === null) {\n throw new Error(\"Orchestrator is not connected. Call connect() first.\");\n }\n return this.toolCatalog;\n }\n\n async callTool(namespacedName: string, input: Record<string, unknown>): Promise<ContentResult> {\n const separatorIndex = namespacedName.indexOf(\"/\");\n if (separatorIndex === -1) {\n throw new Error(\n `Invalid namespaced tool name: \"${namespacedName}\". Expected format: \"mcpName/toolName\".`,\n );\n }\n\n const mcpName = namespacedName.slice(0, separatorIndex);\n const toolName = namespacedName.slice(separatorIndex + 1);\n\n const client = this.clients.get(mcpName);\n if (client === undefined) {\n const available = [...this.clients.keys()].sort().join(\", \");\n throw new Error(`Unknown MCP: \"${mcpName}\". Available MCPs: ${available}`);\n }\n\n return client.callTool(toolName, input);\n }\n\n async disconnectAll(): Promise<void> {\n const disconnections = [...this.clients.values()].map(client => client.disconnect());\n await Promise.all(disconnections);\n this.clients.clear();\n this.toolCatalog = null;\n }\n}\n","import process from \"node:process\";\nimport { FastMCP } from \"fastmcp\";\nimport { z } from \"zod\";\nimport packageJson from \"../../package.json\" with { type: \"json\" };\nimport type { ContentResult } from \"fastmcp\";\nimport type { ToolCatalog } from \"./tool-catalog.js\";\n\ntype ToolCaller = (name: string, input: Record<string, unknown>) => Promise<ContentResult>;\n\ntype ProxyServerConfig = {\n catalog: ToolCatalog;\n callTool: ToolCaller;\n};\n\nexport class ProxyServer {\n private readonly catalog: ToolCatalog;\n private readonly callTool: ToolCaller;\n\n constructor({ catalog, callTool }: ProxyServerConfig) {\n this.catalog = catalog;\n this.callTool = callTool;\n }\n\n async start(): Promise<void> {\n const server = new FastMCP({\n name: \"dynamic-discovery-mcp\",\n version: packageJson.version as `${number}.${number}.${number}`,\n });\n\n server.addTool({\n name: \"discover_tool\",\n description: this.catalog.discoverToolDescription,\n parameters: z.object({ tool_name: z.string() }),\n execute: async ({ tool_name }) => {\n return this.catalog.getToolDetails(tool_name);\n },\n });\n\n server.addTool({\n name: \"use_tool\",\n description: \"Use a tool that was previously discovered with the discover_tool tool.\",\n parameters: z.object({\n tool_name: z.string(),\n tool_input: z.record(z.string(), z.unknown()).default({}),\n }),\n execute: async ({ tool_name, tool_input }) => {\n if (!this.catalog.tools.has(tool_name)) {\n return this.catalog.getToolDetails(tool_name);\n }\n\n const result = await this.callTool(tool_name, tool_input);\n return result;\n },\n });\n\n process.stderr.write(\"Starting dynamic-discovery-mcp server over stdio\\n\");\n await server.start({ transportType: \"stdio\" });\n }\n}\n","import { cli } from \"./cli.js\";\nimport process from \"node:process\";\n\nasync function main() {\n cli.parse(process.argv);\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,uBAAoB;AACpB,uBAAwB;;;ACDxB;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,a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AC3B,YAAY,aAAa,SAAS,EAClC;AAAA,EACC;AAAA,EACA;AAGF,EACC,OAAO,uBAAuB,oCAAoC,EAClE,qBAAqB,IAAI,EACzB,mBAAmB,IAAI,EACvB,OAAO,OAAO,UAAU,QAAQ;AAC/B,QAAM,iBAAiB,qBAAAC,QAAQ,KAAK,QAAQ,IAAI;AAChD,QAAM,aAAa,IAAI,KAAK,EAAE;AAE9B,MAAI,mBAAmB,IAAI;AACzB,UAAM,CAAC,SAAS,GAAG,IAAI,IAAI,qBAAAA,QAAQ,KAAK,MAAM,iBAAiB,CAAC;AAEhE,QAAI,YAAY,QAAW;AACzB,2BAAAA,QAAQ,OAAO;AAAA,QACb;AAAA,MAEF;AACA,2BAAAA,QAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,QAAI;AACF,YAAM,WAAW,SAAS,IAAI;AAAA,IAChC,SAAS,OAAO;AACd,2BAAAA,QAAQ,OAAO,MAAM,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAC1F,2BAAAA,QAAQ,KAAK,CAAC;AAAA,IAChB;AACA;AAAA,EACF;AAEA,MAAI;AACF,UAAM,qBAAqB,UAAU;AAAA,EACvC,SAAS,OAAO;AACd,yBAAAA,QAAQ,OAAO,MAAM,WAAW,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAC1F,yBAAAA,QAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;;;AUzDH,IAAAC,uBAAoB;AAEpB,eAAe,OAAO;AACpB,MAAI,MAAM,qBAAAC,QAAQ,IAAI;AACxB;AAEA,KAAK;","names":["import_node_process","import_node_process","import_stdio","import_node_fs","parseYaml","mcpName","process","mcpName","import_node_process","import_zod","process","process","mcpName","chalk","figlet","process","import_node_process","process"]}