This guide will walk you through creating a simple MCP server with FastMCP. You’ll learn how to define tools, run your server, and test it with the CLI.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/punkpeye/fastmcp/llms.txt
Use this file to discover all available pages before exploring further.
Build your first server
Import FastMCP and define your server
Import FastMCP and create a new server instance:The server configuration accepts:
server.ts
name- Your server’s name (shown to clients)version- Semantic version number- Optional settings for authentication, logging, health checks, and more
Add a tool
Tools are executable functions that clients and LLMs can call. Let’s add a simple addition tool:What’s happening here:
server.ts
name- Unique identifier for the tooldescription- Tells LLMs when to use this toolparameters- Zod schema defining expected inputs (FastMCP also supports ArkType and Valibot)execute- Async function that performs the action and returns a string result
Complete example
Here’s the complete server code:server.ts
Test your server
Run your server with the interactive CLI:add, and enter parameters:
Use MCP Inspector
For a visual debugging experience, use the MCP Inspector:- Browse available tools, resources, and prompts
- Test tool execution with a visual interface
- Inspect request/response payloads
- Debug errors in real-time
Add more features
Add a resource
Resources make data available to clients:Add a prompt
Prompts define reusable templates for LLM interactions:Add streaming output
For long-running operations, stream partial results:Use different schema libraries
FastMCP supports multiple schema validation libraries:Deploy to production
For production deployments, use HTTP streaming:http://localhost:8080/mcp.
FastMCP also supports edge runtimes like Cloudflare Workers. See the deployment guide for details.
Next steps
Tools
Learn about tool parameters, error handling, and progress reporting
Resources
Discover how to expose files, images, and dynamic data
Prompts
Create reusable prompt templates with auto-completion
Authentication
Secure your server with OAuth 2.1 or custom authentication