Example MCP Server
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.
README
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:
git clone <repository-url>
cd nikolas-mcp
- Install dependencies using uv:
uv sync
- Run the server:
uv run python -m mcp_server.main
Using Docker
- Build the Docker image:
docker build -t mcp-server .
- Run the container:
docker run -p 8000:8000 mcp-server
- Or use docker-compose:
docker-compose up
Available Tools
The MCP server provides the following tools:
calculate
Evaluates mathematical expressions safely.
Parameters:
expression(string): Mathematical expression to evaluate
Example:
{
"tool": "calculate",
"arguments": {
"expression": "2 + 3 * 4"
}
}
greet
Generates friendly greeting messages.
Parameters:
name(string): Name of the person to greet
Example:
{
"tool": "greet",
"arguments": {
"name": "World"
}
}
Resources
config://settings- Server configuration settingsinfo://server- General server information
Prompts
help- Display help information about available capabilities
Development
Setup Development Environment
# Install development dependencies
uv sync --dev
# Install pre-commit hooks
uv run pre-commit install
Running Tests
# Run all tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=src --cov-report=html
# Run specific test file
uv run pytest tests/test_main.py -v
Code Quality
# Format code
uv run ruff format .
# Lint code
uv run ruff check .
# Type checking
uv run mypy src/
Project Structure
nikolas-mcp/
โโโ src/
โ โโโ mcp_server/
โ โโโ __init__.py
โ โโโ main.py # Main server implementation
โ โโโ server.py # Server utilities and config
โโโ tests/
โ โโโ __init__.py
โ โโโ conftest.py # Pytest configuration
โ โโโ test_main.py # Main functionality tests
โ โโโ test_server.py # Server utilities tests
โ โโโ test_integration.py # Integration tests
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml # CI/CD pipeline
โ โโโ dependabot.yml # Dependabot auto-merge
โโโ Dockerfile
โโโ docker-compose.yml
โโโ pyproject.toml # Project configuration
โโโ README.md
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:
config = ServerConfig()
config.max_connections = 200
config.timeout = 60
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
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.
E2B
Using MCP to run code via e2b.