← Back to directory
F

Fastify MCP Server

Community
Fastify plugin for building MCP servers with SSE, stdio, OAuth 2.1, and Redis-backed scaling.
GitHub source repository ↗
★ 58 Stars Category · Dev Tools Popular Source revision f4ed3dbaead2
63FMRS · C
Reliability
9/20
Security and permissions
14/20
Maintenance
10/20
Documentation
17/20
Setup experience
13/20

An open-source Fastify plugin maintained by the Platformatic team for scaffolding MCP-compliant servers, covering protocol negotiation, SSE/stdio transports, Redis-backed horizontal scaling, OAuth 2.1 authorization, and newer spec features like tasks and elicitation — but it is a development framework, not a turnkey tool server, so actual security and functionality depend entirely on the integrator's own implementation.

Read the FMRS scoring method →

@platformatic/mcp is a Fastify plugin that implements a Model Context Protocol (MCP) server over JSON-RPC 2.0. It is not a standalone server with a fixed toolset — it's a framework developers use inside their own Fastify application to register tools, resources, and prompts. It supports protocol version negotiation (latest 2025-11-25, negotiating down to 2025-06-18, 2025-03-26, and 2024-11-05), both HTTP/SSE and stdio transports, Redis-backed session storage and message broadcasting for horizontal scaling across instances, and built-in OAuth 2.1 authorization, TypeBox/AJV schema validation, input sanitization, experimental task-augmented tool calls, and elicitation (form and URL modes).

Tools

The tool list has not been reviewed yet.

Setup

Install via npm: npm install @platformatic/mcp (optionally npm install @sinclair/typebox for typed schema validation). Register the plugin in a Fastify app with await app.register(mcpPlugin, { ... }), then define tools/resources/prompts with app.mcpAddTool / app.mcpAddResource / app.mcpAddPrompt. For stdio transport, call the exported runStdioServer(app, options) instead of app.listen.

Fit and risk

Best for

  • Node.js/Fastify developers who need to build a scalable, authenticated MCP server from scratch
  • Teams deploying multiple server instances behind a load balancer with Redis for shared state
  • Projects that want TypeBox-based compile-time and runtime type safety for tool inputs

Not for

  • End users looking for a ready-made server that already exposes a fixed set of tools (e.g. filesystem or database access)
  • Teams not using Node.js/Fastify
  • Simple single-instance prototypes that don't need scaling, OAuth, or session persistence

Required permissions

  • Runs as a library inside the developer's own Fastify process — actual filesystem/network access depends entirely on the tool handlers the developer implements
  • Requires network access to a Redis instance when horizontal scaling is enabled (session store and message broker)
  • Requires network access to the configured JWKS or token-introspection endpoint when OAuth 2.1 authorization is enabled
  • URL-mode elicitation sends the end user out of band to an external URL to complete sensitive interactions

Risks and side effects

  • The plugin ships with no built-in tools, so its real-world security depends on the handlers developers write on top of it
  • Without authorization enabled, tasks are protected only by their random UUID — anyone holding a task ID can reach it, since no requestor identity exists to bind it to
  • Production-grade rate limiting must be added by the integrator; the plugin only provides basic DoS protections (length, depth, and property-count limits)
  • Multiple SSE connections are intentionally allowed per session and receive broadcast messages, a deliberate deviation from the MCP spec's single-stream delivery rule that can cause duplicate message delivery
  • `transformRouteSchema` only edits OpenAPI documentation metadata — it does not enforce authentication, so real auth hooks must be configured separately

Troubleshooting

  1. HTTP requests return 400: check that the `MCP-Protocol-Version` header matches the session's negotiated revision, or that the requested version is supported
  2. Browser requests rejected with 403: verify the request Origin is included in the `allowedOrigins` allow-list
  3. `tasks/result` returns not found: the task likely expired before completion — raise `taskDefaultTtlMs`/`taskMaxTtlMs` or have the client request a longer `ttl`
  4. Messages not reaching clients across instances: confirm the `redis` option is configured and all instances point to the same Redis deployment
  5. Authorization requests return 401: verify the Bearer token, JWKS/introspection endpoint configuration, and that `authorization.enabled` is set

Use cases

Adding MCP-compliant tool/resource/prompt endpoints to an existing Fastify backend
Running SSE-based MCP servers that need cross-instance notification broadcasting and reconnection with Last-Event-ID
Building multi-user MCP services that require OAuth 2.1, JWT, or token-introspection based authentication
Implementing long-running tool calls via task polling instead of blocking requests

Supported clients

Supported clients have not been confirmed yet.