Get the FREE Ultimate OpenClaw Setup Guide →

fastmcp

A TypeScript framework for building MCP servers.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio punkpeye-fastmcp npx -y fastmcp \
  --env MCP_DEBUG="Enable debug logging (optional)"

How to use

FastMCP is a TypeScript framework for building MCP servers. It provides a structured way to define tools, resources, prompts, and routes, with built-in support for authentication, context headers, session tracking, media content, streaming, and various transport options. The framework aims to reduce boilerplate and provide intuitive APIs for common MCP tasks like defining prompts, resources, and server behavior, while still letting you customize error handling, HTTP routes, and streaming behavior. With FastMCP you can build an MCP server that supports HTTP streaming (and SSE), HTTPS, custom routes for REST APIs or admin interfaces, and edge-runtime compatible deployments.

To use it, install the package, create and configure a FastMCP instance, and start the server with a chosen transport (for example stdio for local testing or HTTP streaming for remote clients). The README includes examples of adding tools, starting the server with different transport types, and testing via the MCP CLI or inspector tooling. You can also run HTTP streaming and SSE transports, or configure HTTPS by supplying SSL certificate options. The included showcase demonstrates how to add a simple calculation tool and run the server, while the library handles the MCP protocol specifics for you.

In practice, you typically create a server instance, register tools (each with parameters and an execute function), and then start the server with a transport type such as stdio, HTTP streaming, or a custom transport. For remote clients, you can connect via HTTP streaming or SSE transports, and for secure deployments you can enable HTTPS by providing certificates. The framework also supports prompts, resource embedding, progress notifications, and typed server events, making it straightforward to deliver rich MCP experiences.

How to install

Prerequisites:

  • Node.js (14.x or newer) and npm/yarn/pnpm
  • Basic familiarity with TypeScript/JavaScript project setup

Installation steps:

  1. Create a new project folder and initialize a Node.js project (skip if adding to an existing project):
mkdir my-fastmcp-server
cd my-fastmcp-server
npm init -y
  1. Install FastMCP from npm:
npm install fastmcp
  1. Create a basic server file (e.g., src/server.ts) to initialize FastMCP and start with a sample transport:
import { FastMCP } from "fastmcp";

const server = new FastMCP({
  name: "My Server",
  version: "1.0.0",
});

// Example: add a simple tool (optional)
// server.addTool({ name: "echo", description: "Echo input", parameters: z.object({ text: z.string() }), execute: async (args) => args.text });

server.start({ transportType: "stdio" });
  1. Run the server (adjust to your build setup if using TypeScript compilation):
# If using plain ts-node or a build step, run accordingly. Example with ts-node:
npx ts-node src/server.ts
  1. Optional: build and test with the MCP CLI as shown in the README:
git clone https://github.com/punkpeye/fastmcp.git
cd fastmcp
npm install
npm run build

# Test the addition server example:
npx fastmcp dev src/examples/addition.ts
npx fastmcp inspect src/examples/addition.ts

Additional notes

Tips and common considerations:

  • The default transport for local testing is stdio. For remote usage, consider httpStream or SSE transports and configure ports and endpoints accordingly.
  • HTTPS support requires SSL certificates; you can provide sslCert, sslKey, and optional sslCa when starting the HTTP streaming server.
  • If you plan to run on Cloudflare Workers, Deno Deploy, or other edge runtimes, ensure compatibility with the Edge Runtime support notes in the README.
  • Environment variables can be used to toggle debug modes or pass sensitive configuration at runtime; keep secrets out of source control and consider using a secret manager in production.
  • The framework emphasizes reducing boilerplate. Leverage built-in error handling, typed server events, and resource embedding to build feature-rich MCP servers quickly.

Related MCP Servers

Sponsor this space

Reach thousands of developers