fastmcp

πŸš€ The fast, Pythonic way to build MCP servers and clients

GitHub Stars

17,372

User Rating

Not Rated

Favorites

0

Views

7

Forks

1,195

Issues

168

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Python 3.7 or higher
pip latest version

Installation

Installation

Prerequisites

Please specify required software and versions:
Python: 3.7 or higher
pip: Latest version

Installation Steps

1. Clone Repository

bash
git clone https://github.com/jlowin/fastmcp.git
cd fastmcp

2. Install Dependencies

bash
pip install -r requirements.txt

3. Start Server

bash
fastmcp run server.py

Troubleshooting

Common Issues

Issue: Server won't start Solution: Check Python version and reinstall dependencies. Issue: Client cannot connect to the server Solution: Verify the server URL and port.

Configuration

Configuration

Basic Configuration

Server Setup

Server configuration is done within the server.py file. Here’s a basic setup example:
python
from fastmcp import FastMCP

mcp = FastMCP("Demo πŸš€")

@mcp.tool
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

if __name__ == "__main__":
    mcp.run()

Environment Variables

Set the following environment variables as needed:
bash
export API_KEY="your-api-key"
export DEBUG="true"

Advanced Configuration

Security Settings

Store API keys in environment variables or secure configuration files
Set appropriate file access permissions
Adjust logging levels

Examples

Examples

Basic Usage

Here are basic usage examples for the MCP server:

Running the Server

bash
fastmcp run server.py

Programmatic Usage

python

Python example

import requests def call_mcp_tool(tool_name, params): response = requests.post( 'http://localhost:3000/mcp/call', json={ 'tool': tool_name, 'parameters': params } ) return response.json()

Usage example

result = call_mcp_tool('add', {'a': 5, 'b': 3}) print(result) # 8

Use Cases

Using an MCP server to facilitate data sharing between different AI models.
Creating tools that integrate with external services via REST APIs.
Developing automation scripts for regular data processing tasks.
Invoking MCP tools from client applications to analyze data in real-time.
Author Information
Jeremiah Lowin

CEO at @PrefectHQ. Mostly harmless.

@PrefectHQ Washington, DC

949

Followers

41

Repositories

9

Gists

0

Total Contributions

Related MCPs
agent-builder logo

An example agent demonstrating streaming, tool use, and interactivity from your terminal. This agent builder can help you to build your own agents and tools.

Python
samples logo

Agent samples built using the Strands Agents SDK.

Python
hica logo

hica is a high-performance editor tailored for Python, offering features like code auto-completion and debugging tools. Users can program efficiently through an intuitive interface. With a wide range of plugins, it also boasts high customization, making it suitable for various development environments.

Python