FastMCP
by punkpeye
FastMCP is a TypeScript framework for building MCP servers capable of handling client sessions. It simplifies the creation of servers that expose tools, resources, and prompts for use with LLMs and other applications.
Last updated: N/A
What is FastMCP?
FastMCP is a TypeScript framework designed to facilitate the creation of Model Context Protocol (MCP) servers. These servers can manage client sessions and provide access to tools, resources, and prompts, enabling interaction with Large Language Models (LLMs) and other applications.
How to use FastMCP?
To use FastMCP, install the package via npm (npm install fastmcp
). Define tools, resources, and prompts using the provided API. Start the server using server.start()
with options for stdio or SSE transport. Test and debug using fastmcp dev
or fastmcp inspect
command-line tools.
Key features of FastMCP
Simple Tool, Resource, Prompt definition
Authentication
Sessions
Image content support
Logging
Error handling
SSE support
CORS enabled by default
Progress notifications
Typed server events
Prompt argument auto-completion
Sampling
Automated SSE pings
Roots
CLI for testing and debugging
Use cases of FastMCP
Creating servers that expose custom tools for LLMs
Building applications that require real-time updates via SSE
Developing interactive command-line tools
Managing and serving resources like files and images
Implementing authentication and session management for clients
FAQ from FastMCP
How do I define a tool in FastMCP?
How do I define a tool in FastMCP?
Use the server.addTool()
method, providing a name, description, parameters (using Standard Schema), and an execute
function.
How can I return an image from a tool?
How can I return an image from a tool?
Use the imageContent
function to create a content object with the image data, URL, or path.
How do I handle errors in my tools?
How do I handle errors in my tools?
Throw UserError
instances for errors that should be shown to the user.
How do I test my FastMCP server?
How do I test my FastMCP server?
Use the fastmcp dev
command to run the server with mcp-cli
for terminal-based testing or fastmcp inspect
to use the MCP Inspector Web UI.
How do I use FastMCP with Claude Desktop?
How do I use FastMCP with Claude Desktop?
Configure Claude Desktop to run your FastMCP server using the command
and args
settings, as described in the provided guide.