matthew-sayer/mcp_quick_start_py
If you are the rightful owner of mcp_quick_start_py and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A basic Model Context Protocol (MCP) server skeleton that demonstrates how to organise and structure MCP tools in a logical folder hierarchy.
reverse_string
Reverses the input string
MCP Server Skeleton
A basic Model Context Protocol (MCP) server skeleton that demonstrates how to organise and structure MCP tools in a logical folder hierarchy.
Overview
This project provides a foundational template for building MCP servers with a clean, organised structure. It includes:
- Modular Tool Architecture: Tools are organised in a dedicated
tools/
directory for easy management and discovery - Automatic Tool Registration: The server automatically discovers and loads all tools from the tools directory
- Example Implementation: Includes a simple string reversal tool to demonstrate the MCP tool pattern
Features
- Organised Structure: Clear separation of tools, resources, and configuration
- Auto-Discovery: Automatically registers all Python modules in the
tools/
directory - Example Tool: A basic
reverse_string
tool that reverses any input string - FastMCP Integration: Built using the FastMCP framework for easy development
Project Structure
src/
āāā tools/ # All MCP tools go here
ā āāā tool.py # Example string reversal tool
āāā resources/ # Static resources and data files
āāā main.py # FastAPI server entry point
āāā shared_mcp_object.py # Shared MCP instance and tool registration
āāā config.py # Configuration management
Getting Started
-
Install Dependencies:
uv sync
-
Run the Server:
uv run fastapi dev main.py
-
Connect via MCP: Configure your MCP client to connect to
http://localhost:8000/sse
Adding New Tools
To add a new tool:
- Create a new Python file in the
tools/
directory - Import the shared MCP object:
from shared_mcp_object import mcp
- Use the
@mcp.tool()
decorator to register your function - The tool will be automatically discovered and registered when the server starts
Example Tool Usage
The included reverse_string
tool demonstrates the basic pattern:
@mcp.tool()
def reverse_string(input: str) -> str:
"""Reverses the input string"""
return input[::-1]
This skeleton provides a solid foundation for building more complex MCP servers with multiple tools and capabilities.