Fastify MCP Plugin

v3.0.0Developer Toolsstable

A Fastify plugin to run Model Context Protocol (MCP) servers

aifastifyjavascriptmodel-context-protocolmodelcontextprotocol
Share:
27
Stars
0
Downloads
0
Weekly
0/5

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

Run MCP servers
Fastify integration
Real-time protocol
haroldadmin

Maintainer

LicenseApache-2.0
Languagetypescript
Versionv3.0.0
UpdatedMay 12, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

NPM

npx -y fastify-mcp

Manual Installation

npx -y fastify-mcp

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

Install fastify-mcp

Add the fastify-mcp plugin to your Fastify project using npm or yarn.

npm install fastify-mcp
# or
yarn add fastify-mcp
2

Install 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/sdk
3

Register 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 });
4

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' }) }],
}));
5

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.

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.

Quick Config Preview

{ "mcpServers": { "fastify": { "command": "npx", "args": ["-y", "fastify-mcp"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides