longbridge
OfficialLongbridge MCP server provides 145 tools for brokerage operations across US and HK markets:
Quotes & Market Data: Real-time and historical quotes, candlesticks, order book depth, broker queues, capital flow, market sentiment/temperature, A/H premium, options chain, short positions, market anomalies, and index constituents.
Trading: Submit, cancel, and replace orders; view positions, account balance, executions, cash flow, and margin ratios.
Fundamentals: Financial statements, business segments, dividends, EPS forecasts, analyst consensus, institutional ratings, company profiles, corporate actions, regulatory filings, and industry valuations.
Market & Industry Data: Industry rankings, broker holdings (HKEX CCASS), trade statistics, popularity leaderboards, stock screener, and calculated financial indexes.
Macroeconomic Data: Access macro indicators (CPI, GDP, NFP, etc.) and their historical values.
IPO: Subscriptions, calendar, recently listed stocks, order details, and profit/loss analysis.
Portfolio: Profit/loss analysis (overall and per-symbol), exchange rates.
DCA (Dollar-Cost Averaging): Create, update, pause, resume, and stop plans; view execution history and statistics.
Alerts: Add, delete, enable, disable, and list price alerts.
Watchlists & Community: Watchlist group management, community sharelist CRUD, member management, and popular lists.
Content & Search: Symbol news, news search, discussion topics, community topic search, and financial calendar (earnings, dividends, IPOs, macro events, market holidays).
Banking & Statements: Bank cards, deposit/withdrawal records, and account statement listing/export.
Quant: Run custom indicator scripts against historical K-line data.
Utility: Retrieve current UTC time.
Official MCP server for the Longbridge brokerage. 148 tools across real-time quotes, options, order routing, fundamentals, analyst ratings, calendars, IPO, price alerts, DCA plans, portfolio analytics and community sharelists — covering US and HK markets. Built with Rust using rmcp and axum.
Features
148 MCP tools across 19 categories: quotes, fundamentals, trading, market data, DCA, IPO, sharelists, content, alerts, screener, ATM, portfolio, macrodata, search, statements, authenticate, calendar, quant, and utility
Stateless architecture -- each request carries a Bearer token forwarded directly to the Longbridge SDK; no server-side sessions or database
OAuth 2.1 metadata — RFC 9728 protected-resource + RFC 8414 authorization-server facade; browser authorization stays direct while
token/revokepass through this server to attach Longbridge's DC routing headerJSON response transformation -- field names normalized to snake_case, timestamps converted to RFC 3339, internal counter_id values mapped to human-readable symbols
Compact tool metadata -- typed
outputSchemadescriptors stay intools/listfor compatible clients, redundant return-field prose is trimmed, and full verbose schemas are available as MCP resources underlb://tools/{tool}/output-schemaPrometheus metrics for monitoring tool calls, latency, and errors
Configurable via CLI arguments or a JSON config file (CLI takes precedence)
Related MCP server: AkTools MCP Server
Connect from an MCP client
Longbridge operates a hosted endpoint at https://mcp.longbridge.com, so most users don't need to run their own server — just point your MCP client at it and complete OAuth when prompted. Authorization is auto-discovered via RFC 9728.
Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or the equivalent on your OS:
{
"mcpServers": {
"longbridge": {
"url": "https://mcp.longbridge.com"
}
}
}Restart Claude Desktop. On first tool invocation it will open a browser to complete the Longbridge OAuth flow.
Claude Code
claude mcp add --transport http longbridge https://mcp.longbridge.comZed
Add to your Zed settings.json (open with zed: open settings):
{
"context_servers": {
"longbridge": {
"url": "https://mcp.longbridge.com"
}
}
}On first use, Zed will open a browser to complete the Longbridge OAuth flow.
Cursor / Cline / Windsurf / other MCP clients
Point the client at https://mcp.longbridge.com using transport streamable-http. OAuth is auto-discovered via RFC 9728; no manual token required.
Self-hosting
Prefer running your own instance? Use Docker or build from source.
Docker (recommended)
docker run -p 8443:8443 \
-v /path/to/certs:/certs:ro \
ghcr.io/longbridge/longbridge-mcp \
--bind 0.0.0.0:8443 \
--base-url https://mcp.example.com \
--tls-cert /certs/cert.pem \
--tls-key /certs/key.pemImportant: When deploying to a public network, you must set
--base-urlto the externally reachable URL of your server (e.g.https://mcp.example.com). This URL is returned in the OAuth protected resource metadata and used by MCP clients to discover the authorization server. If not set, it defaults tohttp://localhost:{port}which will not work for remote clients.
Build from source
cargo build --release
./target/release/longbridge-mcpConfigure
Create a config file at ~/.longbridge/mcp/config.json (optional):
{
"bind": "127.0.0.1:8000",
"base_url": "https://mcp.example.com",
"log_dir": "/var/log/longbridge-mcp"
}Configuration
Option | Config Key | CLI Flag | Default | Description |
Bind address |
|
|
| HTTP server listen address |
Base URL |
|
| auto | Public base URL for resource metadata |
Log directory |
|
| (stderr) | Directory for rolling log files |
TLS certificate |
|
| (none) | PEM certificate file for HTTPS |
TLS private key |
|
| (none) | PEM private key file for HTTPS |
CLI arguments override config file values. The config file is read from ~/.longbridge/mcp/config.json (override with LONGBRIDGE_MCP_CONFIG_DIR).
When tls_cert and tls_key are both set, the server runs HTTPS. Otherwise it falls back to HTTP. The base_url defaults to https://localhost:{port} with TLS or http://localhost:{port} without.
Environment Variables
These are advanced settings — most users do not need to change them. They are primarily useful for connecting to non-production Longbridge environments or debugging SDK internals.
Variable | Default | Description |
|
| Config file directory |
|
| Longbridge API base URL (also used for OAuth metadata) |
| (none) | Comma-separated hostnames accepted from the edge-injected |
| (none) | Authorization-server URL advertised to requests arriving via an allowlisted |
|
| Quote WebSocket endpoint |
|
| Trade WebSocket endpoint |
|
| Idle seconds before a cached quote WebSocket context is evicted |
|
| Maximum cached quote WebSocket contexts per server process |
| (unset) |
|
| (none) | SDK internal log path. Leave unset in production — the SDK writes unfiltered request/response bodies there (see Logging and customer data) |
Logging and customer data
MCP requests and responses carry customer data — cash balances, positions, order history — and the upstream SDK frames carry access tokens. None of it belongs in a log file, so the server enforces a cap on the log targets that would print it, independent of RUST_LOG:
Target | Cap | What it would otherwise print |
|
| OpenAPI request and full response bodies (INFO) |
|
| Every WebSocket frame, auth token included (INFO) |
|
| Order push events (INFO) |
|
| Decoded MCP requests and full tool results (DEBUG), raw JSON-RPC frames (TRACE) |
Raising verbosity is therefore safe: RUST_LOG=debug (or even trace) gives you this server's own logs without turning customer data into log lines. Two things do defeat it, both off by default:
LONGBRIDGE_MCP_LOG_PAYLOADS=1removes the caps. Use it only against a test account on a local machine.LONGBRIDGE_LOG_PATHmakes the SDK install a private subscriber that writeslongbridge*INFO events — request and response bodies included — into that directory, where this server's filter does not apply. The server logs a warning at startup when it is set.
Authentication
The server expects a Longbridge OAuth access token in the Authorization: Bearer <token> header. On missing or invalid auth, it returns 401 with a WWW-Authenticate header pointing to the protected resource metadata endpoint, which in turn directs MCP clients to the Longbridge OAuth authorization server.
Claude Code integration
The one-liner in Connect → Claude Code gets you connected. Below are the extra commands you'll reach for while developing against this server.
# Hosted — use this unless you have a reason not to
claude mcp add --transport http longbridge https://mcp.longbridge.com
# Local self-hosted instance (see Self-hosting above)
claude mcp add --transport http longbridge-local http://localhost:8000/mcp
# Inspect
claude mcp list # registered servers
claude mcp get longbridge # config + auth status of one server
claude mcp remove longbridge # unregister
# Re-trigger OAuth (e.g. after token revocation on the Longbridge side)
claude mcp logout longbridgeOn the first tool invocation, Claude Code reads the WWW-Authenticate challenge from the server, fetches /.well-known/oauth-protected-resource (RFC 9728), and opens your browser for the Longbridge OAuth flow. Access tokens are cached per-session and refreshed automatically.
API Endpoints
Method | Path | Description |
GET |
| Protected Resource Metadata (RFC 9728) |
GET |
| Authorization Server Metadata (RFC 8414); advertises direct Longbridge authorize/register and proxied token/revoke endpoints |
POST |
| OAuth token proxy; derives |
POST |
| OAuth revocation proxy; derives |
GET |
| Prometheus metrics |
POST/GET/DELETE |
| MCP Streamable HTTP endpoint (requires Bearer token) |
Tool Categories
Category | Count | Description |
Quote | 32 | Real-time and historical quotes, candlesticks, depth, brokers, options, warrants, watchlists, capital flow, market temperature, short positions, option volume |
Fundamental | 31 | Financial statements/reports, business segments, institutional views, industry peers/valuation, dividends, EPS forecasts, valuations, company info/executives, shareholders, corporate actions, operating metrics |
Trade | 15 | Order submission/cancellation/replacement, positions, balance, executions, cash flow, margin |
Market | 14 | Market status, industry/top-mover rank, broker holdings, A/H premium, trade statistics, anomalies, short trades, index constituents |
DCA | 9 | Dollar-cost averaging plan create/update/pause/resume/stop, execution history, statistics, and support check |
IPO | 7 | IPO subscriptions, calendar, listed stocks, order detail, profit/loss analysis |
Sharelist | 8 | Community sharelist CRUD, member add/remove/sort, popular lists |
Content | 6 | News, discussion topic CRUD and replies |
Alert | 5 | Price alert CRUD (add, delete, enable, disable, list) |
Screener | 5 | Stock screener search, indicators, and strategy recommendation/management |
ATM | 3 | Bank cards, withdrawal records, deposit records |
Portfolio | 3 | Exchange rates, profit/loss analysis with optional date range |
Macrodata | 2 | Macroeconomic indicator list and detail data |
Search | 2 | News search, community topic search |
Statement | 2 | Account statement listing and export |
Authenticate | 1 | OAuth authorization-code exchange for MCP-native clients that can't complete a browser redirect |
Calendar | 1 | Finance calendar events (earnings, dividends, IPOs, macro data, market closures) |
Quant | 1 | Run a quant indicator script against historical K-line data server-side |
Utility | 1 | Current UTC time |
Prometheus Metrics
Metric | Type | Description |
| Counter | Total tool invocations (label: |
| Histogram | Tool call latency (label: |
| Counter | Tool call error count (label: |
Project Structure
src/
main.rs CLI args, config loading, axum server setup
auth/
mod.rs Router composition, MCP service wiring
metadata.rs Protected Resource Metadata (RFC 9728)
middleware.rs Bearer token extraction middleware
tools/
mod.rs MCP tool definitions and ServerHandler impl
quote.rs Quote tools (SDK QuoteContext)
trade.rs Trade tools (SDK TradeContext)
fundamental.rs Fundamental data, business segments, industry peers (HTTP API)
market.rs Market data, industry rank, broker holdings, anomalies (HTTP API)
ipo.rs IPO subscriptions, calendar, orders, profit/loss (HTTP API)
search.rs News and topic search (HTTP API)
atm.rs Bank cards, withdrawals, deposits (HTTP API)
calendar.rs Finance calendar (HTTP API)
portfolio.rs Portfolio analytics (HTTP API)
dca.rs Dollar-cost averaging / recurring investment (HTTP API)
sharelist.rs Community sharelist management (HTTP API)
alert.rs Price alerts (HTTP API)
content.rs News, topics, filings (SDK ContentContext + HTTP)
statement.rs Account statements (HTTP API)
http_client.rs Shared HTTP client helpers
parse.rs Parameter parsing helpers
serialize/ JSON transformation (snake_case, timestamps, counter_id -> symbol)
counter.rs Symbol <-> counter_id bidirectional conversion (ST/ETF/IX/BK)
metrics.rs Prometheus metric definitions and /metrics handler
error.rs Unified error type (thiserror)Development
# Format
cargo +nightly fmt
# Lint
cargo clippy
# Test
cargo testLicense
See LICENSE for details.
Maintenance
Related MCP Servers
- FlicenseDqualityDmaintenanceProvides real-time stock data and AI-powered analysis for A-shares, Hong Kong stocks, and US stocks. Features sentiment analysis of financial news, deep research reports, and comprehensive market data through multiple integrated data sources.Last updated22167
- AlicenseBqualityCmaintenanceProvides comprehensive stock and cryptocurrency data analysis for A-shares, Hong Kong stocks, US stocks, and crypto markets, including price history, technical indicators, financial metrics, market overview, and real-time financial news.Last updated18390MIT
- AlicenseCqualityCmaintenanceEnables financial research and analysis through AI agents that combine web search, content crawling, entity extraction, and deep research workflows. Supports extracting stock/fund entities with security codes and conducting structured financial investigations.Last updated924Apache 2.0
- Flicense-qualityDmaintenanceProvides comprehensive stock market data across US, Hong Kong, and Chinese markets, combining real-time quotes, historical data, fundamentals, and financial statements from multiple sources including Yahoo Finance, Finnhub, Tushare, and Futu OpenAPI.Last updated
Related MCP Connectors
Real-time news with bias scoring, live market data, and AI-powered options pricing
Options analytics: 17 pricing models, 17 Greeks, GEX, IV, 23 screeners, unusual, dark pool, max pain
Access real-time and historical market data for China A-shares and Hong Kong stocks, along with ne…
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/longbridge/longbridge-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server