Longport MCP Server

A Node.js library for Longport Open API

Local serverstdioPython

What is the Longport MCP server?

Longport MCP server exists for a simple reason — assistants are far more useful when they can act on Longport directly instead of describing what you should do. A Node.js library for Longport Open API.

What you get

Longport OpenAPI provides programmatic quote trading interfaces for investors with research and development capabilities and assists them to build trading or quote strategy analysis tools based on their own investment strategies. The functions fall into the following categories:

Setting it up

Setup follows the usual MCP pattern — install or clone the server, register it in your client's configuration file, restart the client.

What the assistant can call

Once Longport is connected, these are the calls the assistant has available:

  • Trading — Create, amend, cancel orders, query today’s/past orders and transaction details, etc
  • Quotes — Real-time quotes, acquisition of historical quotes, etc
  • Portfolio — Real-time query of the account assets, positions, funds
  • Real — time subscription - Provides real-time quotes and push notifications for order status changes

Configuration and credentials

You will need 7 environment variables: LONGPORT_APP_KEY, LONGPORT_APP_SECRET, LONGPORT_ACCESS_TOKEN, LONGPORT_HTTP_URL, LONGPORT_QUOTE_WS_URL, LONGPORT_TRADE_WS_URL, LONGPORT_LOG_PATH. The server will not start without them, which is usually why the tools fail to appear on a first run. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

Before you rely on it

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • Missing credentials fail quietly in some clients — if no tools show up, check the environment block first.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the longport mcp server does with a few real requests.

Choosing this one

Among the payments and commerce options, the useful question is rarely "what can it do" but "what does it cost you to run" — permissions, credentials, and how much of your context its toolset consumes. Longport's toolset — Trading, Quotes, Portfolio and 1 more — is a fair guide to whether it matches your workflow. It is maintained by sunli829; worth a glance at recent repository activity before you build anything load-bearing on it.

SyncDev reviews every entry in this directory against the project's own documentation before publishing, and revisits them as servers change.

Available tools

ToolWhat it does
TradingCreate, amend, cancel orders, query today’s/past orders and transaction details, etc.
QuotesReal-time quotes, acquisition of historical quotes, etc.
PortfolioReal-time query of the account assets, positions, funds
Realtime subscription - Provides real-time quotes and push notifications for order status changes

Configuration

VariableDescriptionRequired
LONGPORT_APP_KEYCredential the server authenticates with.Yes
LONGPORT_APP_SECRETCredential the server authenticates with.Yes
LONGPORT_ACCESS_TOKENCredential the server authenticates with.Yes
LONGPORT_HTTP_URLEndpoint or connection string the server talks to.Yes
LONGPORT_QUOTE_WS_URLEndpoint or connection string the server talks to.Yes
LONGPORT_TRADE_WS_URLEndpoint or connection string the server talks to.Yes
LONGPORT_LOG_PATHFilesystem location the server is allowed to use.Optional

Example prompts to try

  • Use Longport to Trading.
  • Use Longport to Quotes.
  • Use Longport to Portfolio.

Frequently asked questions

It connects Longport to MCP-compatible AI assistants such as Claude and Cursor, exposing 4 tools (Trading, Quotes, Portfolio, and more) that the assistant can call on your behalf. Instead of copying data back and forth by hand, the assistant works with Longport directly.