Skip to content

Fastify Starter

A Fastify MCP server using xmcp's adapter

Categories
Framework
Fastify
Adapter
HTTP
Share
Post on X

A Fastify server with xmcp mounted through the Fastify adapter.

Features

  • Fastify application with MCP mounted at /mcp
  • File-based tool discovery from src/tools/
  • Adapter build via experimental.adapter: "fastify"
  • Type-safe tools with Zod schemas and InferSchema

Getting Started

1. Create the project

Shell

2. Install & run

Shell

Requires Node.js 22.12 or newer. pnpm install also installs @xmcp-dev/compiler, the dev dependency that runs xmcp dev and xmcp build.

The Fastify server starts at http://localhost:3000, and the MCP endpoint is available at /mcp.

Project Structure

Text

MCP Endpoint

The MCP server is mounted through the generated adapter. xmcp build writes it to .xmcp/adapter, and the relative import keeps the compiled dist/index.js runnable with plain Node:

TypeScript

Adding Tools

Create a new .ts file in src/tools/. The tool is automatically discovered:

TypeScript

Build

Shell

Learn More

Other templates

One framework to rule them all