Labsco
stevearagonsite logo

Cryptocurrency Price Service

from stevearagonsite

Provides real-time cryptocurrency price information using the CoinMarketCap API.

๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedAccount requiredAdvanced setup

MseeP.ai Security Assessment Badge

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.py

Development

Adding New Tools to the MCP Server

To add a new tool to the MCP server, follow these steps:

  1. Define the function in the src/__init__.py file
  2. Register the tool in the main() function
  3. 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