{"id":49571105,"url":"https://github.com/sagargupta16/mcp-toolkit","last_synced_at":"2026-05-03T14:03:25.905Z","repository":{"id":342169177,"uuid":"1172129614","full_name":"Sagargupta16/mcp-toolkit","owner":"Sagargupta16","description":"Production-ready middleware for MCP servers - authentication, caching, rate limiting, logging, and TypeScript-first design","archived":false,"fork":false,"pushed_at":"2026-04-16T10:19:54.000Z","size":99,"stargazers_count":4,"open_issues_count":12,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-16T12:31:14.787Z","etag":null,"topics":["ai-tools","authentication","caching","logging","mcp","middleware","model-context-protocol","rate-limiting","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sagargupta16.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["Sagargupta16"]}},"created_at":"2026-03-04T01:11:07.000Z","updated_at":"2026-04-16T10:19:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Sagargupta16/mcp-toolkit","commit_stats":null,"previous_names":["sagargupta16/mcp-toolkit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Sagargupta16/mcp-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fmcp-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fmcp-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fmcp-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fmcp-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sagargupta16","download_url":"https://codeload.github.com/Sagargupta16/mcp-toolkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sagargupta16%2Fmcp-toolkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32571456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-tools","authentication","caching","logging","mcp","middleware","model-context-protocol","rate-limiting","typescript"],"created_at":"2026-05-03T14:03:24.252Z","updated_at":"2026-05-03T14:03:25.898Z","avatar_url":"https://github.com/Sagargupta16.png","language":"TypeScript","funding_links":["https://github.com/sponsors/Sagargupta16"],"categories":[],"sub_categories":[],"readme":"# MCP Toolkit\n\n![GitHub stars](https://img.shields.io/github/stars/Sagargupta16/mcp-toolkit?style=flat-square)\n![GitHub forks](https://img.shields.io/github/forks/Sagargupta16/mcp-toolkit?style=flat-square)\n![License](https://img.shields.io/github/license/Sagargupta16/mcp-toolkit?style=flat-square)\n![Last Commit](https://img.shields.io/github/last-commit/Sagargupta16/mcp-toolkit?style=flat-square)\n![npm](https://img.shields.io/badge/npm-mcp--toolkit-red?style=flat-square\u0026logo=npm)\n\n\u003e Reusable utilities and middleware for building production-ready MCP servers.\n\nStop reimplementing auth, caching, rate limiting, and logging for every MCP server. MCP Toolkit provides drop-in packages that work with the TypeScript SDK.\n\n## Packages\n\n| Package | Description | Status |\n|---------|-------------|--------|\n| [`@mcp-toolkit/auth`](packages/auth/) | API key and JWT authentication | Beta |\n| [`@mcp-toolkit/cache`](packages/cache/) | Response caching with TTL and LRU | Beta |\n| [`@mcp-toolkit/rate-limit`](packages/rate-limit/) | Rate limiting with token bucket | Beta |\n| [`@mcp-toolkit/logger`](packages/logger/) | Structured logging with JSON output and log levels | Beta |\n| [`@mcp-toolkit/cors`](packages/cors/) | Origin validation middleware | Beta |\n\n## Quick Start\n\n### Install\n\n```bash\nnpm install @mcp-toolkit/auth @mcp-toolkit/cache @mcp-toolkit/rate-limit @mcp-toolkit/logger @mcp-toolkit/cors\n```\n\n### Usage with TypeScript SDK\n\n```typescript\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { withAuth } from \"@mcp-toolkit/auth\";\nimport { withCache } from \"@mcp-toolkit/cache\";\nimport { withRateLimit } from \"@mcp-toolkit/rate-limit\";\nimport { createLogger } from \"@mcp-toolkit/logger\";\n\nconst logger = createLogger({ level: \"info\", format: \"json\" });\n\nconst server = new McpServer({\n  name: \"my-server\",\n  version: \"1.0.0\",\n});\n\n// Add middleware\nwithAuth(server, {\n  type: \"api-key\",\n  keys: [process.env.MCP_API_KEY],\n});\n\nwithRateLimit(server, {\n  strategy: \"token-bucket\",\n  maxTokens: 100,\n  refillRate: 10,\n});\n\nwithCache(server, {\n  ttl: 300,\n  maxSize: 1000,\n  strategy: \"lru\",\n});\n\n// Define tools - middleware applies automatically\nserver.tool(\"get-data\", \"Fetch data with auth + cache + rate limiting\", {\n  query: { type: \"string\", description: \"Search query\" },\n}, async ({ query }) =\u003e {\n  logger.info(\"Fetching data\", { query });\n  const result = await fetchData(query);\n  return { content: [{ type: \"text\", text: JSON.stringify(result) }] };\n});\n\nconst transport = new StdioServerTransport();\nawait server.connect(transport);\n```\n\n## Package Details\n\n### Auth\n\nMultiple authentication strategies:\n\n```typescript\n// API Key\nwithAuth(server, { type: \"api-key\", header: \"X-API-Key\", keys: [\"key1\", \"key2\"] });\n\n// JWT\nwithAuth(server, { type: \"jwt\", secret: process.env.JWT_SECRET, algorithms: [\"HS256\"] });\n\n// Custom\nwithAuth(server, { type: \"custom\", verify: async (token) =\u003e isValid(token) });\n```\n\n### Cache\n\nResponse caching with multiple strategies:\n\n```typescript\nwithCache(server, {\n  strategy: \"lru\",       // lru | ttl\n  ttl: 300,              // seconds\n  maxSize: 1000,         // max entries\n  keyGenerator: (toolName, args) =\u003e `${toolName}:${JSON.stringify(args)}`,\n});\n```\n\n### Rate Limit\n\nProtect your server from abuse:\n\n```typescript\nwithRateLimit(server, {\n  strategy: \"token-bucket\",\n  maxTokens: 100,\n  refillRate: 10,            // per second\n  onLimited: (req) =\u003e logger.warn(\"Rate limited\", { tool: req.toolName }),\n});\n```\n\n### Logger\n\nStructured logging built for MCP servers:\n\n```typescript\nconst logger = createLogger({\n  level: \"info\",             // debug | info | warn | error\n  format: \"json\",           // json | text\n  transports: [\"stdout\", { type: \"file\", path: \"./mcp-server.log\" }],\n});\n```\n\n### CORS\n\nValidate request origins when using HTTP or SSE transport:\n\n```typescript\nimport { withCors } from \"@mcp-toolkit/cors\";\n\nwithCors(server, {\n  allowedOrigins: [\"https://myapp.com\"],\n  allowedMethods: [\"GET\", \"POST\"]\n});\n// Optionally restrict HTTP methods\n```\n\n## Architecture\n\n```\nMCP Client (Claude, Cursor, etc.)\n        |\n        v\n+-------------------------+\n|     MCP Transport       |\n| (stdio / Streamable HTTP)|\n+-------------------------+\n|   @mcp-toolkit/cors     |  \u003c-- Origin validation\n+-------------------------+\n|   @mcp-toolkit/auth     |  \u003c-- Authentication layer\n+-------------------------+\n| @mcp-toolkit/rate-limit |  \u003c-- Rate limiting layer\n+-------------------------+\n|   @mcp-toolkit/cache    |  \u003c-- Caching layer\n+-------------------------+\n|  @mcp-toolkit/logger    |  \u003c-- Logging (all layers)\n+-------------------------+\n|   Your MCP Server       |\n|   (tools, resources)    |\n+-------------------------+\n```\n\n## Examples\n\nSee the [`examples/`](examples/) directory:\n\n- [Basic server with auth](examples/basic-auth-server.ts)\n- [Full production setup](examples/production-server.ts)\n\n## Contributing\n\nContributions welcome - new middleware, bug fixes, or docs improvements.\n\n1. Fork this repo\n2. Create a feature branch (`git checkout -b feat/my-middleware`)\n3. Add your code with tests\n4. Submit a PR\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.\n\n## More AI Developer Tools\n\n| Project | Description |\n|---------|-------------|\n| [claude-cost-optimizer](https://github.com/Sagargupta16/claude-cost-optimizer) | Save 30-60% on Claude Code costs - proven strategies and benchmarks |\n| [ai-git-hooks](https://github.com/Sagargupta16/ai-git-hooks) | AI-powered git hooks - auto-review diffs, generate commit messages, security scanning |\n| [claude-code-recipes](https://github.com/Sagargupta16/claude-code-recipes) | 50+ copy-paste recipes for Claude Code - commands, subagents, hooks, skills |\n| [agent-recipes](https://github.com/Sagargupta16/agent-recipes) | AI agent workflows for real-world dev tasks - code review, testing, security |\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagargupta16%2Fmcp-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagargupta16%2Fmcp-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagargupta16%2Fmcp-toolkit/lists"}