{"_id":"@abmalk/mcpcode","_rev":"5-1d7f20285639a6ac897c88e3bb509299","name":"@abmalk/mcpcode","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@abmalk/mcpcode","version":"1.0.0","keywords":["mcp","model-context-protocol","code-generation","typescript","cli","mcp-server","mcp-tools","type-safe","codegen"],"author":{"name":"abmalk"},"license":"ISC","_id":"@abmalk/mcpcode@1.0.0","maintainers":[{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"}],"homepage":"https://github.com/abmalk/mcpcode#readme","bugs":{"url":"https://github.com/abmalk/mcpcode/issues"},"bin":{"mcpcode":"dist/cli.js"},"dist":{"shasum":"4f6790a5ff969297afca74fa0e793cd1e10f9074","tarball":"https://registry.npmjs.org/@abmalk/mcpcode/-/mcpcode-1.0.0.tgz","fileCount":39,"integrity":"sha512-I+UIfnVYr9FhCDxA+g6KdrGbUpAowrAMhzaUdUoVBR+V4yw1onQtZOyto6SvXtKseO5G/6O2nUihwt8LWP37vQ==","signatures":[{"sig":"MEYCIQD5kSPySFTfcn0rbPS+s5Vwi3duwm62AH13rP7y2Fe5cwIhAL4SVmLgzp1BGyFnSuOrh489m6QWw0XnI24wbfCMBfeh","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":95087},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"e4916e1be041d13a6767dfe543ba1d7bdca2224f","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/cli.js","watch":"node dist/cli.js watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"},"repository":{"url":"git+https://github.com/abmalk/mcpcode.git","type":"git"},"_npmVersion":"11.5.2","description":"Generate type-safe TypeScript wrappers for Model Context Protocol (MCP) tools. Connects to MCP servers via STDIO, discovers tools automatically, and generates clean, type-safe code.","directories":{},"_nodeVersion":"22.17.1","dependencies":{"zod":"^3.25.76","chalk":"^5.4.1","commander":"^13.0.0","@modelcontextprotocol/sdk":"^1.22.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","typescript":"^5.9.3","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mcpcode_1.0.0_1764216408584_0.4550368262875373","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@abmalk/mcpcode","version":"1.0.1","keywords":["mcp","model-context-protocol","code-generation","typescript","cli","mcp-server","mcp-tools","type-safe","codegen"],"author":{"name":"abmalk"},"license":"MIT","_id":"@abmalk/mcpcode@1.0.1","maintainers":[{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"}],"homepage":"https://github.com/AbhinavMalkoochi/code-mcp#readme","bugs":{"url":"https://github.com/abmalk/mcpcode/issues"},"bin":{"mcpcode":"dist/cli.js"},"dist":{"shasum":"a3daa485b7f3ecf883507e4e3e4a71ccbe19e1ac","tarball":"https://registry.npmjs.org/@abmalk/mcpcode/-/mcpcode-1.0.1.tgz","fileCount":39,"integrity":"sha512-sVXaNpo5c3twekIhw+0tkJ07yFA4xDaiS/17CjUx5MknTc3152uLRj42oJy6r5pXYP+WxgrUiPvXCJVtxYwTrQ==","signatures":[{"sig":"MEQCICh+/0ttlfdBvXGp8mWAldfNtL2YeeV0FpzDKfdfr+/eAiBhNrPmuLaN92rHPv5sFnvE/jG7gC4ck1c3dCCi88dvQw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":94188},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"508295097c58909a37d159ca5c358c01697cdd03","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/cli.js","watch":"node dist/cli.js watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"},"repository":{"url":"git+https://github.com/AbhinavMalkoochi/code-mcp.git","type":"git"},"_npmVersion":"11.5.2","description":"Generate type-safe TypeScript wrappers for Model Context Protocol (MCP) tools. Connects to MCP servers via STDIO, discovers tools automatically, and generates clean, type-safe code.","directories":{},"_nodeVersion":"22.17.1","dependencies":{"zod":"^3.25.76","chalk":"^5.4.1","commander":"^13.0.0","@modelcontextprotocol/sdk":"^1.22.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","typescript":"^5.9.3","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mcpcode_1.0.1_1764217455579_0.15156679527349382","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@abmalk/mcpcode","version":"1.0.2","keywords":["mcp","model-context-protocol","code-generation","typescript","cli","mcp-server","mcp-tools","type-safe","codegen"],"author":{"name":"abmalk"},"license":"MIT","_id":"@abmalk/mcpcode@1.0.2","maintainers":[{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"}],"homepage":"https://github.com/AbhinavMalkoochi/code-mcp#readme","bugs":{"url":"https://github.com/abmalk/mcpcode/issues"},"bin":{"mcpcode":"dist/cli.js"},"dist":{"shasum":"06cdd8e92beff57db57176181e57a58d779afe0f","tarball":"https://registry.npmjs.org/@abmalk/mcpcode/-/mcpcode-1.0.2.tgz","fileCount":39,"integrity":"sha512-LVHRzq6rTYr3IhgNbf6OgUI3nd52RrVfuRZLBIVqlAbc+Web1Qp0bRJ1aoho+2Rn4qyQaOXF7D3DxlB67VEgIg==","signatures":[{"sig":"MEUCIEYoti5szb9nDcEHhMPPEvbNSPkiBnPEfj0+Lirp88MfAiEA9/nG/ag+It48XSJ1rwv8LaDkBX+I/gJ8M7ue9E2vllg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":112280},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"375fcacbaee49cd7cd45fbb92feeb788b2da0f80","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/cli.js","watch":"node dist/cli.js watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"},"repository":{"url":"git+https://github.com/AbhinavMalkoochi/code-mcp.git","type":"git"},"_npmVersion":"11.5.2","description":"Generate type-safe TypeScript wrappers for Model Context Protocol (MCP) tools. Connects to MCP servers via STDIO, discovers tools automatically, and generates clean, type-safe code.","directories":{},"_nodeVersion":"22.17.1","dependencies":{"zod":"^3.25.76","chalk":"^5.4.1","commander":"^13.0.0","@modelcontextprotocol/sdk":"^1.22.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","typescript":"^5.9.3","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mcpcode_1.0.2_1764220259134_0.4248807478300687","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@abmalk/mcpcode","version":"1.0.3","keywords":["mcp","model-context-protocol","code-generation","typescript","cli","mcp-server","mcp-tools","type-safe","codegen"],"author":{"name":"abmalk"},"license":"MIT","_id":"@abmalk/mcpcode@1.0.3","maintainers":[{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"}],"homepage":"https://github.com/AbhinavMalkoochi/code-mcp#readme","bugs":{"url":"https://github.com/abmalk/mcpcode/issues"},"bin":{"mcpcode":"dist/cli.js"},"dist":{"shasum":"dc4a2c4db570bc88d8effa77fc969f62b73a9673","tarball":"https://registry.npmjs.org/@abmalk/mcpcode/-/mcpcode-1.0.3.tgz","fileCount":39,"integrity":"sha512-RheVkTxV/IbWLb6N0PdpDuSigBVwCJgeJfBu7QgmwCg3+C8sMgysTk9yVG6zS4TfO2W6u+opSaLz/RzNJt8Nkg==","signatures":[{"sig":"MEUCIA0senqoPk7n7Fsat64Ic6DEBdOhXdetdPhuiA2yIJaKAiEAqGsbteLpQCSnxRFif+luW6UbMr1d09YTpnykeyz87fI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122489},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"18595a2784b75135370c099a748f8a85cb019262","scripts":{"dev":"tsc --watch","test":"echo \"Error: no test specified\" && exit 1","build":"tsc","start":"node dist/cli.js","watch":"node dist/cli.js watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"},"repository":{"url":"git+https://github.com/AbhinavMalkoochi/code-mcp.git","type":"git"},"_npmVersion":"11.5.2","description":"Generate type-safe TypeScript wrappers for Model Context Protocol (MCP) tools. Connects to MCP servers via STDIO, discovers tools automatically, and generates clean, type-safe code.","directories":{},"_nodeVersion":"22.17.1","dependencies":{"zod":"^3.25.76","chalk":"^5.4.1","commander":"^13.0.0","@modelcontextprotocol/sdk":"^1.22.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"ts-node":"^10.9.2","typescript":"^5.9.3","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/mcpcode_1.0.3_1764304895552_0.9771881569852068","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@abmalk/mcpcode","version":"1.0.4","description":"Generate type-safe TypeScript wrappers for Model Context Protocol (MCP) tools. Connects to MCP servers via STDIO, discovers tools automatically, and generates clean, type-safe code.","main":"dist/index.js","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"bin":{"mcpcode":"dist/cli.js"},"engines":{"node":">=18.0.0"},"publishConfig":{"access":"public"},"scripts":{"build":"tsc","dev":"tsc --watch","watch":"node dist/cli.js watch","start":"node dist/cli.js","prepublishOnly":"npm run build","test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/AbhinavMalkoochi/code-mcp.git"},"bugs":{"url":"https://github.com/abmalk/mcpcode/issues"},"homepage":"https://github.com/AbhinavMalkoochi/code-mcp#readme","keywords":["mcp","model-context-protocol","code-generation","typescript","cli","mcp-server","mcp-tools","type-safe","codegen"],"author":{"name":"abmalk"},"license":"MIT","dependencies":{"@modelcontextprotocol/sdk":"^1.22.0","chalk":"^5.4.1","commander":"^13.0.0","zod":"^3.25.76"},"devDependencies":{"@types/node":"^24.10.0","ts-node":"^10.9.2","typescript":"^5.9.3"},"_id":"@abmalk/mcpcode@1.0.4","gitHead":"3eaa99bc1969e26c115f4688b071d24baaa543c2","types":"./dist/index.d.ts","_nodeVersion":"22.17.1","_npmVersion":"11.5.2","dist":{"integrity":"sha512-8X9QhwlcO0lRnRJFhZGagMLmBjUrhR7eX9DCb05l2fwwL+YM9QSC0pZL9/cPQNTHh8VPjxRDdHM9d4wEFRP1GA==","shasum":"1f0af1b931f059e780985d1cd7cfaa1d4d2ea288","tarball":"https://registry.npmjs.org/@abmalk/mcpcode/-/mcpcode-1.0.4.tgz","fileCount":39,"unpackedSize":128083,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIAYNvbE/nohwQ0xkWsAY6VSL4RUibatRnwKaG7YQTvrPAiEAmT/suZyvBdVHUnmRj2yssk+um1d/SmftcSA2IgnrWuQ="}]},"_npmUser":{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"},"directories":{},"maintainers":[{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mcpcode_1.0.4_1764305721821_0.18628969313363553"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-27T04:06:48.445Z","modified":"2025-11-28T04:55:22.218Z","1.0.0":"2025-11-27T04:06:48.814Z","1.0.1":"2025-11-27T04:24:15.804Z","1.0.2":"2025-11-27T05:10:59.326Z","1.0.3":"2025-11-28T04:41:35.754Z","1.0.4":"2025-11-28T04:55:22.028Z"},"bugs":{"url":"https://github.com/abmalk/mcpcode/issues"},"author":{"name":"abmalk"},"license":"MIT","homepage":"https://github.com/AbhinavMalkoochi/code-mcp#readme","keywords":["mcp","model-context-protocol","code-generation","typescript","cli","mcp-server","mcp-tools","type-safe","codegen"],"repository":{"type":"git","url":"git+https://github.com/AbhinavMalkoochi/code-mcp.git"},"description":"Generate type-safe TypeScript wrappers for Model Context Protocol (MCP) tools. Connects to MCP servers via STDIO, discovers tools automatically, and generates clean, type-safe code.","maintainers":[{"name":"abhinavmalkoochi","email":"abhinav.malkoochi@gmail.com"}],"readme":"# MCP Code Generator\n\nGenerate type-safe TypeScript functions for your MCP tools. Instead of loading all tool definitions into your agent's context, generate code that your agent can import and use on-demand. Reduce your tool context by 98.7% compared to traditional MCP usage.\n\n## Quick Start\n\nInstall the CLI tool:\n\n```bash\nnpm install -g @abmalk/mcpcode\n```\n\nCreate a config file `mcp.config.json` in your project:\n\n```json\n{\n  \"mcpServers\": {\n    \"git\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-server-git\", \"--repository\", \".\"]\n    }\n  }\n}\n```\n\nGenerate the code:\n\n```bash\nmcpcode generate\n```\n\nThat's it. You'll find TypeScript functions in the `servers/` directory, ready to use.\n\n## Configuration\n\nThe config file tells the generator which MCP servers to connect to. Each server needs a command and optional arguments:\n\n```json\n{\n  \"mcpServers\": {\n    \"server-name\": {\n      \"command\": \"uvx\",\n      \"args\": [\"mcp-server-name\"]\n    }\n  }\n}\n```\n\nServer names can contain letters, numbers, dots, dashes, and underscores. They become the folder names in your generated code.\n\n### Environment Variables\n\nPass environment variables to MCP servers using the `env` field. Use `${VAR_NAME}` to reference environment variables:\n\n```json\n{\n  \"mcpServers\": {\n    \"github\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-github\"],\n      \"env\": {\n        \"GITHUB_TOKEN\": \"${GITHUB_TOKEN}\"\n      }\n    }\n  }\n}\n```\n\n### HTTP/SSE Transport\n\nFor web-based MCP servers, use `type: \"http\"` or `type: \"sse\"`:\n\n```json\n{\n  \"mcpServers\": {\n    \"remote\": {\n      \"type\": \"http\",\n      \"url\": \"https://mcp.example.com/api\",\n      \"headers\": {\n        \"Authorization\": \"Bearer ${API_TOKEN}\"\n      }\n    }\n  }\n}\n```\n\n### Relative Paths (STDIO)\n\nFor local STDIO servers with relative paths:\n\n```json\n{\n  \"mcpServers\": {\n    \"local\": {\n      \"command\": \"./bin/my-server\",\n      \"args\": []\n    }\n  }\n}\n```\n\n## CLI Options\n\nGenerate code once:\n\n```bash\nmcpcode generate\nmcpcode generate --config my-config.json --output generated/\nmcpcode generate --clean  # Remove output directory before generation\n```\n\nWatch for config changes and auto-regenerate:\n\n```bash\nmcpcode watch\nmcpcode watch --debounce 2000\n```\n\nAvailable options:\n\n- `-c, --config <path>` - Path to config file (default: `mcp.config.json`)\n- `-o, --output <path>` - Output directory (default: `servers/`)\n- `--clean` - Remove output directory before generation\n- `-d, --debounce <ms>` - Watch debounce delay (100-60000ms, default: `1000`)\n\n## Run Without Installing\n\nYou can use npx to run it without installing:\n\n```bash\nnpx @abmalk/mcpcode generate\n```\n\n## Why Use This?\n\nWhen you connect an agent to many MCP servers, loading all tool definitions upfront can consume a lot of tokens. This approach lets your agent:\n\n- Load tools on-demand by importing only what it needs\n- Process data in code before sending results back to the model\n- Use familiar programming constructs like loops and conditionals\n- Keep intermediate results private (they stay in the execution environment)\n\nResearch from Anthropic shows this can reduce token usage by up to 98.7% compared to loading all tools upfront.\n\n## Tool Discovery\n\nA `search.ts` file is generated with utilities for agents to discover tools:\n\n```typescript\nimport { searchTools, listServers, listTools } from \"./servers/search.js\";\n\n// Search by keyword\nconst gitTools = searchTools(\"commit\");\n\n// List all servers\nconst servers = listServers();\n\n// List tools for a server\nconst tools = listTools(\"git\");\n```\n\n## IDE Integration\n\nFor AI coding assistants (Cursor, Claude Code, etc.), you can create rules files that instruct the LLM to use your generated `servers/` folder. This ensures the assistant leverages code execution instead of direct MCP calls. See the Anthropic blog on [Code execution with MCP](https://www.anthropic.com/research/code-execution-mcp) for more details.\n\n## Supported Transports\n\n- **STDIO** (default): Local process communication\n- **HTTP**: StreamableHTTP for modern MCP servers\n- **SSE**: Server-Sent Events for legacy servers\n\n## License\n\nMIT\n","readmeFilename":"README.md"}