{"id":26163975,"url":"https://github.com/haroldadmin/fastify-mcp","last_synced_at":"2026-03-14T08:02:14.670Z","repository":{"id":280639742,"uuid":"941724940","full_name":"haroldadmin/fastify-mcp","owner":"haroldadmin","description":"A Fastify plugin to run Model Context Protocol (MCP) servers","archived":false,"fork":false,"pushed_at":"2025-06-03T19:14:57.000Z","size":186,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T03:21:34.427Z","etag":null,"topics":["ai","fastify","javascript","model-context-protocol"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/fastify-mcp","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haroldadmin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-02T23:53:49.000Z","updated_at":"2025-06-03T19:12:09.000Z","dependencies_parsed_at":"2025-04-18T12:28:05.344Z","dependency_job_id":"c193a5b8-a4da-451f-9047-3df7abdf41b6","html_url":"https://github.com/haroldadmin/fastify-mcp","commit_stats":null,"previous_names":["haroldadmin/fastify-mcp"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/haroldadmin/fastify-mcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffastify-mcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffastify-mcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffastify-mcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffastify-mcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haroldadmin","download_url":"https://codeload.github.com/haroldadmin/fastify-mcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haroldadmin%2Ffastify-mcp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261205703,"owners_count":23124814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","fastify","javascript","model-context-protocol"],"created_at":"2025-03-11T14:54:47.196Z","updated_at":"2025-10-26T00:06:41.065Z","avatar_url":"https://github.com/haroldadmin.png","language":"TypeScript","funding_links":[],"categories":["📚 Projects (1974 total)","🤖 AI/ML"],"sub_categories":["MCP Servers"],"readme":"# fastify-mcp\n\nIntegrate [Model Context Protocol](https://modelcontextprotocol.io/) servers with your [Fastify](https://www.fastify.dev) app.\n\nSupports the [Streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) as well as the legacy [HTTP+SSE transport](https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse).\n\n## Usage\n\nFirst, define your MCP server.\n\n```ts\nfunction createServer() {\n  const mcpServer = new McpServer({\n    name: \"...\",\n    version: \"...\",\n  });\n\n  mcpServer.tool(\"...\");\n  mcpServer.resource(\"...\");\n\n  return mcpServer.server;\n}\n```\n\nCreate a Fastify app and register the plugin.\n\n```ts\nimport { fastify } from \"fastify\";\nimport { streamableHttp } from \"fastify-mcp\";\nimport { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\n\nconst app = fastify();\n\napp.register(streamableHttp, {\n  // Set to `true` if you want a stateful server\n  stateful: false,\n  mcpEndpoint: \"/mcp\",\n  sessions: new Sessions\u003cStreamableHTTPServerTransport\u003e()\n  createServer,\n});\n\napp.listen({ port: 8080 });\n```\n\nSee the [examples](./examples) directory for more detailed examples.\n\n## Installation\n\n```bash\n# npm\nnpm install fastify-mcp\n\n# yarn\nyarn add fastify-mcp\n```\n\n## Session Management\n\nThe official [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) does not support managing multiple sessions out of the box, and therefore it's the host server's responsibility to do so.\n\nThis package uses an in-memory mapping of each active session against its session ID to manage multiple sessions, as recommended by the MCP SDK examples.\n\n### Session Events\n\nThe `Sessions` class emits the following events:\n\n- `connected`: Emitted when a new session is added.\n- `terminated`: Emitted when a session is removed.\n- `error`: Emitted when an asynchronous event handler throws an error.\n\n```ts\nconst sessions = new Sessions\u003cStreamableHTTPServerTransport\u003e();\n\nsessions.on(\"connected\", (sessionId) =\u003e {\n  console.log(`Session ${sessionId} connected`);\n});\n\nsessions.on(\"terminated\", (sessionId) =\u003e {\n  console.log(`Session ${sessionId} terminated`);\n});\n```\n\n## Contributing\n\nPlease file an issue if you encounter a problem when using this package. Pull requests for new features or bug fixes are also welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldadmin%2Ffastify-mcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharoldadmin%2Ffastify-mcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharoldadmin%2Ffastify-mcp/lists"}