Python-based-MCP-server

dineshkhichar569/Python-based-MCP-server

3.2

If you are the rightful owner of Python-based-MCP-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This project implements a Python-based MCP server for real-time and historical cryptocurrency market data using the CCXT library.

Tools
2
Resources
0
Prompts
0

Crypto MCP Server – Real-Time & Historical Market Data (Python)

This project implements a Python-based MCP (Model Context Protocol) server that exposes tools for retrieving real-time and historical cryptocurrency market data using the CCXT exchange library. The server follows MCP best practices, includes caching, error handling, modular architecture, and test coverage.


1. Features

Core MCP Tools

  • realtime_price(symbol)
    Returns real-time market price for a trading pair (e.g., BTC/USDT).

  • historical_price(symbol, timeframe)
    Returns OHLCV historical data for a given timeframe (e.g., 1m, 1h, 1d).

Supporting Features

  • Clean modular architecture (handlers/)
  • Error handling and rate-limit safe design
  • In-memory caching with TTL
  • Automated tests using pytest
  • Fully MCP compatible using fastmcp

2. Tech Stack

  • Python 3.10+
  • MCP (Model Context Protocol) – FastMCP
  • CCXT for exchange data
  • Pytest for testing

3. Project Structure

        Python-based MCP/
        |
        |- server.py
        |- requirements.txt
        |- README.md
        |
        |- handlers/
        | |- init.py
        | |- realtime.py
        | |- historical.py
        | |- utils.py
        |
        |- tests/
        |- init.py
        |- test_realtime.py
        |- test_historical.py

4. Installation

Clone the repository:

git clone <your-repo-url>
cd crypto_mcp

Install dependencies:


pip install -r requirements.txt

5. Running the MCP Server

Start the server:

python server.py

The server will start and wait for incoming MCP tool calls.

6. MCP Tools Overview

1. Real-Time Price

Tool: realtime_price(symbol)

Example Call:

{
  "symbol": "BTC/USDT"
}

Example Response:

{
  "symbol": "BTC/USDT",
  "price": 98765.12
}

2. Historical Price Data

Tool: historical_price(symbol, timeframe) Example Call:

{
  "symbol": "BTC/USDT",
  "timeframe": "1h"
}

Example Response:

{
  "symbol": "BTC/USDT",
  "data": [
    [timestamp, open, high, low, close, volume],
    ...
  ]
}

7. Caching

The project uses a custom @cache(ttl=...) decorator:

  • Real-time prices cached for 10 seconds
  • Historical data cached for 60 seconds

This improves performance and reduces API load.

8. Running Tests

Run all tests:

pytest

Expected result:

2 passed in X.XXs


9. Assumptions & Limitations

  • Binance (via CCXT) is used as the default exchange.

  • Any network or rate-limit issue may return an "error" field.

  • The server is read-only (no trading endpoints).

  • Project is designed for clarity, modularity, and reliability.


👤 Author

Dinesh Khichar

💻 Full Stack Developer (MERN & Python)
🎓 B.Tech CSE, DIT University, Dehradun

🔗 Links

🐙 GitHub: https://github.com/dineshkhichar569
🔗 LinkedIn: https://www.linkedin.com/in/dinesh-khichar-5265b4282
🌐 Portfolio: https://dineshportfolios.site

📝 Professional Summary

Focused and fast-learning full stack developer with experience in MERN stack, Python tooling, and backend API integrations. Strong foundation in scalable architecture, clean code practices, and automated testing. Passionate about building reliable, production-ready systems and actively preparing for backend/full-stack internship roles.

🚀 Skills

  • ⚛️ MERN Stack (MongoDB, Express, React, Node.js)
  • 🐍 Python (APIs, automation, MCP tools)
  • 🌐 REST APIs, JSON, Postman
  • 🧠 DSA (problem-solving & algorithms)
  • 📦 Git, GitHub, CI basics
  • 🛠️ System Design fundamentals