← Back to directory
F

Fastify MCP Server

Community
Framework / SDK
Fastify plugin for building MCP servers with SSE, stdio, OAuth 2.1, and Redis-backed scaling.

This is a framework for building MCP servers or agents, not a server you connect a client to.

Category
Dev Tools #74 of 438
Stars
★ 58 Popular
Transport
stdio (local process) · SSE · Streamable HTTP
Runtime
Node.js
Credentials
No credential needed
License
Apache-2.0
Last commit
63FMRS · C

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.

Strongest · Documentation 17/20 Weakest · Reliability 9/20

Reliability
9/20
Security and permissions
14/20
Maintenance
10/20
Documentation
17/20
Setup experience
13/20
Why each score
Reliability 9/20
The README describes protocol version negotiation (2025-11-25 down to 2024-11-05), the initialize handshake, tool/resource/prompt registration, and TypeBox/AJV validation in a self-consistent way with many code samples, and claims 'comprehensive test coverage,' but this review had no server manifest (not cached) and no actual CI workflow or test files to verify against. Per the static calibration rule, reliability cannot exceed 12 without verifiable execution evidence; given the complete inability to confirm declared tool behavior matches implementation or that error handling is real, the score is further reduced to 9.
Security and permissions 14/20
Security design is broad: Origin validation against DNS rebinding, OAuth 2.1 + PKCE + JWT/introspection, a bearer-auth recommendation, a fine-grained canAccessTool authorization hook, input sanitization with depth/length limits, URL-mode elicitation that keeps sensitive data (passwords, API keys, payment info) out of form mode, and tasks bound to the token subject when authorization is enabled (with tasks/list refused in anonymous mode to prevent ID enumeration). No red-line issues were found (no malware, no irreversible destructive default actions). However, all of this is self-reported in README/docs with no source or tests confirming correct implementation, and rate limiting is described as something 'should be implemented' by the deployer rather than enforced by default, so it falls short of full marks.
Maintenance 10/20
The repo carries an Apache-2.0 license and is not archived, meeting basic compliance. But the only available metadata is 58 stars and 23 open issues — no commit history, release cadence, changelog, or security-response channel was provided to verify sustained or responsive maintenance. Following the rule that missing evidence is a deduction, only a middling score is warranted.
Documentation 17/20
Documentation quality is high: it covers installation, quick start, a protocol version negotiation table, SSE/Redis horizontal scaling, stdio transport, the full OAuth 2.1 flow, TypeBox vs AJV validation differences, the per-tool access hook, route schema customization, security considerations, and test examples, with clear layering and abundant examples, plus explicit callouts of edge cases (e.g., requests without an Origin header are always accepted; plain JSON Schema tools are unvalidated by default unless AJV is opted in). A modest deduction applies because several behaviors (e.g., rate limiting, many security claims) remain self-asserted, there's no independent troubleshooting/known-limitations section, and manifest data is unavailable.
Setup experience 13/20
Setup steps are clear: npm install plus an optional TypeBox dependency, a minimal Fastify plugin registration example, and working minimal code for both stdio and HTTP transports. Per the static calibration rule, without CI or test evidence to confirm these examples actually run, setup is capped at 15; the plugin also involves several optional prerequisites (Redis for horizontal scaling, an OAuth authorization server, the bearer-auth plugin) that add real-world setup complexity, bringing the score down to 13.

Static review · not runListed 2026-08-26

Read the FMRS scoring method →

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

Setup

Before you start

Runtime:Node.js

OAUTH_CLIENT_SECRET optionalsecret OAuth 2.1 client secret obtained from the authorization server; sensitive.
REDIS_PASSWORD optionalsecret Redis authentication password; sensitive.
MCP_BEARER_TOKEN optionalsecret Bearer token used with @fastify/bearer-auth; sensitive.
Other optional settings (6)
OAUTH_CLIENT_ID optional OAuth 2.1 client ID from your authorization server; only used when authorization is enabled.
REDIS_HOST optional Redis hostname for horizontally scaled session sharing; defaults to localhost.
REDIS_PORT optional Redis port; defaults to 6379.
REDIS_DB optional Redis database number; defaults to 0.
DEBUG optional Set to true to enable stderr debug logging in stdio mode.
PORT optional HTTP listen port, e.g. 3000 in the examples.

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.

Check that it works

Start the Fastify app and send an initialize request to /mcp, or run node server.js in stdio mode and pipe an initialize JSON-RPC message; success is confirmed when the protocol version is negotiated and tools/list returns your registered tools.

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

Things to try

Once connected, you can ask your AI assistant things like:

  • List all tools registered on this server
  • Use the calculator tool to compute 12 times 8
  • Read the file://config. resource
  • Call the echo tool with 'Hello, stdio!'

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

Overview

@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).

Similar servers

Context7 80 · B

Upstash's official server providing up-to-date third-party library docs for AI coding assistants

★ 63.3k · Tools 2 Compare with this →

Source revision 8525bb43b3b5 Data synced 2026-10-19 Read the FMRS scoring method