SuperAPI AI Directory

longbridge-mcp

🎖️ 🦀 ☁️ - Longbridge brokerage: US and HK real-time quotes, options, trading, fundamentals, analyst ratings, calendars, price alerts, DCA plans and portfolio analytics.

Open website

About this tool

Longbridge MCP Server is the official MCP server provided by Longbridge Securities, used to connect Longbridge broker capabilities to AI clients that support MCP. The project is written in Rust, based on rmcp and axum, and covers the U.S. and Hong Kong markets.

Purpose

The server is designed to let MCP clients access market data and account features in natural language. According to the official description, it has been officially listed in the ChatGPT Apps directory and the Claude Connectors directory, allowing users to query quotes, options, fundamentals, and their own investment portfolios in ordinary language, without editing configuration files or pasting tokens.

Main capabilities

The server provides 164 tools, covering real-time quotes, options, order routing, fundamentals, analyst ratings, financial calendars, IPOs, price alerts, dollar-cost averaging plans, grid trading, portfolio analysis, and community stock lists. The official description includes twenty categories in total, spanning market data, trading, research, and account management. Data covers the U.S. and Hong Kong markets.

Each tool supports an optional parameter _jq, used to apply jq-compatible filtering to the complete returned JSON; the expression runs after the response is normally serialized. The _jq name is reserved for response filtering to avoid conflicts with business parameters. Usage instructions are sent once in the instructions of the MCP initialize response; each tool's schema only declares the name and type of this optional parameter. For example, .data[:5] can be used to take the first five items of the data array, .data | map(select(.price > 10)) to filter rows, and {total: .total} to project fields. Expressions use jq-compatible syntax with the embedded jaq engine, so jq does not need to be installed separately. Omitting _jq or passing null preserves the original response. A single value is returned directly, multiple values are returned as an array, and no value returns []. Scalars and arrays are JSON text, and objects also appear in structuredContent, containing only the filtered fields. Plain text responses are provided as JSON strings. When there are multiple content blocks and no structured content, they are provided as an array. Tool errors and permission/no-data descriptions remain unfiltered. Empty, invalid, or non-string expressions are rejected before the tool runs. If runtime filtering fails, the response clearly states that the tool has been executed, and write operations such as placing orders should not be automatically retried. Environment access, filesystem imports, and log filtering are unavailable. The output limit is 10,000 values and 8 MiB; exceeding it returns an error rather than partial results. Because filtering changes the response shape, tools do not declare a fixed outputSchema; the original typed schema is still available via resources/list and resources/read at lb://tools/{tool-name}/output-schema.

Usage

The official hosted endpoint is https://mcp.longbridge.com,可将任意 Point the MCP client to this address and complete OAuth when prompted. Authorization is automatically discovered via RFC 9728, with no need to paste tokens. Claude Desktop requires adding it to claude_desktop_config.json and then restarting; clients such as Cursor, Cline, Windsurf, and Zed should point to https://mcp.longbridge.com and use the streamable-http transport. On first use, the client reads the WWW-Authenticate challenge, fetches /.well-known/oauth-protected-resource (RFC 9728), and opens a browser to complete the Longbridge OAuth flow; tokens are cached per session and refreshed automatically.

For self-hosting, you can run the published image and set --base-url to an externally accessible URL (used in OAuth metadata for clients to discover the authorization server; the default http://localhost:{port} remote clients cannot use it). You can also build from source: cargo build --release && ./target/release/longbridge-mcp. Configuration is at ~/.longbridge/mcp/config.json; the directory can be overridden with LONGBRIDGE_MCP_CONFIG_DIR, and CLI flags take precedence. When tls_cert and tls_key are both set, the server runs HTTPS; otherwise it runs HTTP; base_url defaults to https://localhost:{port},无 under TLS, defaults to http://localhost:{port}。中国大陆环境不是标志,而是在设置 When LONGBRIDGE_REGION=cn, it is selected automatically (using the same variable as the SDK), so mainland clusters do not need to set it specifically. Upstream endpoints are fixed by the selected environment; Canary uses the -global gateway rather than openapi.longbridge.xyz because only the former is fronted by CloudFront and performs x-dc-region data center routing, and the server relies on it to serve us_ and ap_ prefixed credentials from a single process. Canary and the mainland environment fix all the above URLs at startup; in production, except when using us_ credentials and there is no upstream override to fix to the global .com gateway, resolution is left to the SDK itself, and the specific selection rules are in src/endpoints.rs.

The server expects a Longbridge OAuth access token to be passed in Authorization: Bearer <token>. If it is missing or invalid, it returns 401 with a WWW-Authenticate header pointing to the protected resource metadata, guiding the client to the Longbridge OAuth authorization server. Sending x-papertrading: true (or 1) in the request allows running against the paper trading environment; the upstream will reject paper trading requests made with real-money tokens, so this header is a safeguard rather than a routing switch, and can only narrow token permissions. LONGBRIDGE_PAPERTRADING=true enables it for the entire deployment.

Security and limits

The official documentation states that this server is designed to be stateless: each request forwards the Bearer token directly to the Longbridge SDK, with no sessions, no database, and nothing stored server-side. It uses OAuth 2.1 with automatic discovery, supports RFC 9728 protected resource and RFC 8414 authorization server metadata, and lets clients complete the flow without pasting a token. Responses are in a clearly typed format: snake_case fields, RFC 3339 timestamps, human-readable codes, and typed response schemas in MCP resources.

MCP requests and responses carry customer data (cash balances, positions, order history), and upstream SDK frames carry access tokens, so the server restricts log targets that could print these contents, regardless of RUST_LOG. Increasing verbosity is safe: RUST_LOG=debug (or trace) provides the server's own logs without leaking customer data. Two switches can breakthis protection, and both are off by default: LONGBRIDGE_MCP_LOG_PAYLOADS=1 (removes the restriction, for use only with local test accounts) and LONGBRIDGE_LOG_PATH (causes the SDK to write unfiltered response bodies to that directory; when set, the server warns at startup).

For monitoring, Prometheus metrics are provided: mcp_tool_calls_total (counter), mcp_tool_call_duration_seconds (histogram), and mcp_tool_call_errors_total (counter), all labeled by tool_name. The project is released under the MIT license. Pricing, the specific tool list, and more usage details are not yet available.