FastMCP logo

FastMCP

by jlowin

FastMCP is a Python library that simplifies building Model Context Protocol (MCP) servers and clients. It provides a high-level, Pythonic interface for creating tools, exposing resources, defining prompts, and connecting components for LLM applications.

View on GitHub

Last updated: N/A

What is FastMCP?

FastMCP is a Python library designed to facilitate the creation of MCP (Model Context Protocol) servers and clients. It abstracts away the complexities of the MCP protocol, allowing developers to focus on building tools and applications that interact with LLMs in a standardized and secure manner.

How to use FastMCP?

To use FastMCP, you install the library using uv pip install fastmcp. You then define your server using the FastMCP class and decorate your functions with @mcp.tool(), @mcp.resource(), and @mcp.prompt() to expose functionality to LLMs. You can run the server using the fastmcp run command or integrate it into Claude Desktop using fastmcp install.

Key features of FastMCP

  • Simplified server creation with decorators

  • Client library for interacting with MCP servers

  • Support for tools, resources, and prompts

  • Advanced features like proxy servers and server composition

  • Automatic generation of servers from OpenAPI specs or FastAPI objects

Use cases of FastMCP

  • Exposing data and functionality to LLM applications

  • Building custom tools for LLMs

  • Creating reusable interaction patterns for LLMs

  • Integrating existing web APIs with LLMs

FAQ from FastMCP

What is MCP?

The Model Context Protocol (MCP) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way.

Why use FastMCP?

FastMCP handles the complex protocol details and server management, so you can focus on building great tools. It's designed to be high-level and Pythonic.

How do I install FastMCP?

We strongly recommend installing FastMCP with uv: uv pip install fastmcp

How do I define a tool?

Decorate a Python function with @mcp.tool(). FastMCP automatically generates the necessary MCP schema based on type hints and docstrings.

How do I define a resource?

Decorate a Python function with @mcp.resource("your://uri"). Use curly braces {} in the URI to define dynamic resources.