trackmcp
Back to directory
fintools-ai

mcp-order-flow-server

View on GitHub

This is the mcp to fetch and get order flow information

0 stars PythonSearch & Data Retrieval Updated Jun 17, 2025

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.

Python 3.10+
gRPC
MCP

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:

bash
git clone 
   cd mcp-order-flow-server

2. Install dependencies:

bash
pip install -r requirements.txt

3. Generate protobuf files (if using gRPC data source):

bash
./generate_proto.sh

4. Configure environment (optional):

bash
export DATA_BROKER_GRPC_URL=localhost:9090
   export LOG_LEVEL=INFO

5. Start the server:

bash
python src/mcp_server.py

Usage

MCP Tool: `analyze_order_flow_tool`

The server exposes a single MCP tool for order flow analysis:

Parameters

ParameterTypeDefaultDescription
`ticker`stringrequiredStock/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

json
{
  "method": "tools/call",
  "params": {
    "name": "analyze_order_flow_tool",
    "arguments": {
      "ticker": "SPY",
      "history": "5mins",
      "include_patterns": true
    }
  }
}

Example Response

xml
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.20

Configuration

Environment Variables

bash
# 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, ERROR

Data Sources

SourceLatencyThroughputUse Case
gRPC0.1-0.5ms2000+ req/sProduction (Recommended)
Redis0.5-2ms500+ req/sDevelopment/Fallback

Architecture

code
┌─────────────────┐    ┌──────────────────┐    ┌───────────────────┐
│   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

code
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 dependencies

Testing

bash
# 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:

bash
./generate_proto.sh

Performance

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
// Code block

Frequently 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

Run your own MCP server? See who uses it and what to fix.

Measure it with TrackMCP