{"_id":"@capsuleer/mcp","_rev":"2-a461f019fec4dd8a88b0d589f5b5e3f5","name":"@capsuleer/mcp","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"@capsuleer/mcp","version":"1.0.1","keywords":["capsuleer","mcp","model-context-protocol","tools"],"author":{"name":"cody"},"license":"MIT","_id":"@capsuleer/mcp@1.0.1","maintainers":[{"name":"codywakeford","email":"codypwakeford@gmail.com"}],"dist":{"shasum":"84f4be667d06b76455de0bdb20839f1da3d81af3","tarball":"https://registry.npmjs.org/@capsuleer/mcp/-/mcp-1.0.1.tgz","fileCount":4,"integrity":"sha512-DrTTLvTIi0QeWlfBOvFBQahc9MJYoqZZtvrrxagx16Ok+o9xPKnaHFPlW6VfsaUpO7YtQU2e7bls3DnPYJdncg==","signatures":[{"sig":"MEYCIQC6w5J+1yEOY8RBXDRh0DvpwasoIbmnuj20hq1GrthzEgIhAKM92KXKVJjXEUX/CubGig+OGtsZjxyraNX2w3Rivm9H","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9342},"main":"./index.ts","type":"module","types":"./index.ts","gitHead":"0bf566506647c64f713619ba29a557dfbe78110b","_npmUser":{"name":"codywakeford","email":"codypwakeford@gmail.com"},"_npmVersion":"10.9.3","description":"MCP adapter for capsuleer — wrap any MCP server as a capsuleer module","directories":{},"_nodeVersion":"22.19.0","dependencies":{"@capsuleer/core":"latest","@modelcontextprotocol/sdk":"^1.27.1"},"_hasShrinkwrap":false,"peerDependencies":{"bun":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/mcp_1.0.1_1773947547893_0.5324030975478475","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@capsuleer/mcp","version":"1.0.2","description":"MCP adapter for capsuleer — wrap any MCP server as a capsuleer module","type":"module","main":"./index.ts","types":"./index.ts","keywords":["capsuleer","mcp","model-context-protocol","tools"],"author":{"name":"cody"},"license":"MIT","dependencies":{"@capsuleer/core":"latest","@modelcontextprotocol/sdk":"^1.27.1"},"peerDependencies":{"bun":">=1.0.0"},"_id":"@capsuleer/mcp@1.0.2","gitHead":"cdb48a4985d0d61def904ca24ff4ba7bca194601","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-AwXgPk3Bf3cAUvGBPjNlkmrIIhlhk+d6CIEDNuD+05n6X7k0swmg6xwzJ8Ci/IP1jodBFhG5Fy9Izu6hyp5Khg==","shasum":"19294cec15c5b5ae30eb0e13dd6cc82e7b06c580","tarball":"https://registry.npmjs.org/@capsuleer/mcp/-/mcp-1.0.2.tgz","fileCount":5,"unpackedSize":13219,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAM8J5pWfYdQliPnO8dWiZzb4juN0fhv2hdRf99v12JyAiApq63Mq9/wRPoDzVY9ZULW+I8SJ60EgXVOcdVuwd68Lg=="}]},"_npmUser":{"name":"codywakeford","email":"codypwakeford@gmail.com"},"directories":{},"maintainers":[{"name":"codywakeford","email":"codypwakeford@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcp_1.0.2_1773960059850_0.2704448324104063"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-19T19:12:27.764Z","modified":"2026-03-19T22:41:00.118Z","1.0.1":"2026-03-19T19:12:28.062Z","1.0.2":"2026-03-19T22:40:59.995Z"},"author":{"name":"cody"},"license":"MIT","keywords":["capsuleer","mcp","model-context-protocol","tools"],"description":"MCP adapter for capsuleer — wrap any MCP server as a capsuleer module","maintainers":[{"name":"codywakeford","email":"codypwakeford@gmail.com"}],"readme":"# @capsuleer/mcp\n\nMCP adapter for Capsuleer. Wrap any [Model Context Protocol](https://modelcontextprotocol.io) server as a Capsuleer module — its tools are automatically discovered, typed, and registered as globals in the capsule's execution scope.\n\n```bash\ncapsuleer install mcp\n```\n\n---\n\n## What it does\n\nMCP servers expose tools over a stdio JSON-RPC protocol. `@capsuleer/mcp` connects to any MCP server, calls `tools/list` to discover its full tool surface, and registers each tool as an async function on a named global. The capsule then emits a `module:manifest` event with TypeScript declarations derived from each tool's JSON Schema — so the LLM has accurate signatures and can't hallucinate a tool that doesn't exist.\n\n---\n\n## Usage\n\nCreate a `.module.ts` file in `~/.capsuleer/environment/modules/` that calls `defineMcpModule`:\n\n```typescript\n// ~/.capsuleer/environment/modules/linear.module.ts\nimport { defineMcpModule } from \"@capsuleer/mcp\"\n\nexport default await defineMcpModule({\n  name: \"linear\",\n  description: \"Linear issue tracker\",\n  command: \"npx\",\n  args: [\"-y\", \"@linear/mcp-server\"],\n  env: {\n    LINEAR_API_KEY: process.env.LINEAR_API_KEY!,\n  },\n})\n```\n\nAfter the capsule boots, agent code can call any of Linear's tools directly:\n\n```typescript\nconst issues = await linear.list_issues({ team_id: \"ENG\", state: \"open\" })\nconst issue = await linear.create_issue({ title: \"Fix auth timeout\", team_id: \"ENG\" })\n```\n\nThe tool names and parameter shapes come directly from the MCP server — no hand-written wrappers needed.\n\n---\n\n## Config\n\n```typescript\ndefineMcpModule({\n  /** Module name — becomes the global namespace in the capsule */\n  name: string\n\n  /** Shown in registry and injected into LLM context */\n  description?: string\n\n  /** Command to spawn the MCP server subprocess */\n  command: string\n\n  /** Arguments passed to the command */\n  args?: string[]\n\n  /** Environment variables forwarded to the server process */\n  env?: Record<string, string>\n})\n```\n\n---\n\n## How it works\n\n1. Spawns the MCP server subprocess via `StdioClientTransport`\n2. Connects with `@modelcontextprotocol/sdk`\n3. Calls `tools/list` (with pagination) to discover all tools\n4. For each tool, builds an async wrapper that maps positional args → the tool's JSON Schema parameter names\n5. Calls `tools/call` and extracts the text content from the response\n6. Generates TypeScript declarations from each tool's `inputSchema` for the manifest\n7. Registers graceful shutdown on `exit`, `SIGTERM`, `SIGINT`\n\nTool results are returned as strings. For tools that return structured data, parse with `JSON.parse()`.\n\n---\n\n## Examples\n\n**Filesystem via MCP (e.g. `@modelcontextprotocol/server-filesystem`):**\n```typescript\nexport default await defineMcpModule({\n  name: \"files\",\n  description: \"Filesystem access via MCP\",\n  command: \"npx\",\n  args: [\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/home/user/project\"],\n})\n```\n\n**GitHub via MCP:**\n```typescript\nexport default await defineMcpModule({\n  name: \"github\",\n  description: \"GitHub API via MCP\",\n  command: \"npx\",\n  args: [\"-y\", \"@modelcontextprotocol/server-github\"],\n  env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_TOKEN! },\n})\n```\n\n**Any local MCP server:**\n```typescript\nexport default await defineMcpModule({\n  name: \"mytools\",\n  description: \"Internal tooling\",\n  command: \"bun\",\n  args: [\"run\", \"/home/user/my-mcp-server/index.ts\"],\n  env: { API_KEY: process.env.INTERNAL_API_KEY! },\n})\n```\n\n---\n\n## Notes\n\n- The MCP server process runs as a child of the capsule — it is killed when the capsule shuts down\n- Tools with no input parameters accept an optional `args` object\n- If the server reports zero tools, `defineMcpModule` throws immediately rather than registering an empty module\n- The module is async (`await defineMcpModule(...)`) — use top-level await in your `.module.ts` file\n","readmeFilename":"README.md"}