Skip to content

MCP and OpenAPI

Polygolem exposes agent-friendly read-only integration surfaces for local tooling and SDK experiments. They do not add a hosted proxy, a signing service, or any live-trading mutation path.

Safety boundary

MCP and OpenAPI v1 must not expose:

  • live order placement or cancellation;
  • private-key signing;
  • token approvals;
  • bridge withdrawals;
  • deposit-wallet relayer submission;
  • authenticated trading mutations.

Use the regular CLI and SDK safety gates for future mutating flows. The agent surfaces are for discovery, market data, public account reads, and diagnostics.

MCP stdio server

Run the minimal MCP stdio server from the repo root:

Terminal window
go run ./cmd/polygolem_mcp

List safe tools with one JSON-RPC line:

Terminal window
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' \
| go run ./cmd/polygolem_mcp

Current tool manifest:

ToolPurpose
polygolem.healthPublic API reachability check.
polygolem.discover_searchRead-only market search.
polygolem.data_positionsPublic Data API position lookup.
polygolem.orderbook_bookCLOB order book read.
polygolem.marketdata_snapshotLocal market-data tracker snapshot.

By default, cmd/polygolem_mcp exposes the manifest and rejects unconfigured execution. Embedders can wire concrete read-only SDK clients with pkg/mcp.NewServerWithHandlers or pkg/mcp.NewSDKReadOnlyHandlers.

OpenAPI spec

Print the read-only OpenAPI 3.1 document:

Terminal window
go run ./cmd/polygolem_openapi

Current paths:

PathPurpose
GET /healthAPI health.
GET /diagLocal diagnostic envelope.
GET /discover/search?q=...Public market search.
GET /data/positions?user=...Public user position reads.
GET /orderbook/{token_id}CLOB order book read.
GET /marketdata/snapshot?token_id=...Local market-data snapshot.

This is a spec artifact for local proxy/tooling experiments. Polygolem does not ship or operate a hosted proxy service.

Go embedding sketch

handlers := mcp.NewSDKReadOnlyHandlers(
mcp.HandlerConfig{Timeout: 10 * time.Second},
gamma.NewClient(""),
data.NewClient(data.Config{}),
clob.NewClient(clob.Config{}),
)
server := mcp.NewServerWithHandlers(handlers)
_ = server

For market-data snapshots, feed a marketdata.Tracker from your websocket reader and register mcp.NewMarketDataSnapshotHandler(tracker) as the polygolem.marketdata_snapshot handler.