my-mcp-server2
A Model Context Protocol server built with FastMCP that features dynamic tool loading and modular management via a dedicated tool directory. It supports both stdio and HTTP transport modes, enabling efficient development and deployment of custom MCP tools.
README
my-mcp-server2
my-mcp-server2 is a Model Context Protocol (MCP) server built with FastMCP featuring dynamic tool loading.
Features
- Dynamic Tool Loading: Tools are automatically discovered and loaded from
src/tools/ - One Tool Per File: Each tool is a single file with a function matching the filename
- FastMCP Integration: Leverages FastMCP for robust MCP protocol handling
- Configuration Management: Tool-specific configuration via
mcp.yaml - Fail-Fast: Server won't start if any tool fails to load
- Auto-Generated Tests: Automatic test generation for tool validation
Project Structure
src/
├── tools/ # Tool implementations (one file per tool)
│ ├── echo.py # Example echo tool
│ └── __init__.py # Auto-generated tool registry
├── core/ # Dynamic loading framework
│ ├── server.py # Dynamic MCP server
│ └── utils.py # Shared utilities
└── main.py # Entry point
mcp.yaml # Configuration file
tests/ # Generated tests
Quick Start
Option 1: Local Development (with Python/uv)
-
Install Dependencies:
uv sync -
Run the Server:
# Stdio mode (default MCP transport) uv run python src/main.py # HTTP mode with WebSocket MCP endpoint uv run python src/main.py --http # HTTP mode with custom host/port uv run python src/main.py --http --host 0.0.0.0 --port 8080 -
Using uv Scripts:
# Development mode (HTTP on port 3000) uv run dev # HTTP mode uv run dev-http # Stdio mode uv run start -
Add New Tools:
# Create a new tool (no tool types needed!) arctl mcp add-tool weather # The tool file will be created at src/tools/weather.py # Edit it to implement your tool logic
Option 2: Docker-Only Development (no local Python/uv required)
-
Build Docker Image:
arctl mcp build --verbose -
Run in Container:
docker run -i my-mcp-server2:latest -
Add New Tools:
# Create a new tool arctl mcp add-tool weather # Edit the tool file, then rebuild arctl mcp build
HTTP Transport Mode
The server supports running in HTTP mode for development and integration purposes.
Starting in HTTP Mode
# Command line flag
python src/main.py --http
# Environment variable
MCP_TRANSPORT_MODE=http python src/main.py
# Custom host and port
python src/main.py --http --host localhost --port 8080
Creating Tools
Basic Tool Structure
Each tool is a Python file in src/tools/ containing a function decorated with @mcp.tool():
# src/tools/weather.py
from core.server import mcp
from core.utils import get_tool_config, get_env_var
@mcp.tool()
def weather(location: str) -> str:
"""Get weather information for a location."""
# Get tool configuration
config = get_tool_config("weather")
api_key = get_env_var(config.get("api_key_env", "WEATHER_API_KEY"))
base_url = config.get("base_url", "https://api.openweathermap.org/data/2.5")
# TODO: Implement weather API call
return f"Weather for {location}: Sunny, 72°F"
Tool Examples
The generated tool template includes commented examples for common patterns:
# HTTP API calls
# async with httpx.AsyncClient() as client:
# response = await client.get(f"{base_url}/weather?q={location}&appid={api_key}")
# return response.json()
# Database operations
# async with asyncpg.connect(connection_string) as conn:
# result = await conn.fetchrow("SELECT * FROM weather WHERE location = $1", location)
# return dict(result)
# File processing
# with open(file_path, 'r') as f:
# content = f.read()
# return {"content": content, "size": len(content)}
Configuration
Configure tools in mcp.yaml:
tools:
weather:
api_key_env: "WEATHER_API_KEY"
base_url: "https://api.openweathermap.org/data/2.5"
timeout: 30
database:
connection_string_env: "DATABASE_URL"
max_connections: 10
Testing
Run the generated tests to verify your tools load correctly:
uv run pytest tests/
Development
Adding Dependencies
Update pyproject.toml and run:
uv sync
Code Quality
uv run black .
uv run ruff check .
uv run mypy .
Deployment
Docker
# Build image (handles lockfile automatically)
arctl mcp build
# Run container
docker run -i my-mcp-server2:latest
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。