{"_id":"@ai-application-toolkit/mcp","_rev":"3-655d20c3f9db5d35e55a7f432bd291ca","name":"@ai-application-toolkit/mcp","dist-tags":{"latest":"0.1.2"},"versions":{"0.0.0":{"name":"@ai-application-toolkit/mcp","version":"0.0.0","keywords":["ai","llm","toolkit","anthropic","claude","mcp"],"author":{"name":"Danny LAN","email":"45042818+shaoyulan@users.noreply.github.com"},"license":"MIT","_id":"@ai-application-toolkit/mcp@0.0.0","maintainers":[{"name":"dannyshao","email":"dannyshao94@gmail.com"}],"homepage":"https://github.com/shaoyulan/ai-application-toolkit/tree/main/packages/integrations/mcp#readme","bugs":{"url":"https://github.com/shaoyulan/ai-application-toolkit/issues"},"dist":{"shasum":"6b9d86973cade2fd263d18438cc000dafbc0edfd","tarball":"https://registry.npmjs.org/@ai-application-toolkit/mcp/-/mcp-0.0.0.tgz","fileCount":39,"integrity":"sha512-Fx6Khj9r+lPwY+hBNynesmL8guTN7V1/oQ8Oj2rzm2K2yR6fWwhwN2qIBJ8HYMLip+UBfY1WANnBeGh9qIoSFw==","signatures":[{"sig":"MEQCIFkPkrhivmjL3pcUjVYRta7IwGLfEAshJ/fiKflTjBnmAiBB8FGkFsjR/pvk7DwTcUi5843VuU99OfNMAXXpkJPOjA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":76066},"type":"module","_from":"file:ai-application-toolkit-mcp-0.0.0.tgz","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.json","clean":"rm -rf dist","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"dannyshao","email":"dannyshao94@gmail.com"},"_resolved":"/private/var/folders/yd/ygwjqvld63b4z_j_0dk3krzm0000gq/T/cce372bf82b3b2bd7f7bdcbfd8c3b33b/ai-application-toolkit-mcp-0.0.0.tgz","_integrity":"sha512-Fx6Khj9r+lPwY+hBNynesmL8guTN7V1/oQ8Oj2rzm2K2yR6fWwhwN2qIBJ8HYMLip+UBfY1WANnBeGh9qIoSFw==","repository":{"url":"git+https://github.com/shaoyulan/ai-application-toolkit.git","type":"git","directory":"packages/integrations/mcp"},"_npmVersion":"11.11.0","description":"Expose AI Application Toolkit tools as a Model Context Protocol (MCP) server.","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","dependencies":{"jose":"^6.2.0","@modelcontextprotocol/sdk":"^1.29.0","@ai-application-toolkit/core":"0.0.0","@ai-application-toolkit/tool":"0.0.0","@ai-application-toolkit/runtime":"0.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@ai-application-toolkit/guardrail":"0.0.0"},"_npmOperationalInternal":{"tmp":"tmp/mcp_0.0.0_1782911979397_0.32940478295138576","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@ai-application-toolkit/mcp","version":"0.1.1","keywords":["ai","llm","toolkit","anthropic","claude","mcp"],"author":{"name":"Danny LAN","email":"45042818+shaoyulan@users.noreply.github.com"},"license":"MIT","_id":"@ai-application-toolkit/mcp@0.1.1","maintainers":[{"name":"dannyshao","email":"dannyshao94@gmail.com"}],"homepage":"https://github.com/shaoyulan/ai-application-toolkit/tree/main/packages/integrations/mcp#readme","bugs":{"url":"https://github.com/shaoyulan/ai-application-toolkit/issues"},"dist":{"shasum":"2fd1928c7309bff01381b6fb936cea7c83dc5912","tarball":"https://registry.npmjs.org/@ai-application-toolkit/mcp/-/mcp-0.1.1.tgz","fileCount":39,"integrity":"sha512-2HRVg8kjjoWMhi8uPdQKGNDzDbqO9RGVSNdpQjOTgc82FE0V+xBdscMmePLoXI1oMa0sRTRSLBnEF1k1dJlCWQ==","signatures":[{"sig":"MEQCIF+wd8uwIG/dfFyS7AoslxvHvbexDhkqPng58mW9B+RcAiAwdQNSccujPcHQHt8oTLm7SO3rDUaNH4+vphRm5Zqs3g==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":81891},"type":"module","_from":"file:ai-application-toolkit-mcp-0.1.1.tgz","engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"lint":"eslint src","test":"vitest run","build":"tsc -p tsconfig.json","clean":"rm -rf dist","typecheck":"tsc -p tsconfig.json --noEmit"},"_npmUser":{"name":"dannyshao","email":"dannyshao94@gmail.com"},"_resolved":"/tmp/7e5ecc8112e38f342c074a9be3ccb69a/ai-application-toolkit-mcp-0.1.1.tgz","_integrity":"sha512-2HRVg8kjjoWMhi8uPdQKGNDzDbqO9RGVSNdpQjOTgc82FE0V+xBdscMmePLoXI1oMa0sRTRSLBnEF1k1dJlCWQ==","repository":{"url":"git+https://github.com/shaoyulan/ai-application-toolkit.git","type":"git","directory":"packages/integrations/mcp"},"_npmVersion":"10.9.8","description":"Expose AI Application Toolkit tools as a Model Context Protocol (MCP) server.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.1","dependencies":{"jose":"^6.2.0","@modelcontextprotocol/sdk":"^1.29.0","@ai-application-toolkit/core":"0.1.1","@ai-application-toolkit/tool":"0.1.1","@ai-application-toolkit/runtime":"0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.10.0","@ai-application-toolkit/guardrail":"0.1.1"},"_npmOperationalInternal":{"tmp":"tmp/mcp_0.1.1_1782913594088_0.11707672161274973","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@ai-application-toolkit/mcp","version":"0.1.2","description":"Expose AI Application Toolkit tools as a Model Context Protocol (MCP) server.","license":"MIT","author":{"name":"Danny LAN","email":"45042818+shaoyulan@users.noreply.github.com"},"homepage":"https://github.com/shaoyulan/ai-application-toolkit/tree/main/packages/integrations/mcp#readme","repository":{"type":"git","url":"git+https://github.com/shaoyulan/ai-application-toolkit.git","directory":"packages/integrations/mcp"},"bugs":{"url":"https://github.com/shaoyulan/ai-application-toolkit/issues"},"keywords":["ai","llm","toolkit","anthropic","claude","mcp"],"type":"module","sideEffects":false,"engines":{"node":">=20"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"dependencies":{"@modelcontextprotocol/sdk":"^1.29.0","jose":"^6.2.0","@ai-application-toolkit/core":"0.1.1","@ai-application-toolkit/tool":"0.1.1","@ai-application-toolkit/runtime":"0.1.1"},"devDependencies":{"@types/node":"^22.10.0","typescript":"^5.7.2","vitest":"^2.1.8","@ai-application-toolkit/guardrail":"0.1.1"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc -p tsconfig.json","typecheck":"tsc -p tsconfig.json --noEmit","test":"vitest run","lint":"eslint src","clean":"rm -rf dist"},"_id":"@ai-application-toolkit/mcp@0.1.2","_integrity":"sha512-Lfet8ET5efOiPKWYEbopt4ey+o5XfxJz2i+yKgi5Jmp8dQlydtpNaAwKo8oxHhmasKeRVb+J1cS1t9eKw4E6GQ==","_resolved":"/tmp/5bc6f7b2b42b80d24709e278f372dd26/ai-application-toolkit-mcp-0.1.2.tgz","_from":"file:ai-application-toolkit-mcp-0.1.2.tgz","_nodeVersion":"22.23.0","_npmVersion":"10.9.8","dist":{"integrity":"sha512-Lfet8ET5efOiPKWYEbopt4ey+o5XfxJz2i+yKgi5Jmp8dQlydtpNaAwKo8oxHhmasKeRVb+J1cS1t9eKw4E6GQ==","shasum":"d5212ba546a01299281b666675ee1d27281deed1","tarball":"https://registry.npmjs.org/@ai-application-toolkit/mcp/-/mcp-0.1.2.tgz","fileCount":39,"unpackedSize":82501,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDd13nX5O8gGk52UwDSINmmncGCujFxpfPj+iBCTg4ezAiBrRAOQKWzTtsm9hydl88VqHsIs/DLa76cs06/vrr/T8A=="}]},"_npmUser":{"name":"dannyshao","email":"dannyshao94@gmail.com"},"directories":{},"maintainers":[{"name":"dannyshao","email":"dannyshao94@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp_0.1.2_1782921208907_0.7078330305558971"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-01T13:19:39.279Z","modified":"2026-07-01T15:53:29.190Z","0.0.0":"2026-07-01T13:19:39.560Z","0.1.1":"2026-07-01T13:46:34.234Z","0.1.2":"2026-07-01T15:53:29.054Z"},"bugs":{"url":"https://github.com/shaoyulan/ai-application-toolkit/issues"},"author":{"name":"Danny LAN","email":"45042818+shaoyulan@users.noreply.github.com"},"license":"MIT","homepage":"https://github.com/shaoyulan/ai-application-toolkit/tree/main/packages/integrations/mcp#readme","keywords":["ai","llm","toolkit","anthropic","claude","mcp"],"repository":{"type":"git","url":"git+https://github.com/shaoyulan/ai-application-toolkit.git","directory":"packages/integrations/mcp"},"description":"Expose AI Application Toolkit tools as a Model Context Protocol (MCP) server.","maintainers":[{"name":"dannyshao","email":"dannyshao94@gmail.com"}],"readme":"# @ai-application-toolkit/mcp\n\nConnect the AI Application Toolkit to the Model Context Protocol — **serve** your\ntools to MCP clients (over stdio or remote HTTP), or **consume** any external MCP\nserver's tools as toolkit tools.\n\nPart of the [AI Application Toolkit](https://github.com/shaoyulan/ai-application-toolkit#readme).\n\n## Install\n\n```bash\npnpm add @ai-application-toolkit/mcp @modelcontextprotocol/sdk\n```\n\n## Usage\n\nDefine tools once, then serve them over MCP. Tool input schemas are forwarded\nas MCP `inputSchema`, and `tools/call` runs through the toolkit runtime — so\ninput validation, guardrails, context, and tracing all apply.\n\n```ts\nimport { defineTool } from '@ai-application-toolkit/tool'\nimport { startStdioMcpServer } from '@ai-application-toolkit/mcp'\n\nconst add = defineTool({\n  id: 'add',\n  description: 'Add two numbers',\n  input: {\n    type: 'object',\n    properties: { a: { type: 'number' }, b: { type: 'number' } },\n    required: ['a', 'b'],\n    additionalProperties: false\n  },\n  execute: (input: { a: number; b: number }) => input.a + input.b\n})\n\nawait startStdioMcpServer({ name: 'my-tools', version: '1.0.0', tools: [add] })\n```\n\nUse `createMcpServer(...)` if you want to connect a transport yourself, and pass\n`runtime` to add guardrails, a base context, a trace sink, or a timeout:\n\n```ts\nimport { createMcpServer } from '@ai-application-toolkit/mcp'\n\nconst server = createMcpServer({\n  name: 'my-tools',\n  version: '1.0.0',\n  tools: [add],\n  runtime: { guardrails: [myGuardrail], timeoutMs: 5000 }\n})\n```\n\n### Serve over HTTP (remote, stateless)\n\n`startHttpMcpServer` serves the same tools over the MCP Streamable HTTP\ntransport. It is **stateless by default** (no session bound to the connection),\nso it scales horizontally behind a load balancer. `createHttpMcpHandler` returns\na framework-agnostic Node `(req, res)` handler you can mount anywhere.\n\n```ts\nimport { startHttpMcpServer } from '@ai-application-toolkit/mcp'\n\nawait startHttpMcpServer({ name: 'my-tools', version: '1.0.0', tools: [add], port: 3000 })\n// Point a Streamable HTTP MCP client at http://localhost:3000/mcp\n```\n\n### Protect it with OAuth 2.1 + scopes\n\nVerify a bearer JWT at the transport boundary with `createBearerVerifier` (JWKS),\nthen authorize per tool with `defineScopeGuardrail`. The verified caller is\nplaced on `context.metadata.auth`, where the scope guardrail reads it.\n\n```ts\nimport { startHttpMcpServer, createBearerVerifier } from '@ai-application-toolkit/mcp'\nimport { defineScopeGuardrail } from '@ai-application-toolkit/guardrail'\n\nawait startHttpMcpServer({\n  name: 'my-tools',\n  version: '1.0.0',\n  tools: [add],\n  port: 3000,\n  authenticate: createBearerVerifier({\n    jwksUri: 'https://issuer.example.com/.well-known/jwks.json',\n    issuer: 'https://issuer.example.com/',\n    audience: 'https://my-mcp-server.example.com'\n  }),\n  resourceMetadataUrl: 'https://my-mcp-server.example.com/.well-known/oauth-protected-resource',\n  runtime: { guardrails: [defineScopeGuardrail({ required: { add: ['calc:write'] } })] }\n})\n```\n\nUnauthenticated requests get `401` with a `WWW-Authenticate` challenge; callers\nmissing a required scope get the usual `GUARDRAIL_BLOCKED` tool error.\n\n## Consume an external MCP server (client)\n\n`connectMcpClient` connects to any MCP server and wraps its tools as toolkit\ntools, so they run through your runtime — picking up the same input validation,\nguardrails, timeout, and tracing as local tools.\n\n```ts\nimport { connectMcpClient } from '@ai-application-toolkit/mcp'\nimport { createRuntime } from '@ai-application-toolkit/runtime'\n\nconst remote = await connectMcpClient({\n  transport: { kind: 'stdio', command: 'some-mcp-server' }, // or { kind: 'http', url }\n  toolIdPrefix: 'remote.'\n})\n\nconst runtime = createRuntime({ tools: remote.tools, guardrails: [myGuardrail] })\nawait runtime.executeTool({ toolId: 'remote.search', input: { q: 'hello' } })\n\nawait remote.close()\n```\n\n## License\n\nMIT © Danny LAN\n","readmeFilename":"README.md"}