Fintech MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Fintech MCP Server evaluate the risk of buying 10 shares of AAPL for my account"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Fintech MCP Server Blueprint
A production-oriented reference blueprint for customer-facing financial & trading MCP servers (Streamable HTTP + stdio JSON-RPC 2.0).
Most MCP demos stop at wrapping three REST endpoints and trusting the system prompt to behave. In real brokerage, trading, and portfolio platforms, the hard 80% lives in the control layer between the model and your execution API:
OAuth 2.1 + RFC 9728 Protected Resource Metadata: Bearer token verification with RFC 8707 audience binding, least-privilege scopes (
portfolio:read,market:read,orders:propose,orders:execute), and per-user account isolation (IDOR prevention).Strict Pydantic v2 Tool Contracts (
extra="forbid"): Rejects hallucinated or prompt-injected fields before business logic ever runs, with explicit token-budget pagination caps.Deterministic
DecimalRisk & Sizing Engine: Zero binary floats. The model passes an intent (account_id,symbol,side,quantity); deterministic Python computes exact notional, buying power, short-sale checks, and post-trade single-name concentration limits, emitting an immutable SHA-256proposal_hash.Non-Bypassable Ed25519 Human Confirmation Gate: Execution accepts only an approved
proposal_hashsigned out-of-band on an operator channel. The MCP server holds only the reviewer's public key and exposes no approval tool—rejecting unapproved calls, forged signatures, failed risk checks, expired TTLs (>15 min), live price drift (>50 bps), and replays.Tamper-Evident Signed Audit Log: Append-only SHA-256 hash-chained, Ed25519-signed JSONL log written and verified before routing any order to the broker adapter.
Automated CI Eval Suite: Runs adversarial security, isolation, arithmetic, and gate regression cases on every push via GitHub Actions.
Architecture
flowchart LR
Client["MCP Client\n(Claude / ChatGPT / Cursor)"] -->|Bearer JWT + RFC 8707 aud| Auth["OAuth 2.1 Middleware\nScopes + Account Isolation"]
Auth -->|Validated JSON-RPC 2.0| Router["Typed Tool Router\nPydantic v2 · extra=forbid"]
Router -->|Read tools| Broker["Broker Adapter\n(IBKR / Alpaca / Sandbox)"]
Router -->|evaluate_order_risk| Risk["Deterministic Risk Engine\nPython Decimal · SHA-256 hash"]
Risk --> Gate["Ed25519 Approval Gate\nTTL · Drift · Replay Guard"]
Operator["Human Reviewer\n(Out-of-Band UI / Key)"] -.->|Signed ApprovalRecord| Gate
Gate -->|Append & Verify FIRST| Audit["Hash-Chained Audit Log\nSHA-256 + Ed25519 JSONL"]
Audit -->|Authorized only| BrokerRelated MCP server: IBKR Agent Harness MCP Server
Tool Surface
Tool | Required OAuth Scope | Behavior |
|
| Exact |
|
| Holdings, market values, and weights with bounded pagination |
|
| Bid / ask / last quote snapshot |
|
| Computes exact notional & risk checks server-side; returns immutable |
|
| Enforces Ed25519 approval, TTL, drift, replay & audit verification before broker routing |
|
| Independently validates full hash chain and Ed25519 signatures |
Quick Start
uv sync --all-extras
# Run unit & integration test suite
uv run pytest -v
# Run automated security & contract CI evals
uv run python -m evals.run_evals
# Lint
uv run ruff check src tests evalsRun the Streamable HTTP MCP Server locally
uv run python -c "
import uvicorn
from fintech_mcp.http_app import create_demo_app
app, verifier, _, _ = create_demo_app()
uvicorn.run(app, host='127.0.0.1', port=8080)
"Inspect OAuth 2.1 discovery metadata at GET http://127.0.0.1:8080/.well-known/oauth-protected-resource and send authenticated JSON-RPC 2.0 requests to POST http://127.0.0.1:8080/mcp.
Repository Structure
src/fintech_mcp/
auth.py # OAuth 2.1 bearer verification, RFC 8707 aud, scope & account checks
schemas.py # Strict Pydantic v2 tool contracts and response models
risk.py # Deterministic Decimal sizing, concentration & pre-trade risk engine
gate.py # Out-of-band Ed25519 confirmation gate (TTL, drift, replay guards)
audit.py # SHA-256 hash-chained & Ed25519-signed append-only audit log
broker.py # BrokerAdapter protocol + deterministic SandboxBrokerAdapter
router.py # Transport-agnostic JSON-RPC 2.0 MCP router
http_app.py # FastAPI Streamable HTTP transport + RFC 9728 metadata
server.py # Stdio JSON-RPC 2.0 MCP transport
tests/
test_server.py # Unit & HTTP integration tests
evals/
run_evals.py # Automated adversarial & contract CI evaluation harnessAuthor & Consulting
Built by Ahmed Khattab — AI Agents & MCP Infrastructure Engineer for Finance (Philips, ASML via ICT Group, Valeo; previously led a ~20-tool brokerage MCP server over IBKR, Alpaca, and Binance).
Published as-is under Apache-2.0 as an architectural reference blueprint. For fixed-price production MCP servers, broker/market-data agent integrations, or CI evaluation harnesses, visit ahmedkhattab.io or email ahmed@ahmedkhattab.io.
Engineering reference only. Uses an in-memory sandbox broker adapter and does not connect to live accounts or give investment advice.
Available Tools
5 toolsevaluate_order_riskA
Compute deterministic Decimal sizing, post-trade concentration, and pre-trade risk checks for an order intent. Emits an immutable SHA-256 proposal_hash; never executes.
Inputs: side (required), symbol (required), quantity (required), rationale (required), +3 more.
get_account_balancesBRead-only
Read cash, buying power, and NAV for an authorized brokerage account.
Inputs: account_id (required).
get_market_quoteARead-only
Read latest bid/ask/last market quote for an equity or ETF symbol.
Inputs: symbol (required).
get_positionsBRead-only
Read current holdings, market values, and portfolio weights (Decimal exact).
Inputs: account_id (required), limit.
verify_audit_logARead-only
Verify the SHA-256 hash chain and Ed25519 signatures across the audit log.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool targets a distinct resource and action: account balances, market quote, positions, order risk evaluation, and audit log verification. The only near-neighbors, get_account_balances and get_positions, are clearly separated by their descriptions (cash/NAV vs. holdings/weights).
All five tools follow the same verb_noun snake_case convention (get_*, evaluate_*, verify_*). Names are readable and predictably structured across resources.
Five tools is a tight, well-scoped surface for a read-only brokerage and risk layer, with each tool earning a clear place. Nothing redundant and nothing padding the list.
The read-and-verify surface is coherent, and risk evaluation explicitly stops at a proposal hash, handing execution off elsewhere. Minor gaps remain: no account/authorization enumeration, no order status or trade history lookup to close the post-submission loop.
Related MCP Connectors
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
Institutional financial data with SEC filing citations, for every AI agent. OAuth 2.1.
Unified financial infrastructure connecting AI agents directly to trade live/demo brokerage accounts, Web3 non-custodial wallets, real-time market data across equities, ETFs, crypto, forex, options, DeFi swaps, and prediction markets, institutional research feeds, and algorithmic strategy backtesters.
Deterministic pre-trade risk firewall and portfolio MCP server for AI agents (IBKR, Alpaca).
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to execute stock trading operations with built-in risk controls and human approval workflows. Supports paper trading simulation, real brokerage integration (Alpaca, Tradier), backtesting, sentiment analysis, and portfolio management while maintaining strict separation between AI intelligence and trade execution.MIT
- AlicenseBqualityBmaintenanceEnables LLM clients to query Interactive Brokers portfolio data and run deterministic policy, valuation, risk, tax, and options analytics through read-only tools, with dual-plane DLP isolation for local or public-only cloud research and human-approved stateful workflows.211MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI clients to author and backtest trading strategies, paper trade, and execute orders across supported venues with built-in circuit breakers, risk-based position sizing, automatic stop-loss and take-profit orders, and a local audit trail.9MIT
- AlicenseBqualityBmaintenanceEnables AI agents to access Charles Schwab market data, account information, and risk-guarded trading through official APIs with OAuth authentication and configurable safety controls.30MIT