- MCP Server Template (Python)
MCP Server Template (Python)
Content
MCP Server Template (Python)
A ready-to-use template for building Model Context Protocol (MCP) servers in Python. This template helps you quickly create servers that can register and expose tools and prompts for AI models to use.
📚 Table of Contents
- Quick Start
- Command Line Options
- Creating Your Own Tools and Prompts
- Project Structure
- Deployment Options
- Development Guide
- Need Help?
🚀 Quick Start
Prerequisites
- Python 3.10 or newer
Setup in 3 Easy Steps
1️⃣ Install the package
# Clone the repository
git clone https://github.com/nisarg38/mcp-server-template-python.git my-mcp-server
cd my-mcp-server
# Install in development mode
pip install -e ".[dev]"
2️⃣ Run your server
# Run with Python
python -m src.main
# Or use the convenient CLI
mcp-server-template
3️⃣ Your server is now live!
Access your MCP server at:
- 🌐 HTTP: http://localhost:8080
- 💻 Or use the stdio transport:
mcp-server-template --transport stdio
You'll see log output confirming the server is running successfully.
🎮 Command Line Options
Customize your server behavior with these command-line options:
# Change port (default: 8080)
mcp-server-template --port 9000
# Enable debug mode for more detailed logs
mcp-server-template --debug
# Use stdio transport instead of HTTP
mcp-server-template --transport stdio
# Set logging level (options: debug, info, warning, error)
mcp-server-template --log-level debug
🛠️ Creating Your Own Tools and Prompts
Add a Tool
Tools are functions that AI models can call. To add a new tool:
- Edit
src/main.py - Add a new function with the
@mcp.tool()decorator:
@mcp.tool()
def your_tool_name(param1: str, param2: int) -> Dict[str, Any]:
"""
Your tool description - this will be shown to the AI.
Args:
param1: Description of first parameter
param2: Description of second parameter
Returns:
Dictionary with your results
"""
# Your tool logic here
return {"result": "your result"}
Add a Prompt
Prompts are templates that AI models can access:
@mcp.prompt()
def your_prompt_name(param: str) -> str:
"""Your prompt description."""
return f"""
Your formatted prompt with {param} inserted.
Use this for structured prompt templates.
"""
📁 Project Structure
src/ # Source code directory
├── main.py # Server entry point with tools & prompts
├── config.py # Configuration settings
├── utils/ # Utility functions
├── tools/ # Tools implementation
└── resources/ # Resource definitions
test/ # Tests directory
pyproject.toml # Package configuration
Dockerfile # Docker support
🚢 Deployment Options
Docker Deployment
# Build the Docker image
docker build -t my-mcp-server .
# Run the container
docker run -p 8080:8080 my-mcp-server
Cloud Deployment
This template is designed to work well with various cloud platforms:
- Deploy as a container on AWS, GCP, or Azure
- Run on serverless platforms that support containerized applications
- Works with Kubernetes for orchestration
🧪 Development Guide
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src test
isort src test
# Run linting
flake8 src test
❓ Need Help?
- 📚 MCP Documentation: modelcontextprotocol.io
- 🐛 File an issue: GitHub Issues
- 💬 Community: Join our Discord community (link coming soon)
Made with ❤️ for the AI developer community
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
WindsurfThe new purpose-built IDE to harness magic
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题;
Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Tavily Mcp
CursorThe AI Code Editor
Playwright McpPlaywright MCP server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
DeepChatYour AI Partner on Desktop
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Amap Maps高德地图官方 MCP Server
Serper MCP ServerA Serper MCP Server