Track MCP LogoTrack MCP
Track MCP LogoTrack MCP

The world's largest repository of Model Context Protocol servers. Discover, explore, and submit MCP tools.

Product

  • Categories
  • Top MCP
  • New & Updated
  • Submit MCP

Company

  • About

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy

© 2026 TrackMCP. All rights reserved.

Built with ❤️ by Krishna Goyal

    Fastify Mcp

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

    21 stars
    TypeScript
    Updated Oct 27, 2025
    ai
    fastify
    javascript
    model-context-protocol

    Table of Contents

    • Usage
    • Installation
    • Session Management
    • Session Events
    • Contributing

    Table of Contents

    • Usage
    • Installation
    • Session Management
    • Session Events
    • Contributing

    Documentation

    fastify-mcp

    Integrate Model Context Protocol servers with your Fastify app.

    Supports the Streamable HTTP transport as well as the legacy HTTP+SSE transport.

    Usage

    First, define your MCP server.

    ts
    function createServer() {
      const mcpServer = new McpServer({
        name: "...",
        version: "...",
      });
    
      mcpServer.tool("...");
      mcpServer.resource("...");
    
      return mcpServer.server;
    }

    Create a Fastify app and register the plugin.

    ts
    import { fastify } from "fastify";
    import { streamableHttp } from "fastify-mcp";
    import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
    
    const app = fastify();
    
    app.register(streamableHttp, {
      // Set to `true` if you want a stateful server
      stateful: false,
      mcpEndpoint: "/mcp",
      sessions: new Sessions()
      createServer,
    });
    
    app.listen({ port: 8080 });

    See the examples directory for more detailed examples.

    Installation

    bash
    # npm
    npm install fastify-mcp
    
    # yarn
    yarn add fastify-mcp

    Session Management

    The official MCP TypeScript SDK does not support managing multiple sessions out of the box, and therefore it's the host server's responsibility to do so.

    This package uses an in-memory mapping of each active session against its session ID to manage multiple sessions, as recommended by the MCP SDK examples.

    Session Events

    The Sessions class emits the following events:

    • connected: Emitted when a new session is added.
    • terminated: Emitted when a session is removed.
    • error: Emitted when an asynchronous event handler throws an error.
    ts
    const sessions = new Sessions();
    
    sessions.on("connected", (sessionId) => {
      console.log(`Session ${sessionId} connected`);
    });
    
    sessions.on("terminated", (sessionId) => {
      console.log(`Session ${sessionId} terminated`);
    });

    Contributing

    Please file an issue if you encounter a problem when using this package. Pull requests for new features or bug fixes are also welcome.

    Similar MCP

    Based on tags & features

    • MC

      Mcp Ipfs

      TypeScript·
      11
    • AN

      Anilist Mcp

      TypeScript·
      57
    • ME

      Metmuseum Mcp

      TypeScript·
      14
    • LI

      Liveblocks Mcp Server

      TypeScript·
      11

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k
    View All MCP Servers

    Similar MCP

    Based on tags & features

    • MC

      Mcp Ipfs

      TypeScript·
      11
    • AN

      Anilist Mcp

      TypeScript·
      57
    • ME

      Metmuseum Mcp

      TypeScript·
      14
    • LI

      Liveblocks Mcp Server

      TypeScript·
      11

    Trending MCP

    Most active this week

    • PL

      Playwright Mcp

      TypeScript·
      22.1k
    • SE

      Serena

      Python·
      14.5k
    • MC

      Mcp Playwright

      TypeScript·
      4.9k
    • MC

      Mcp Server Cloudflare

      TypeScript·
      3.0k