Skip to main content

Prerequisites

Before installing FastMCP, ensure you have:
  • Node.js - Version 18 or higher recommended
  • Package manager - npm, yarn, or pnpm

Install FastMCP

Install the fastmcp package using your preferred package manager:
npm install fastmcp
This will install FastMCP along with its core dependencies:
  • @modelcontextprotocol/sdk - The official MCP SDK
  • zod - For schema validation (you can also use ArkType or Valibot)
  • Additional runtime dependencies for HTTP streaming and session management

Optional dependencies

Depending on your use case, you may want to install additional packages:

For OAuth/JWT authentication

If you plan to use OAuth authentication with JWT token verification:
npm install jose

For Valibot schema validation

If you prefer Valibot over Zod for schema validation:
npm install valibot @valibot/to-json-schema

For ArkType schema validation

If you prefer ArkType over Zod for schema validation:
npm install arktype

Verify installation

Create a simple test file to verify FastMCP is installed correctly:
test.ts
import { FastMCP } from "fastmcp";

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

console.log("FastMCP installed successfully!");
Run the file:
npx tsx test.ts
If you see “FastMCP installed successfully!”, you’re ready to build your first MCP server.

Using the CLI

FastMCP includes a CLI for testing and debugging servers:
# Test your server with interactive CLI
npx fastmcp dev src/server.ts

# Inspect your server with MCP Inspector (web UI)
npx fastmcp inspect src/server.ts
The CLI supports various options:
  • --transport - Choose transport type (stdio, http-stream)
  • --port - Set HTTP port (default: 8080)
  • --stateless - Enable stateless mode for serverless deployments

Project setup

For a complete boilerplate with TypeScript configuration and best practices:
git clone https://github.com/punkpeye/fastmcp-boilerplate.git my-mcp-server
cd my-mcp-server
npm install

Next steps

Quickstart

Create your first MCP server

Core concepts

Learn about tools, resources, and prompts

Build docs developers (and LLMs) love