mcp-order-flow-server
This is the mcp to fetch and get order flow information
Documentation
MCP Order Flow Server
A high-performance Model Context Protocol (MCP) server that provides real-time order flow analysis for algorithmic trading applications. This server connects to market data brokers via gRPC to deliver institutional-grade market microstructure insights.
Features
- Real-time Order Flow Analysis: Live market microstructure data processing
- High-Performance gRPC Integration: Sub-millisecond latency data retrieval
- Institutional Pattern Detection: Absorption, stacking, and sweep patterns
- Support/Resistance Levels: Algorithmically derived key price levels
- Market Momentum Metrics: Bid/ask dynamics and size acceleration
- MCP Protocol Compliance: Seamless integration with AI agents and LLMs
Quick Start
Prerequisites
- Python 3.10 or higher
- A compatible market data broker (gRPC endpoint)
- Basic understanding of market microstructure concepts
Installation
1. Clone the repository:
git clone
cd mcp-order-flow-server2. Install dependencies:
pip install -r requirements.txt3. Generate protobuf files (if using gRPC data source):
./generate_proto.sh4. Configure environment (optional):
export DATA_BROKER_GRPC_URL=localhost:9090
export LOG_LEVEL=INFO5. Start the server:
python src/mcp_server.pyUsage
MCP Tool: `analyze_order_flow_tool`
The server exposes a single MCP tool for order flow analysis:
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| `ticker` | string | required | Stock/ETF ticker symbol (e.g., "SPY", "QQQ") |
| `history` | string | `"5mins"` | Analysis time window (e.g., "30s", "10mins", "1h") |
| `include_patterns` | boolean | `true` | Include pattern detection in response |
Example Request
{
"method": "tools/call",
"params": {
"name": "analyze_order_flow_tool",
"arguments": {
"ticker": "SPY",
"history": "5mins",
"include_patterns": true
}
}
}Example Response
1847
300s
3
485.230
485.250
1800
1200
0.020
0.050
0.045
3
2
1650
1250
1
0
YES
YES
bullish
strong
Strong bid absorption at 485.20Configuration
Environment Variables
# Data source configuration
DATA_SOURCE=grpc # Use 'grpc' (recommended) or 'redis'
DATA_BROKER_GRPC_URL=localhost:9090 # gRPC endpoint for market data
# Redis fallback (if DATA_SOURCE=redis)
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
# Logging
LOG_LEVEL=INFO # DEBUG, INFO, WARNING, ERRORData Sources
| Source | Latency | Throughput | Use Case |
|---|---|---|---|
| gRPC | 0.1-0.5ms | 2000+ req/s | Production (Recommended) |
| Redis | 0.5-2ms | 500+ req/s | Development/Fallback |
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌───────────────────┐
│ MCP Client │───▶│ MCP Server │───▶│ Market Data │
│ (AI Agent) │ │ (This Repo) │ │ Broker (gRPC) │
└─────────────────┘ └──────────────────┘ └───────────────────┘
│
▼
┌──────────────────┐
│ Order Flow │
│ Analysis Engine │
└──────────────────┘Key Components
- MCP Server: FastMCP-based server handling tool requests
- gRPC Client: High-performance data retrieval from market broker
- State Manager: XML response formatting and data aggregation
- Pattern Detector: Real-time institutional pattern recognition
Development
Project Structure
mcp-order-flow-server/
├── src/
│ ├── mcp_server.py # Main MCP server entry point
│ ├── config.py # Configuration management
│ ├── proto/ # Generated protobuf files
│ ├── storage/
│ │ ├── grpc_client.py # gRPC data client
│ │ └── redis_client.py # Redis fallback client
│ ├── formatters/
│ │ └── state_manager.py # XML response formatting
│ └── tools/
│ └── order_flow_tool.py # MCP tool implementation
├── generate_proto.sh # Protobuf generation script
├── test_tool.py # Development testing
└── requirements.txt # Python dependenciesTesting
# Run development tests
python test_tool.py
# Test specific ticker
python -c "
import asyncio
from src.tools.order_flow_tool import analyze_order_flow
result = asyncio.run(analyze_order_flow('SPY', '1min', True))
print(result)
"Regenerating Protobuf Files
If the market data broker's protobuf definitions change:
./generate_proto.shPerformance
Benchmarks
- Analysis Latency:
No data available for ticker
Invalid ticker symbol
Market data broker not running
Network connectivity issues
Verify ticker symbol is correct
Check market data broker status
Ensure network connectivity
// Code blockFrequently asked questions
What is mcp-order-flow-server?
mcp-order-flow-server is This is the mcp to fetch and get order flow information
How do I install mcp-order-flow-server?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is mcp-order-flow-server open source?
Yes — it is hosted on GitHub at https://github.com/fintools-ai/mcp-order-flow-server.
Related MCP tools
🙌 OpenHands: Code Less, Make More for the Model Context Protocol. Enhance AI assistants with powerful integrations. Python-based implementation.
Universal memory layer for AI Agents; Announcing OpenMemory MCP - local and secure memory management. Python-based implementation.
基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择ChatGPT/Claude/DeepSeek/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
Cognee is the open-source AI memory platform for agents. Give your AI agents persistent long-term memory across sessions with a self-hosted knowledge graph engine.
An LLM agent that conducts deep research (local and web) on any given topic and generates a long report with citations. Built for the Model Context Protocol to
🚀 The fast, Pythonic way to build MCP servers and clients Trusted by 19900+ developers. Trusted by 19900+ developers. Trusted by 19900+ developers.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP