# API, MCP & SDK

> Every programmatic way into Somnia: the JSON-RPC API for the chain, the Explorer APIs, the Somnia CLI and MCP server, and the SDKs for markets and data.

**Every programmatic way into Somnia.**

Everything the explorer shows is reachable programmatically: the chain over JSON-RPC, the explorer's own APIs, the Somnia CLI and its MCP server, and typed SDKs for markets and data.

## JSON-RPC API

Somnia exposes an RPC API compatible with the Ethereum JSON-RPC specification, so standard tooling (viem, ethers, Foundry, Hardhat) works unchanged.

- Mainnet: `https://api.infra.mainnet.somnia.network` (chain ID 5031)
- Testnet: `https://api.infra.testnet.somnia.network` (chain ID 50312)
- WebSocket endpoints at the same hosts under `/ws`

See the [JSON-RPC API reference](/developer/json-rpc-api) for every method, and [Somnia Dedicated RPC](/blockchain/rpcs/dedicated-rpc) for private, low-latency nodes reserved for your traffic (coming soon).

## Somnia MCP server

`somnia mcp`, part of the Somnia CLI, gives AI agents read tools for markets, order books, positions, oracle prices and the Explorer, and finds the CLI command for anything else. It never signs or sends a transaction. Add it to Claude Code with:

```sh
claude mcp add somnia -- npx -y @somnia-chain/cli mcp
```

See [Somnia MCP server](/build/mcp) for Codex, Cursor and other clients. For the docs themselves, point your agent at [llms.txt](https://new.docs.somnia.network/llms.txt), and at the Explorer's [llms.txt](https://new.explorer.somnia.network/llms.txt) for its pages and APIs.

## SDKs

- **Markets SDK** — create and configure venues, and trade spot, perpetual and event markets. See the [Markets SDK docs](/markets/somnia-markets).
- **Venue Kit** (coming soon) — a front-end template, venue commands and an agent skill. See [Venue Kit](/build/venue-kit).
- **Data Streams SDK** — publish and read structured onchain data streams. See the [SDK methods guide](/developer/data-streams/sdk-methods-guide).
- **Somnia CLI** — spot, binary and perp markets, SomniaLend, oracle prices and the Explorer from the command line, scriptable and CI-friendly. See [Somnia CLI](/build/cli).

---

Every page is also Markdown: append `.md` to its URL, or ask for `text/markdown`. Found something wrong, missing or confusing in these docs? Tell us: `POST /api/feedback` on this site with JSON `{"message": "…", "context": "what you were doing and what happened", "page": "…"}`, or a plain-text body. `GET /api/feedback` gives the JSON Schema. The team reads every one.
