Fastify MCP Plugin
A Fastify plugin to run Model Context Protocol (MCP) servers
What is Fastify MCP Plugin?
Fastify MCP Plugin is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to fastify plugin to run model context protocol (mcp) servers
A Fastify plugin to run Model Context Protocol (MCP) servers
This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- A Fastify plugin to run Model Context Protocol (MCP) servers
Use Cases
Maintainer
Works with
Installation
NPM
npx -y fastify-mcpManual Installation
npx -y fastify-mcpConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Fastify MCP Plugin
fastify-mcp is a Fastify plugin that lets you embed a Model Context Protocol (MCP) server directly inside any Fastify web application. It handles both the current Streamable HTTP transport and the legacy HTTP+SSE transport for backward compatibility, manages stateful and stateless session modes, and exposes your MCP tools and resources on a configurable route path. Developers use it to add MCP capabilities to existing Fastify services without standing up a separate MCP process.
Prerequisites
- Node.js 18 or later installed
- An existing Fastify project (or willingness to create one)
- npm or yarn for package management
- The @modelcontextprotocol/sdk package for creating MCP server instances
- An MCP client such as Claude Desktop for testing
Install fastify-mcp
Add the fastify-mcp plugin to your Fastify project using npm or yarn.
npm install fastify-mcp
# or
yarn add fastify-mcpInstall the MCP SDK
Install the official MCP TypeScript SDK which provides the McpServer class you'll use to define tools and resources.
npm install @modelcontextprotocol/sdkRegister the plugin in your Fastify app
Import fastify-mcp and register it with your Fastify instance. Provide a createServer function that instantiates and configures your MCP server with tools and resources.
import Fastify from 'fastify';
import { fastifyMcp, Sessions } from 'fastify-mcp';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
const app = Fastify();
await app.register(fastifyMcp, {
stateful: true,
mcpEndpoint: '/mcp',
sessions: new Sessions(),
createServer: async () => {
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
server.tool('greet', { name: 'string' }, async ({ name }) => ({
content: [{ type: 'text', text: `Hello, ${name}!` }],
}));
return server;
},
});
await app.listen({ port: 8080 });Define tools and resources
Use the McpServer API to register tools (callable functions) and resources (data the model can read) inside your createServer callback.
// Tools: callable functions
server.tool('get_weather', { city: 'string' }, async ({ city }) => ({
content: [{ type: 'text', text: `Weather for ${city}: Sunny, 22°C` }],
}));
// Resources: readable data
server.resource('config://app', async () => ({
contents: [{ uri: 'config://app', text: JSON.stringify({ version: '1.0' }) }],
}));Configure your MCP client
For Claude Desktop or other MCP clients that support HTTP transport, point the client at the /mcp endpoint of your running Fastify server.
{
"mcpServers": {
"my-fastify-server": {
"url": "http://localhost:8080/mcp"
}
}
}Fastify MCP Plugin Examples
Client configuration
Claude Desktop configuration connecting to a fastify-mcp server running on port 8080 via the Streamable HTTP transport.
{
"mcpServers": {
"my-fastify-mcp": {
"url": "http://localhost:8080/mcp"
}
}
}Prompts to try
After defining your own tools, use prompts like these to invoke them through Claude. Replace the tool names with whatever you registered in your server.
- "Call the greet tool with my name"
- "Use the get_weather tool to check the weather in Tokyo"
- "Read the app config resource and summarize the settings"
- "List all available tools on this MCP server"Troubleshooting Fastify MCP Plugin
MCP client cannot connect to the Fastify server
Ensure the Fastify server is listening on the expected port (default 8080) and the mcpEndpoint path matches what is configured in the client (e.g., /mcp). Check for CORS issues if the client and server run on different origins.
Session-related errors with stateful mode
Make sure you pass a `new Sessions()` instance in the plugin options when using stateful mode. Each client connection gets its own session; if you omit the sessions option, connections may not be tracked correctly.
Legacy MCP client not connecting (SSE transport)
fastify-mcp supports the legacy HTTP+SSE transport automatically. Ensure your client is configured to connect to the correct endpoint path. Some older clients require the SSE URL to be explicitly set rather than the Streamable HTTP URL.
Frequently Asked Questions about Fastify MCP Plugin
What is Fastify MCP Plugin?
Fastify MCP Plugin is a Model Context Protocol (MCP) server that fastify plugin to run model context protocol (mcp) servers It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Fastify MCP Plugin?
Install via npm with the command: npx -y fastify-mcp. Then add the server configuration to your AI client's JSON config file (e.g., claude_desktop_config.json or .cursor/mcp.json).
Which AI clients work with Fastify MCP Plugin?
Fastify MCP Plugin works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Fastify MCP Plugin free to use?
Yes, Fastify MCP Plugin is open source and available under the Apache-2.0 license. You can use it freely in both personal and commercial projects.
Fastify MCP Plugin Alternatives — Similar Developer Tools Servers
Looking for alternatives to Fastify MCP Plugin? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Fastify MCP Plugin in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Fastify MCP Plugin?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.