tossinvest-openapi-mcp
This server lets an MCP client safely read Toss Securities account/market/order data and, only with explicit multi-gate opt-in, prepare and place real orders.
Check auth/config status without exposing secrets via
auth_status.Read account data:
accounts,holdings,buying_power,sellable_quantity,commissions.Read market data:
prices,orderbook,trades,price_limits,candles,stock_info,stock_warnings,exchange_rate,market_calendar.Read order data:
orders_open,orders_closed,order_detail,order_status_summary.Run safety-first workflows:
portfolio_snapshot,pre_trade_check,order_preview,order_execute,order_status_summary.Use dry-run/default-safe trading tools:
order_validate,order_create,order_modify,order_cancel.Real create/modify/cancel orders require
ENABLE_TRADING, operation-specific gates,dryRun=false, confirmation, and amount/symbol limits.order_previewnever calls Toss order POST endpoints; previews are in-memory only.order_executesubmits at most one order POST after preview/hash/confirmation/env/delegated-authority checks and reports ambiguous outcomes asunknown_execution_state.Read-only tools do not require trading gates and are safe by default.
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., "@tossinvest-openapi-mcp what are my current holdings?"
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.
tossinvest-openapi-mcp
Safe-by-default local stdio MCP server for the official Toss Securities / 토스증권 Open API.
This package is an independent developer tool and is not affiliated with, endorsed by, or sponsored by Toss Securities.
This package is designed for developers who want read-only account, market, and order data in an MCP client, with optional order operations protected by multiple explicit safety gates.
Safety defaults
Uses only the official Toss Open API server:
https://openapi.tossinvest.comStarts without credentials;
auth_statusreports missing configuration instead of crashing.Keeps OAuth access tokens in memory only.
On eligible GET
401 invalid-tokenor401 token-revokedresponses, replaces the affected cached token and retries once; concurrent issuance is shared within a client instance.auth_statusseparates token issuance from data endpoint reachability and reports whether a defaultTOSS_ACCOUNT_SEQis configured.Redacts API keys, secrets, bearer tokens, account headers, and account numbers from tool output/errors.
Trading is disabled by default.
v0.2 workflow tools are safety-first and preview-based:
portfolio_snapshot → pre_trade_check → order_preview → approval → order_execute → order_status_summary.order_previewstores preview contracts in memory only and never calls Toss order POST endpoints.order_executeis intentionally fast: it rechecks only preview/confirmation/hash/env/delegated-authority gates, submits at most one order POST, and reports timeout/network ambiguity asunknown_execution_statefor reconciliation before any manual retry.Order tools default to
dryRun=true.Real create/modify/cancel operations require
ENABLE_TRADING=trueplus the operation-specific gate.Confirmation is required by default.
Default max order amounts are
0KRW and0USD.BLOCKED_SYMBOLStakes precedence overALLOWED_SYMBOLS.
Related MCP server: tossinvest-mcp
Install and run
This repository is currently distributed from GitHub source only. It has not been published to npm under an EthanKlocked-owned package.
Important: the unscoped npm name tossinvest-openapi-mcp is already used by a different npm package, so do not install or run that package expecting this repository's code.
Clone this repository, then install and build locally:
git clone https://github.com/EthanKlocked/tossinvest-openapi-mcp.git
cd tossinvest-openapi-mcp
npm install
npm run build
npm testRun locally:
TOSS_API_KEY=... TOSS_SECRET_KEY=... node dist/index.jsDo not put real secrets in committed files. Prefer passing env vars from your local shell or MCP client secret manager.
MCP client configuration example
Use the local cloned path:
{
"mcpServers": {
"tossinvest": {
"command": "node",
"args": ["/absolute/path/to/cloned/tossinvest-openapi-mcp/dist/index.js"],
"env": {
"TOSS_API_KEY": "${TOSS_API_KEY}",
"TOSS_SECRET_KEY": "${TOSS_SECRET_KEY}",
"TOSS_ACCOUNT_SEQ": "${TOSS_ACCOUNT_SEQ}"
}
}
}
}If this project is later published to npm, use a package name owned by the maintainer, such as @ethanklocked/tossinvest-openapi-mcp, rather than the already-taken unscoped name.
Environment variables
Name | Default | Purpose |
| unset | Toss Open API client id / API key. |
| unset | Toss Open API client secret. |
| unset | Optional default account sequence for account-scoped tools. |
|
| Global gate for any real order operation. |
|
| Gate for real order create. |
|
| Gate for real order modify. |
|
| Gate for real order cancel. |
|
| Requires exact confirmation text for real order operations. |
|
| Maximum allowed calculated KRW order amount. |
|
| Maximum allowed calculated USD order amount. |
| unset | Optional comma-separated allow list. |
| unset | Optional comma-separated block list; always wins over allow list. |
|
| Timeout for OAuth, read-only, and order requests. Set |
Confirmation text for real order operations:
I understand this may place a real Toss Securities orderTools
Read-only tools:
auth_statusaccountsholdingspricesorderbooktradesprice_limitscandlesstock_infostock_warningsexchange_ratemarket_calendarorders_openorders_closedorder_detailbuying_powersellable_quantitycommissions
Workflow tools:
portfolio_snapshot— reads holdings, KRW/USD buying power, open orders, calculable position weights, account/accountSeq state, warning flags, and partial failures. Position weights use a KRW-converted, cash-inclusive denominator (holdings + KRW/USD cash buying power); whencashStatusispartial, omitted cash currencies are listed inomittedCashCurrencies.pre_trade_check— separate read/check layer for candidate orders; returnscanProceedDryRun,realOrderBlockedByDefault,checks,warnings,blockers,missing,estimate, anddataFreshness.order_preview— creates an in-memory preview contract; returnspreviewId,requestHash,ttlSeconds,expiresAt, exactconfirmationText, estimated amount/fee/cash/quantity checks, gate status, risk flags, and calculability notes. It never calls order POST endpoints. Default TTL: 90 seconds; max accepted TTL: 300 seconds.order_execute— fast preview-based submission; requirespreviewId, matchingrequestHash, exact confirmation (I approve this exact Toss order preview), unexpired preview, env gates, and optional delegated-authority bounds. It does not runpre_trade_checkin the hot path and does not add automatic order POST retry.order_status_summary— read-only reconciliation summary for open/recently closed orders, state counts, filled/partial/canceled/rejected/replace-related states when present, and caveats for disappeared/replaced orders.
Trading tools:
order_validate— checks local gates only and never calls Toss order POST endpoints.order_create— defaults to dry-run; real execution requires all create gates.order_modify— defaults to dry-run; real execution requires all modify gates.order_cancel— defaults to dry-run; real execution requires all cancel gates. WhenALLOWED_SYMBOLSorBLOCKED_SYMBOLSis configured, real cancellation also requires caller-suppliedrequest.symbolso local symbol policy can be evaluated before the POST. The server does not fetch order details before cancel because this would add a second API dependency and the official detail payload shape should be confirmed by users with live credentials before relying on it for safety.
Auth status and account selection
auth_status intentionally separates OAuth token issuance from actual data API reachability:
configured: required credential environment variables are present.tokenAvailable:POST /oauth2/tokensucceeded.dataApiReachable: a real read-only data check againstGET /api/v1/accountssucceeded.authenticated:trueonly when both token issuance and the data endpoint check succeed.accountSeqConfigured:truewhenTOSS_ACCOUNT_SEQis set.accountSeqRequiredForAccountTools:true; account-scoped tools need either a per-callaccountSeqorTOSS_ACCOUNT_SEQ.
Most market-data tools such as prices, orderbook, trades, and stock_info do not require accountSeq. Account-scoped tools such as holdings, orders_open, orders_closed, order_detail, buying_power, sellable_quantity, commissions, and real/dry-run order tools require accountSeq via the tool arguments or TOSS_ACCOUNT_SEQ.
Token recovery and diagnostics
Token recovery matches exact structured code or error.code values (invalid-token, token-revoked) on HTTP 401 only. When present, error.code takes precedence even if unrelated or conflicting; the top-level code is used only when the nested code is absent (for example, an error object containing only message). Messages, arbitrary nested strings, and unrelated 401 errors do not trigger issuance. GET requests permit at most one authentication retry; a second rejection is returned as an API error. Existing POST invalid-token retry behavior is preserved, but POST token-revoked is never replayed. The internal retryInvalidToken: false option disables both authentication recovery codes, including order execution paths that already opt out. Ambiguous order outcomes still require reconciliation, not automatic replay.
Tokens remain memory-only, using expires_in with the existing 30-second expiry margin (and existing 60-second minimum lifetime / 3600-second default). Concurrent cold starts and refreshes share one in-flight issuance per client instance. Cache generations use object identity, so a late rejection cannot discard a newer generation even if the provider returns the same token string. This does not coordinate separate processes or external clients. There is no periodic issuance or refresh-token grant.
auth_status adds tokenLifecycle when credentials are configured: a snapshot of the latest issuance attempt, not proof of data API acceptance. Existing status fields remain; use dataApiReachable / dataApiCheck to check data access, including repeated token rejection.
reason:cold-cache,expiry-margin,invalid-token, ortoken-revoked.startedAt,completedAt,expiresAt: Unix epoch milliseconds; completion/expiry can benullwhile pending or when unavailable.durationMs: elapsed issuance milliseconds, ornullwhile pending.outcome:pending,succeeded, orfailed.
Diagnostics contain only these fixed categories and timing values, never tokens, credentials, headers, provider bodies, or raw network messages. Issuance failures return a safe actionable configuration/network error; a later request can try issuance again. No new environment variables or required tool arguments are introduced.
After updating source, run npm run build and restart the MCP subprocess to load the new build. Deployment and read-only verification in the consuming environment are separate operator steps; source tests do not prove that runtime has been upgraded.
Endpoint mapping
Tool | Method/path | Side effect |
|
| Token/data reachability check only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
|
| Read-only |
| Composes | Read-only workflow snapshot |
| Composes market calendar, warnings, price limits, buying power/sellable quantity, commissions, and open orders | Read/check only; no order POST |
| Local preview contract plus read/check calls | No Toss order POST; memory-only preview storage |
|
| At most one order POST; no automatic order POST retry |
|
| Read-only reconciliation |
| Local gate evaluation only | No Toss order POST |
|
| Real order only after all gates pass |
|
| Real order modification only after all gates pass |
|
| Real order cancellation only after all gates pass |
v0.2 workflow examples
Recommended safety-first flow:
portfolio_snapshot → pre_trade_check → order_preview → user/delegated approval → order_execute → order_status_summaryMarket calendar checks are routed by request market:
currency=KRWor a six-digit Korean stock symbol usesmarket_calendar(KR).US tickers /
currency=USDusemarket_calendar(US).US non-business days are detected from the official calendar shape when
result.today.dayMarket,preMarket,regularMarket, andafterMarketare allnull.KR non-business days are detected when
result.today.integratedisnull.In those cases
pre_trade_checkandorder_previewreturn amarket_closed_non_business_dayblocker withmarket,date, andnextBusinessDay; they do not reportmarket_open_unknowninmissing.
portfolio_snapshot example:
{
"accountSeq": 1,
"currencies": ["KRW", "USD"],
"limit": 50
}pre_trade_check example. This is a separate read/check tool and is intentionally not forced into order_execute's hot path:
{
"accountSeq": 1,
"request": {
"symbol": "005930",
"side": "BUY",
"orderType": "LIMIT",
"quantity": "1",
"price": "70000",
"currency": "KRW"
},
"delegatedAuthority": {
"remainingAmount": 100000,
"expiresAt": "2026-07-05T15:00:00.000Z"
}
}order_preview example. It never calls Toss order POST endpoints and returns previewId, requestHash, TTL, and exact confirmation text:
{
"accountSeq": 1,
"ttlSeconds": 90,
"request": {
"symbol": "005930",
"side": "BUY",
"orderType": "LIMIT",
"quantity": "1",
"price": "70000",
"currency": "KRW"
}
}order_execute example. Copy the previewId, requestHash, and exact confirmationText from the preview response:
{
"previewId": "preview_...",
"requestHash": "<sha256-from-preview>",
"confirmation": "I approve this exact Toss order preview"
}If an order POST times out or returns an ambiguous network failure, order_execute returns status: "unknown_execution_state" and directs callers to reconcile with order_status_summary/order_detail before any manual retry. The server does not automatically retry order POSTs.
order_status_summary example:
{
"accountSeq": 1,
"symbol": "005930",
"limit": 50
}Trading safety examples
Dry-run validation:
{
"request": {
"symbol": "005930",
"side": "BUY",
"orderType": "LIMIT",
"quantity": "1",
"price": "70000",
"currency": "KRW"
}
}Real create requires all of the following:
ENABLE_TRADING=true
ENABLE_ORDER_CREATE=true
REQUIRE_CONFIRMATION=true
MAX_ORDER_KRW=100000
ALLOWED_SYMBOLS=005930And the tool call must include:
{
"dryRun": false,
"confirmation": "I understand this may place a real Toss Securities order",
"request": {
"symbol": "005930",
"side": "BUY",
"orderType": "LIMIT",
"quantity": "1",
"price": "70000",
"currency": "KRW"
}
}Official endpoint mapping
The implementation is intentionally thin and maps tools to official Toss Open API paths:
OAuth:
POST /oauth2/tokenMarket/account/order data:
/api/v1/...paths fromhttps://openapi.tossinvest.com/openapi-docs/latest/openapi.jsonOrder create/modify/cancel: official
/api/v1/ordersPOST paths only, guarded locally before any POST is attempted.
Development
npm install
npm test
npm run lint
npm run audit:prodThe required test suite uses Node's built-in test runner and mocked fetch calls. It does not require real Toss credentials and does not call live order endpoints.
Opt-in read-only integration smoke test
After configuring your own Toss credentials locally, you can run a safe read-only smoke test:
TOSS_API_KEY=... TOSS_SECRET_KEY=... npm run smoke:readonlyOptional account-scoped checks can use TOSS_ACCOUNT_SEQ, but the default smoke path only calls read-only tools that do not create, modify, or cancel orders: auth_status, accounts, and market_calendar. If TOSS_API_KEY or TOSS_SECRET_KEY is missing, the command exits successfully with a SKIP message and makes no Toss API request. Output is passed through the same redaction helpers used by the MCP server.
Timeout/retry policy
This server applies a configurable request timeout to OAuth, read-only calls, and order calls. GETs retain bounded transient retries: up to three for HTTP 429 and two for HTTP 502/503/504, with retry delays capped at 10 seconds. Authentication recovery is separately bounded to one retry as described above. POSTs do not receive transient retries or new token-revoked replay; existing invalid-token behavior and per-call opt-outs are unchanged. Never retry an ambiguous order outcome without reconciliation.
Release checklist
Before publishing or tagging a release:
Verify package ownership and name availability; do not publish the unscoped
tossinvest-openapi-mcpname.Run
npm test,npm run lint,npm run audit:prod, andnpm pack --dry-run.Confirm the dry-run tarball includes only runtime files (
dist/JavaScript/declarations without source maps),scripts/smoke-readonly.mjs,README.md,LICENSE,.env.example, and package metadata.Re-scan docs for secrets, account numbers, local paths, private workflow notes, or investment advice/automation claims.
Publish only after explicit maintainer approval.
Publication hygiene
.gitignoreexcludes.env,.env.*, logs, coverage,node_modules, and build output..npmignoreexcludes local env files, logs, coverage, internal handoff/QA notes, and local run artifacts.package.jsonfilesonly publishesdist, public docs,.env.example, and changelog/security/license files.
Disclaimer
This software is not investment advice and does not implement trading strategy, rebalancing, optimization, or automated trading loops. Order tools can place real financial orders only when explicitly enabled and used with valid Toss credentials; use at your own risk.
Available Tools
27 toolsaccountsA
List Toss Securities accounts. Account numbers are masked.
Inputs: no named parameters.
auth_statusA
Check Toss API credential configuration and token status without returning secrets.
Inputs: no named parameters.
buying_powerC
Read buying power for an account and currency.
Inputs: currency (required), accountSeq.
candlesD
Read candles for a symbol.
Inputs: symbol (required), interval (required), count, before, +1 more.
commissionsC
Read official Toss account commission rates.
Inputs: accountSeq.
exchange_rateC
Read exchange rate from official Toss API.
Inputs: baseCurrency (required), quoteCurrency (required), dateTime.
holdingsC
Read holdings for an account using X-Tossinvest-Account.
Inputs: symbol, accountSeq.
market_calendarC
Read KR or US market calendar.
Inputs: date, market.
orderbookC
Read orderbook for a symbol.
Inputs: symbol (required).
order_cancelA
Cancel an order. Default dry-run; real execution requires ENABLE_TRADING, ENABLE_ORDER_CANCEL, dryRun=false, confirmation, and caller-supplied request.symbol when symbol allow/block policy is configured.
Inputs: orderId (required), dryRun, request, accountSeq, +1 more.
order_createA
Create an order. Default dry-run; real execution requires ENABLE_TRADING, ENABLE_ORDER_CREATE, dryRun=false, confirmation, amount, and symbol gates.
Inputs: request (required), dryRun, accountSeq, confirmation.
order_detailC
Read one order detail for an account.
Inputs: orderId (required), accountSeq.
order_executeB
Fast preview-based order execution. Requires valid unexpired previewId, matching requestHash, exact confirmation, and passing env/delegated-authority gates. No automatic order POST retry.
Inputs: previewId (required), requestHash (required), confirmation (required), delegatedAuthority.
order_modifyA
Modify an order. Default dry-run; real execution requires ENABLE_TRADING, ENABLE_ORDER_MODIFY, dryRun=false, confirmation, and applicable gates.
Inputs: orderId (required), request (required), dryRun, accountSeq, +1 more.
order_previewB
Create an in-memory preview contract for an order. Never calls Toss order POST endpoints. order_execute confirmation text: I approve this exact Toss order preview
Inputs: request (required), date, accountSeq, ttlSeconds, +1 more.
orders_closedB
Read closed orders for an account if supported by Toss API.
Inputs: to, from, limit, cursor, +2 more.
orders_openC
Read open orders for an account.
Inputs: limit, symbol, accountSeq.
order_status_summaryC
Read-only order reconciliation summary for open and recently closed orders, state counts, and replace/modify caveats.
Inputs: to, from, limit, cursor, +2 more.
order_validateC
Validate order safety gates only. Never calls Toss order POST endpoints. Confirmation text: I understand this may place a real Toss Securities order
Inputs: request (required), dryRun, operation, confirmation.
portfolio_snapshotA
Read a structured account snapshot: holdings, KRW/USD buying power, open orders, calculable position weights, warning flags, and partial failures. Position weights use a KRW-converted, cash-inclusive denominator (holdings + KRW/USD cash buying power); when cashStatus is 'partial', omitted cash currencies are listed in omittedCashCurrencies. If status is 'partial', do not trust holdings.count as a complete account position count; retry or use a fallback read path.
Inputs: limit, accountSeq, currencies.
pre_trade_checkB
Run separate pre-execution safety/reality checks for a candidate order. Read/check only; not required in order_execute hot path.
Inputs: request (required), date, accountSeq, delegatedAuthority.
price_limitsB
Read upper/lower price limits for a symbol.
Inputs: symbol (required).
pricesA
Read current prices for comma-separated symbols.
Inputs: symbols (required).
sellable_quantityC
Read sellable quantity for an account and symbol.
Inputs: symbol (required), accountSeq.
stock_infoC
Read basic stock info for comma-separated symbols.
Inputs: symbols (required).
stock_warningsC
Read buy-warning information for a stock.
Inputs: symbol (required).
tradesC
Read recent trades for a symbol.
Inputs: symbol (required), count.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 27 tools
Many tools related to orders (e.g., orders_open, orders_closed, order_detail, order_validate, order_preview, order_execute, order_create, order_modify, order_cancel) have similar purposes but descriptions help distinguish them. Some overlap exists, such as between order_validate and order_preview, but they are not identical.
All tool names use lowercase with underscores, but they are not strictly verb_noun; many are noun phrases (e.g., stock_info, exchange_rate, portfolio_snapshot) or adjective_noun (e.g., orders_open, orders_closed). The pattern is consistent in structure, though not perfectly verb_noun.
With 27 tools, the server is on the upper end of a reasonable range. While a trading platform may require many tools, some could be combined (e.g., orders_open and orders_closed into one with a parameter) to reduce count without loss of functionality.
The tool surface covers market data, account information, order management, and safety checks comprehensively. Minor gaps exist, such as no explicit tool for deposit/withdrawal history, but core trading workflows are well-supported.
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
JW3.ai remote MCP server for market reads and confirm-gated trading execution.
Open-source MCP server for Zerodha Kite Connect. Portfolio, market data, backtesting, alerts.
MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server wrapping Toss Securities Open API, enabling stock price queries and trading for Korean and US stocks via natural language.36265 npmMIT
- AlicenseAqualityBmaintenanceToss Securities (토스증권) Open API MCP server for the Korean stock market. Supports real-time quotes, orderbook, candles, account holdings, buying power, and order management (create/modify/cancel) with a built-in safety gate requiring explicit confirmation before any real order is placed.36259 npm4MIT
- AlicenseAqualityDmaintenanceA local MCP server that automatically generates tools from Toss Securities' official OpenAPI spec, enabling real API calls with multi-layered order safety and OAuth 2.0 authentication.361MIT
- AlicenseAqualityDmaintenanceMCP server for Toss Securities Open API that exposes Korean (KRX) and US market data, portfolio holdings, order management, and conditional orders through 28 tools, with read-only and authenticated remote modes.28MIT