
ML Task Router MCP Server
Enables routing of ML tasks like chat, sentiment analysis, recommendations, and summarization to appropriate models through a dynamic YAML-based registry. Provides async FastAPI endpoints with streaming support, retry logic, and pluggable model architecture for scalable ML inference.
README
🧠 MCP Server (Model Compute Paradigm)
A modular, production-ready FastAPI server built to route and orchestrate multiple AI/LLM-powered models behind a unified, scalable interface. It supports streaming chat, LLM-based routing, and multi-model pipelines (like analyze → summarize → recommend) – all asynchronously and fully Dockerized.
🎯 Project Score (Production Readiness)
Capability | Status | Details |
---|---|---|
🧠 Multi-Model Orchestration | ✅ Complete | Dynamic routing between chat , summarize , sentiment , recommend |
🤖 LLM-Based Task Router | ✅ Complete | GPT-powered routing via "auto" task type |
🔁 Async FastAPI + Concurrency | ✅ Complete | Async/await + concurrent task execution with simulated/model API delays |
🔊 GPT Streaming Support | ✅ Complete | text/event-stream chunked responses for chat endpoints |
🧪 Unit + Mocked API Tests | ✅ Complete | Pytest-based test suite with mocked run() responses |
🐳 Dockerized + Clean Layout | ✅ Complete | Python 3.13 base image, no Conda dependency, production-ready Dockerfile |
📦 Metadata-Driven Registry | ✅ Complete | Model metadata loaded from external YAML config |
🔐 Rate Limiting & Retry | ⏳ In Progress | Handles 429 retry loop; rate limiting controls WIP |
🧪 CI + Docs | ⏳ Next | GitHub Actions + Swagger/Redoc planned |
🧩 Why This Project? (Motivation)
Modern ML/LLM deployments often involve:
- Multiple task types and model backends (OpenAI, HF, local, REST)
- Routing decisions based on input intent
- Combining outputs of multiple models (e.g.,
summarize
+recommend
) - Handling 429 retries, async concurrency, streaming responses
🔧 However, building such an LLM backend API server that is:
- Async + concurrent
- Streamable
- Pluggable (via metadata)
- Testable
- Dockerized … is non-trivial and not easily found in one single place.
💡 What We’ve Built (Solution)
This repo is a production-ready PoC of an MCP (Model-Compute Paradigm) architecture:
- ✅ FastAPI-based microserver to handle multiple tasks via
/task
endpoint - ✅ Task router that can:
- 🔁 Dispatch to specific model types (
chat
,sentiment
,summarize
,recommend
) - 🤖 Use an LLM to infer which task to run (
auto
) - 🧠 Run multiple models in sequence (
analyze
)
- 🔁 Dispatch to specific model types (
- ✅ GPT streaming via
text/event-stream
- ✅ Async/await enabled architecture for concurrency
- ✅ Clean modular code for easy extension
- ✅ Dockerized for deployment
- ✅ Tested using Pytest with mocking
🛠️ Use Cases
Use Case | MCP Server Support |
---|---|
Build your own ChatGPT-style API | ✅ chat task with streaming |
Build intelligent task router | ✅ auto task with GPT-powered intent parsing |
Build AI pipelines (like RAG/RL) | ✅ analyze task with sequential execution |
Swap between OpenAI/HuggingFace APIs | ✅ Via model_registry.yaml config |
Add custom models (e.g., OCR, vision) | ✅ Just add a new module + registry entry |
🚀 Features
- ✅ Async FastAPI server
- 🧠 Task-based Model Routing (
chat
,sentiment
,recommender
,summarize
) - 📄 Model Registry from YAML/JSON
- 🔁 Automatic Retry and Rate Limit Handling for APIs
- 🔄 Streaming Responses for Chat
- 🧪 Unit Tests + Mocked API Calls
- 🐳 Dockerized for production deployment
- 📦 Modular structure, ready for CI/CD
🏗 Architecture Overview
┌────────────┐
│ Frontend │
└─────┬──────┘
│
▼
┌────────────┐ YAML/JSON
│ FastAPI │◄────┐ Model Registry
│ Server │ │
└─────┬──────┘ ▼
┌──────────────┼──────────────┐
│ │ │
▼ ▼ ▼
[chat] [sentiment] [recommender]
GPT-4 HF pipeline stub logic / API
---
🛠 Setup
📦 Install dependencies
git clone https://github.com/YOUR_USERNAME/mcp-server.git
cd mcp-server
---
# Optional: create virtualenv
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
or
conda create -n <env_name>
conda activate <env_name>
pip install -r requirements.txt
▶️ Run the server
uvicorn app:app --reload
Access the docs at: http://localhost:8000/docs
🧪 Running Tests
pytest tests/
Unit tests mock external API calls using unittest.mock.AsyncMock.
🐳 Docker Support
🔨 Build image
docker build -t mcp-server .
🚀 Run container
docker run -p 8000:8000 mcp-server
🧰 Example API Request
curl -X POST http://localhost:8000/task \
-H "Content-Type: application/json" \
-d '{
"type": "chat",
"input": "What are the benefits of restorative yoga?"
}'
🔍 Directory Structure
mcp/
├── app.py # FastAPI entry
├── models/ # ML models (chat, sentiment, etc.)
├── agent/
│ ├── task_router.py # Task router
│ └── model_registry.py # Registry loader
├── registry/models.yaml # YAML registry of model metadata
├── tests/ # Unit tests
├── Dockerfile
├── requirements.txt
├── README.md
└── .env / .gitignore
🤝 Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you’d like to change.
📄 License
MIT
✨ Author
Built by Sriram Kumar Reddy Challa
推荐服务器

Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。