
Python Server MCP - Cryptocurrency Price Service
This project implements an MCP (Model Context Protocol) server that provides cryptocurrency price information. The server is built using Python and the MCP framework to create an API that can be consumed by different clients.
Docker
Docker build:
docker build -t mcp/python-server-mcp -f Dockerfile .
Add the following to your mcp.json file:
{
"mcpServers": {
"python-server-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-p",
"8000:8000",
"-e",
"ENVIRONMENT",
"-e",
"COINMARKETCAP_API_KEY",
"mcp/python-server-mcp"
],
"env": {
"ENVIRONMENT": "PRODUCTION",
"COINMARKETCAP_API_KEY": "your-api-key",
}
}
}
}Features
- Real-time cryptocurrency price retrieval
- Environment-based configuration (development, production, staging, local)
- CoinMarketCap API integration
- Docker container deployment
Project Structure
.
โโโ main.py
โโโ src
โโโ __init__.py
โโโ core
โ โโโ common
โ โ โโโ crypto_schema.py
โ โ โโโ schema.py
โ โโโ config.py
โ โโโ settings
โ โ โโโ __init__.py
โ โ โโโ base.py
โ โ โโโ development.py
โ โ โโโ environment.py
โ โ โโโ local.py
โ โ โโโ production.py
โ โ โโโ staging.py
โ โโโ utils
โ โโโ datetime.py
โ โโโ extended_enum.py
โ โโโ filename_generator.py
โ โโโ passwords.py
โ โโโ query_utils.py
โ โโโ redis.py
โโโ mcp_server.py
โโโ resources
โ โโโ __init__.py
โ โโโ coinmarketcap_resource.py
โโโ server.py
โโโ services
โ โโโ __init__.py
โ โโโ coinmarketcap_service.py
โโโ tools
โโโ __init__.py
โโโ prices.pyDevelopment
Adding New Tools to the MCP Server
To add a new tool to the MCP server, follow these steps:
- Define the function in the
src/__init__.pyfile - Register the tool in the
main()function - Document the tool with docstrings
Example:
@server.add_tool
def my_new_tool(parameter1: str, parameter2: int) -> str:
"""
Description of what the tool does.
Args:
parameter1: Description of parameter 1
parameter2: Description of parameter 2
Returns:
Description of what is returned
"""
# Tool implementation
return result## Features
- Real-time cryptocurrency price retrieval
- Environment-based configuration (development, production, staging, local)
- CoinMarketCap API integration
- Docker container deployment
## Requirements
- Python 3.12+
- uv (package and virtual environment manager)
- Docker (optional, for container execution)
## Installation
### Using uv (recommended)Before it works, you'll need: ENVIRONMENTCOINMARKETCAP_API_KEY
Requirements
- Python 3.12+
- uv (package and virtual environment manager)
- Docker (optional, for container execution)
Installation
Using uv (recommended)
# Clone the repository
git clone <repository-url>
cd PythonServerMcpCreate and activate virtual environment with uv
uv venv
source .venv/bin/activateInstall dependencies
uv sync
Configuration
- Create a
.envfile in the project root with the following variables:
ENVIRONMENT=DEV # Options: LOCAL, DEV, STAGING, PROD
COINMARKETCAP_API_KEY=your_api_key_here- You can also create specific environment files for each environment:
.dev.env- For development environment.staging.env- For staging environment.prod.env- For production environment
Usage
Local Execution
python main.pyThis will start the MCP server that will listen for requests through standard input/output (stdio).
Using Docker
# Build the image
docker build -t test-mcp -f Dockerfile --platform linux/amd64 .
# Run the container
docker run -it test-mcpNo common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.
Licensed under GPL-3.0โ you can use, modify, and redistribute it under that license's terms.
View the full license file on GitHub โ