MCP Server with FastMCP v2.0
A Model Control Protocol (MCP) server implementation using FastMCP v2.0, featuring Docker containerization, comprehensive testing, and CI/CD automation.
Features
- 🚀 Built with FastMCP v2.0
- 🐳 Docker containerization with multi-stage builds
- 📦 Modern Python packaging with
uv
- 🧪 Comprehensive test suite with pytest
- 🔄 GitHub Actions CI/CD pipeline
- 🛡️ Security scanning and dependency management
- 📊 Code coverage reporting
- 🔧 Automated code formatting and linting
Quick Start
Prerequisites
- Python 3.10+
- uv for dependency management
- Docker (optional, for containerization)
Installation
- Clone the repository:
- Install dependencies using uv:
- Run the server:
Using Docker
- Build the Docker image:
- Run the container:
- Or use docker-compose:
Available Tools
The MCP server provides the following tools:
calculate
Evaluates mathematical expressions safely.
Parameters:
expression
(string): Mathematical expression to evaluate
Example:
greet
Generates friendly greeting messages.
Parameters:
name
(string): Name of the person to greet
Example:
Resources
config://settings
- Server configuration settingsinfo://server
- General server information
Prompts
help
- Display help information about available capabilities
Development
Setup Development Environment
Running Tests
Code Quality
Project Structure
CI/CD Pipeline
The project includes a comprehensive GitHub Actions pipeline:
- Lint and Format: Runs ruff for code formatting and linting
- Test Suite: Runs tests across multiple Python versions and OS platforms
- Security Scan: Performs security vulnerability scanning
- Docker Build: Builds and tests Docker images
- Auto-publish: Publishes to PyPI and Docker Hub on release
Required Secrets
For full CI/CD functionality, configure these GitHub secrets:
PYPI_API_TOKEN
- PyPI authentication tokenDOCKERHUB_USERNAME
- Docker Hub usernameDOCKERHUB_TOKEN
- Docker Hub access token
Configuration
Environment Variables
LOG_LEVEL
- Logging level (default: INFO)PYTHONPATH
- Python path for module resolution
Server Configuration
The server can be configured via the ServerConfig
class in src/mcp_server/server.py
:
Docker Configuration
Multi-stage Build
The Dockerfile uses multi-stage builds for optimized image size:
- Base stage: Sets up Python and system dependencies
- Dependencies stage: Installs Python packages with uv
- Runtime stage: Copies application code and runs the server
Health Checks
The container includes health checks to ensure the server is running correctly.
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Run tests and ensure they pass
- 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.
Support
If you encounter any issues or have questions:
- Check the Issues page for existing problems
- Create a new issue with detailed information
- Refer to the FastMCP documentation for FastMCP-specific questions
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A demonstration MCP server built with FastMCP v2.0 that provides basic mathematical calculations and greeting functionality. Features Docker containerization, comprehensive testing, and CI/CD automation for learning MCP development patterns.
Related MCP Servers
- -securityFlicense-qualityA minimal fastmcp demonstration server that provides a simple addition tool through the MCP protocol, supporting deployment via Docker with multiple transport modes.Last updated -2
- AsecurityAlicenseAqualityA starter template for building MCP servers with FastMCP, providing testing, linting, formatting, and NPM publishing setup.Last updated -11MIT License
- AsecurityAlicenseAqualityA FastMCP server for mathematical computations, including numerical and symbolic calculations with NumPy and SymPy integration, as well as data visualization through Matplotlib.Last updated -125MIT License
- -securityFlicense-qualityA basic MCP server template built with FastMCP that provides simple tools for greeting users, performing math operations, and managing user information. Serves as a starting point for building custom MCP servers with essential functionality examples.Last updated -4