DaZongGuan MCP Server
A template for building MCP servers with Python, providing modular tools, API key authentication, and logging to connect AI-powered assistants to backend systems.
README
DaZongGuan - MCP Server Template
A template for building MCP (Model Context Protocol) servers with Python. This template provides a solid foundation for creating AI-powered assistants that connect to your backend systems.
Features
- š MCP Protocol Support - Built on MCP Python SDK 2.0
- š ApiKey Authentication - Secure API key-based authentication via HTTP headers
- š ļø Modular Tools - Easy-to-extend tool system
- š Comprehensive Logging - Built-in logging with rotation
- š Production Ready - Includes middleware, error handling, and configuration management
Quick Start
Prerequisites
- Python 3.10+
- MCP Python SDK >= 2.0.0
Installation
# Clone the repository
git clone https://github.com/yourusername/mcp-server-template.git
cd mcp-server-template
# Install dependencies
pip install -r requirements.txt
# Copy environment template
cp .env.example .env
Configuration
Edit .env file with your settings:
# Backend API Configuration
API_BASE_URL=http://your-api-server:port
# Server Configuration
PORT=8001
# Logging
LOG_LEVEL=INFO
Start Server
python server.py
The server runs at http://localhost:8001 by default, with the MCP endpoint at http://localhost:8001/mcp.
Project Structure
mcp-server-template/
āāā server.py # MCP server entry point
āāā config.py # Configuration and logging
āāā middleware.py # Authentication middleware
āāā constants.py # Constants definition
āāā utils.py # Utility functions
āāā tools/ # Tools module directory
ā āāā __init__.py # Tools module initialization
ā āāā example.py # Example tools
ā āāā ... # Add your tools here
āāā docs/ # Documentation
ā āāā README.md # This file
ā āāā API.md # API documentation
āāā .env.example # Environment variables template
āāā requirements.txt # Python dependencies
āāā LICENSE # MIT License
Usage
Configure MCP Client
Add the MCP configuration to your AI client:
{
"mcpServers": {
"your-server-name": {
"url": "http://localhost:8001/mcp",
"headers": {
"X-Api-Key": "YOUR_API_KEY"
}
}
}
}
Creating Tools
Create new tools in the tools/ directory:
# tools/your_tool.py
from utils import call_api, check_response
def register_your_tools(mcp):
"""Register your tools to MCP server"""
@mcp.tool()
async def your_tool_name(param1: str = "", param2: int = 0) -> str:
"""Tool description for AI to understand when to use it.
Args:
param1: Description of param1
param2: Description of param2
Returns:
Description of return value
"""
# Call your backend API
res = await call_api("/api/your-endpoint", body={
"param1": param1,
"param2": param2
})
# Check response
ok, result = check_response(res, "your action")
if not ok:
return f"ā {result}"
# Process and return result
return f"ā
Success: {result}"
Register your tools in tools/__init__.py:
from tools.your_tool import register_your_tools
def register_all_tools(mcp):
"""Register all tools to MCP server"""
register_your_tools(mcp)
Creating Resources
Resources provide read-only data to AI:
@mcp.resource("your-server://resource-name")
async def get_resource():
"""Resource description"""
return {"key": "value"}
Environment Variables
| Variable | Description | Default |
|---|---|---|
API_BASE_URL |
Backend API base URL | http://localhost:8000 |
PORT |
Server port | 8001 |
LOG_LEVEL |
Logging level | INFO |
Tech Stack
- MCP Python SDK - Official MCP Python SDK (>= 2.0.0)
- httpx - Async HTTP client
- uvicorn - ASGI server
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Model Context Protocol - The protocol specification
- MCP Python SDK - The Python implementation
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.