What it does
A Fastify plugin that brings Model Context Protocol (MCP) server functionality into Fastify applications. It supports both modern Streamable HTTP and legacy HTTP with Server-Sent Events (SSE) transports, and handles session management for multiple concurrent MCP connections. You define your tools and resources using the MCP SDK, then register the plugin to expose them over HTTP.
Who it's for
Backend engineers building Fastify microservices that need to expose MCP-compatible tools and resources to AI clients like Claude, or who are integrating MCP into broader API gateways and service meshes.
Common use cases
- Expose custom tools and resources to Claude or other MCP clients over HTTP
- Build a multi-tenant MCP server with per-connection session isolation
- Integrate MCP into an existing Fastify microservice without major refactoring
- Run stateless MCP servers behind load balancers using the Streamable HTTP transport
- Migrate from legacy HTTP+SSE to modern Streamable HTTP transport incrementally
Setup pitfalls
- Session management is manual—the plugin provides the
Sessionscontainer, but you must decide how to persist and retrieve session state (in-memory only by default, or integrate Redis/database as needed) - Transport selection is not negotiated—clients and server must agree on HTTP+SSE or Streamable HTTP upfront; mismatches cause silent connection failures
- No built-in authentication or authorization—securing the
/mcpendpoint (or your chosen path) is your responsibility - Project has no CI configured—review the README examples carefully before deploying to ensure your use case is covered