Supports environment variable management via .env files for server configuration, loaded by python-dotenv/pydantic-settings
Listed as a prerequisite for using the server, suggesting integration with Git for version control
Uses Pydantic for data modeling and validation, with dedicated models directory for schemas
Provides comprehensive test suite integration including unit, integration, and performance tests
Built as a Python template for MCP servers, requiring Python >=3.13
Integrates with Taskfile for managing development workflows, CI tasks, and server operations
My MCP Server
My MCP Server is a Python template for building a Model Context Protocol (MCP) server. It uses FastMCP to expose tools via JSON-RPC over stdio (and can be extended to HTTP), enabling secure and scalable context and tool invocation for language models.
Project Structure
├── src/ Source code (package: my_mcp_server
)
│ ├── server.py Entry point and tool registrations
│ ├── main.py Console script entry
│ ├── config/ Configuration modules
│ ├── context/ Context providers for MCP
│ ├── models/ Pydantic models and schemas
│ ├── tools/ Custom tool implementations
│ └── utils/ Helper utilities
├── tests/ Unit, integration, and performance tests
├── Taskfile.yaml Common development and CI tasks
├── pyproject.toml Project metadata and build configuration
├── requirements.txt Runtime dependencies
└── docs/ Contribution & architecture guides
Prerequisites
- Python >=3.13
- Git
- (Optional) Taskfile task runner
Setup
Create and activate virtual environment
task create-venv source .venv/bin/activate
Install runtime dependencies
task install-requirements
(Optional) Install development dependencies
task install-dev
Taskfile Tasks
Run task --list
to see all available tasks. Common tasks include:
- default: List available tasks
- create-venv: Create a Python virtual environment in
.venv
- activate-venv: Show activation commands for the venv
- clean-venv: Remove the
.venv
directory - install-requirements: Install runtime dependencies (
pip install -r requirements.txt
) - install-dev: Install the project in editable mode with dev dependencies (
pip install -e ".[dev]"
) - flake8: Run
flake8
oversrc/
andtests/
- mypy: Run
mypy
oversrc/
andtests/
- black: Format code with
black
- format: Alias for
black
(formats all Python files) - lint: Run both
flake8
andmypy
- test: Run all tests (unit, integration, performance) with
pytest
- test-unit: Run unit tests only
- test-integration: Run integration tests only
- test-performance: Run performance tests only
- coverage: Generate coverage report (HTML + terminal) with
pytest-cov
- check: Run
format
,lint
, andtest
sequentially - run: Start the console-based MCP server (
python -m my_mcp_server
) - dev: Alias for
run
(start server in development mode) - clean: Clean Python build artifacts and caches
- build: Build distribution packages (sdist & wheel) using Hatchling
Development & Usage
After setup, you can start the server in stdio mode:
Or directly:
Testing & Linting
- Run all tests:
task test
- Run linters:
task lint
- Format code:
task format
Build & Release
- Build distributions:
task build
- Upload to PyPI:
twine upload dist/*
Configuration
Environment variables can be managed via a .env
file (loaded by python-dotenv
/pydantic-settings
).
Contributing
See docs/CONTRIBUTING.md
for guidelines on contributing and architecture details.
License
MIT License
This server cannot be installed
A Python template for building Model Context Protocol (MCP) servers that expose tools via JSON-RPC, enabling secure and scalable context and tool invocation for language models.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol (MCP) server that provides JSON-RPC functionality through OpenRPC.Last updated -2733JavaScriptApache 2.0
- AsecurityAlicenseAqualityA TypeScript-based template for building Model Context Protocol servers, featuring fast testing, automated version management, and a clean structure for MCP tool implementations.Last updated -1162TypeScriptMIT License
- -securityAlicense-qualityA streamlined foundation for building Model Context Protocol servers in Python, designed to make AI-assisted development of MCP tools easier and more efficient.Last updated -14PythonMIT License
- -securityFlicense-qualityA Python implementation of the MCP server that enables AI models to connect with external tools and data sources through a standardized protocol, supporting tool invocation and resource access via JSON-RPC.Last updated -1Python