Integrations
Enables generation of media content using Flux's AI image generation capabilities
Provides tools for generating Git commit messages based on code changes
Built as a TypeScript framework for constructing MCP servers with client session management
FastMCP
FastMCP is a TypeScript framework for building MCP servers with client session management.
[!NOTE]
For a Python implementation, see FastMCP Python .
Key Features
FastMCP offers the following features:
- Simple tools, resources and prompt definitions
- Authentication function
- Session Management
- Image content support
- Logging
- Error Handling
- Server-Sent Events (SSE)
- CORS (enabled by default)
- Progress Notifications
- Typed Server Events
- Prompt Argument Auto-Completion
- Sampling Request
- Automatic SSE ping
- Route Management
- CLI for testing and debugging
How to install
Quickstart
[!NOTE]
There are many real-world use cases for FastMCP. Check out our case studies .
Now you have a working MCP server!
You can test it in the terminal with:
SSE
Server-Sent Events (SSE) is a mechanism by which a server can send real-time updates to a client over an HTTPS connection. In the context of MCP, SSE is primarily used to enable remote MCP communication, allowing an MCP hosted on a remote machine to be accessed and updates relayed over the network.
You can also run the server with SSE support:
This will start a server, listening for SSE connections at http://localhost:8080/sse
.
Then you can connect to the server using SSEClientTransport
:
Basic Concepts
tool
In MCP tools , servers expose executable functions that clients and LLMs can call to perform actions.
FastMCP uses the Standard Schema specification for defining tool parameters, which allows you to use your favorite schema validation library that implements the specification, such as Zod, ArkType, or Valibot.
Zod example:
ArkType example:
Example of Valibot:
Valibot requires a peer dependency: @valibot/to-json-schema.
Returning a String
execute
can return a string:
This is equivalent to:
Returning a List
If you want to return a list of messages, you can return an object with content
property:
Returning the images
To create an image content object, use imageContent
:
The imageContent
function accepts the following options:
url
: URL of the imagepath
: Path to the image filebuffer
: Image data as a buffer
Exactly one of url
, path
or buffer
must be specified.
The above example is equivalent to:
Logging
Tools can log messages to the client using the context object's log
:
log
object has the following methods:
debug(message: string, data?: SerializableValue)
error(message: string, data?: SerializableValue)
info(message: string, data?: SerializableValue)
warn(message: string, data?: SerializableValue)
error
Errors that should be displayed to the user should be thrown as UserError
instances:
Progress Notifications
A tool can report its progress by calling reportProgress
on the context object:
resource
Resources represent any kind of data that an MCP server wants to provide to its clients. This includes:
- File Contents
- Screenshots and images
- Log files
- And many more
Each resource is identified by a unique URI and can contain text or binary data.
[!NOTE]
load
can return multiple resources, this can be used for example to return a list of files in a directory when the directory is loaded.Copy
You can also return binary content with load
:
Resource Templates
You can also define resource templates:
Auto-completion of resource template arguments
To enable auto-completion of resource template arguments, we provide a complete
function:
prompt
Prompts allows servers to define reusable prompt templates and workflows that clients can easily present to users and LLMs, providing a powerful way to standardize and share common LLM interactions.
Prompt Argument Auto-Completion
The prompt can provide auto-completion of arguments:
Auto-completion of prompt arguments using enum
If you provide an enum
array for arguments, the server will automatically provide argument completion.
certification
FastMCP allows you to authenticate
clients using a custom function:
You can now access the authenticated session data in your tools:
session
session
object is an instance of FastMCPSession
and describes an active client session.
To allow one-to-one communication between client and server, a new server instance is allocated for each client connection.
Typed Server Events
You can listen to events emitted by the server using the on
method:
FastMCPSession
FastMCPSession
represents a client session and provides methods for interacting with the client.
See the Session example for how to obtain FastMCPSession
instance.
requestSampling
requestSampling
makes a sampling request and returns the response.
clientCapabilities
clientCapabilities
property contains the client capabilities.
loggingLevel
loggingLevel
property describes the logging level set by the client.
roots
roots
property contains the routes set by the client.
server
server
property contains the instance of the MCP server associated with the session.
Typed Session Events
You can listen to events emitted by the session using on
method:
Running the Server
Test with MCP-CLI
The fastest way to test and debug your server is to use fastmcp dev
:
This will run a server for testing and debugging your MCP server in the terminal using mcp-cli
.
Inspect with MCP Inspector
Another option is to inspect your server in the WebUI using the official MCP Inspector
:
FAQ
How to use with Claude Desktop?
Follow the guide https://modelcontextprotocol.io/quickstart/user and add the following configuration:
Case Study
[!NOTE]
If you have developed a server using FastMCP, please submit a PR and introduce it as a case study!
- apinetwork/piapi-mcp-server - Generate media using Midjourney/Flux/Kling/LumaLabs/Udio/Chrip/Trellis
- domdomegg/computer-use-mcp - Control a computer
- LiterallyBlah/Dradis-MCP - Project and vulnerability management with Dradis
- Meeting-Baas/meeting-mcp - Create meeting bots, search meeting minutes, manage recording data
- drumnation/unsplash-smart-mcp-server - Enables an AI agent to seamlessly search, recommend, and distribute professional photos from Unsplash
- ssmanji89/halopsa-workflows-mcp - Integrating HaloPSA workflows with AI assistants
- aiamblichus/mcp-chat-adapter - Provides a clean interface for LLM to use chat completion
Acknowledgements
- FastMCP is inspired by a Python implementation by Jonathan Lowin .
- Parts of the codebase were adopted from LiteMCP .
- Part of the codebase was adopted from our experiment with SSE over the Model Context protocol .
This server cannot be installed
A TypeScript framework for building MCP servers with client session management capabilities, supporting tools definition, authentication, image content, logging, and error handling.