FastMCP is a lightweight framework that helps you build MCP (Model Context Protocol) servers easily. MCP allows AI models (like ChatGPT, Claude, etc.
Overview
FastMCP is a lightweight framework that helps you build MCP (Model Context Protocol) servers easily. MCP allows AI models (like ChatGPT, Claude, etc.) to communicate with external tools such as: Databases APIs File systems Custom scripts FastMCP makes writing these servers simple and fast. 📦 1. Installation Make sure you have Python 3.10+. pip install fastmcp 📁 2. Project Structure (Beginner-Friendly) Create a folder: my-mcp-server/ │── server.py │── requirements.txt Add this to requirements.txt: fastmcp 🧠 3. Writing Your First MCP Server Create a file server.py: from fastmcp import FastMCP @app.tool() def say_hello(name: str) -> str: """ Returns a greeting message. """ return f"Hello, {name}! Welcome to MCP!" if == "": app.run() ✔️ What this server does Creates an MCP server named my_first_mcp_server Registers a tool called say_hello When an AI calls this tool, it will respond with a greeting 🧪 4. Running the MCP Server Run: python server.
README
FastMCP is a lightweight framework that helps you build MCP (Model Context Protocol) servers easily. MCP allows AI models (like ChatGPT, Claude, etc.) to communicate with external tools such as: Databases APIs File systems Custom scripts FastMCP makes writing these servers simple and fast. 📦 1. Installation Make sure you have Python 3.10+. pip install fastmcp 📁 2. Project Structure (Beginner-Friendly) Create a folder: my-mcp-server/ │── server.py │── requirements.txt Add this to requirements.txt: fastmcp 🧠 3. Writing Your First MCP Server Create a file server.py: from fastmcp import FastMCP
app = FastMCP(“my_first_mcp_server”)
A simple tool
@app.tool() def say_hello(name: str) -> str: “”" Returns a greeting message. “”" return f"Hello, {name}! Welcome to MCP!"
if name == “main”: app.run() ✔️ What this server does Creates an MCP server named my_first_mcp_server Registers a tool called say_hello When an AI calls this tool, it will respond with a greeting 🧪 4. Running the MCP Server Run: python server.py You will see: MCP server started on port 5000 🤝 5. Connecting MCP Server With AI (ChatGPT / Anthropic) 👉 For ChatGPT (OpenAI) Go to: Settings → Developer → MCP Servers → Add New Add: Command: python Arguments: server.py 👉 For Claude (Anthropic) In Claude Desktop → Settings → MCP → Add Server → point to your script. 🧩 6. Adding More Tools Example: A tool that adds two numbers @app.tool() def add(a: int, b: int) -> int: “”“Adds two numbers.”“” return a + b Example: A tool that fetches data from an API import requests
@app.tool() def get_joke() -> str: “”“Returns a random joke.”“” res = requests.get(“https://official-joke-api.appspot.com/random_joke”).json() return f"{res[‘setup’]} — {res[‘punchline’]}"
Install
This server does not publish a one-line install command.
Open the repository installation guide New to MCP? Start with the mcpskill.org guide →