Copy-paste-ready AI agent examples using @traderouter/trade-router-mcp — non-custodial Solana trading via the Model Context Protocol. Every example here uses the same 1-line install:
npx -y @traderouter/trade-router-mcpEach example is self-contained, MIT licensed, and ships with a TRADEROUTER_DRY_RUN=true mode so you can run it end-to-end without touching mainnet.
| Folder | What it does | Difficulty |
|---|---|---|
01-instant-swap |
Smallest possible agent: prompt → swap on multi-DEX with Jito MEV protection | beginner |
02-dca-bot |
Buy a fixed SOL amount of a token every N hours via TWAP order | beginner |
03-trailing-stop |
Place a trailing-stop sell to lock in gains as price climbs | intermediate |
04-mcap-trigger |
Watch a memecoin and limit-buy when its market cap drops below a target | intermediate |
05-combo-take-profit |
Limit-then-trailing-then-TWAP: enter at target mcap, ride the trend, exit gradually | advanced |
08-helius-trade-router-combo |
Helius for reads (DAS API token discovery) + Trade Router for writes (auto-take-profit on largest position) — the canonical pairing | intermediate |
09-pumpfun-graduation-sniper |
Watch a Pump.fun token, fire a MEV-protected limit buy the moment it graduates to PumpSwap/Raydium | intermediate |
The MCP server works in any framework that supports MCP. Configuration only — no custom code:
| Folder | Framework | Adapter |
|---|---|---|
06-elizaos-agent |
ElizaOS (90+ official plugins on Solana) | @fleek-platform/eliza-plugin-mcp — generic MCP-client for ElizaOS |
07-langchain-agent |
LangChain (Python + TypeScript) | langchain-mcp-adapters — official LangChain MCP integration |
Solana Agent Kit (SAK): SAK's
adapter-mcppackage wraps SAK into an MCP server (the inverse of what we need). For SAK agents that want to use Trade Router, the cleanest path is direct REST (api.traderouter.ai/swap+/protect) per our OpenAPI spec, or wrap the MCP server in any of the generic Node MCP clients (e.g.@modelcontextprotocol/sdk'sClientclass) and feed the tool list to your SAK agent's tool array. We're documenting an SAK example more fully in a future release.
Claude Desktop / Cursor / Cline / any MCP client: Just paste the
mcpServers.traderouterblock from any example'sconfig.example.jsoninto your client's MCP config file. No framework needed.
- A dedicated trading wallet (use a fresh one — see SECURITY.md on the main repo)
- The base58 private key in your env:
export TRADEROUTER_PRIVATE_KEY=<base58> - Recommended for first runs:
export TRADEROUTER_DRY_RUN=true— every write tool returns{ dry_run: true, ... }instead of submitting real transactions
Each NN-name/ folder has:
README.md— what the agent does, when to use it, expected behavioragent.ts(oragent.py) — minimal runnable codeconfig.example.json— Claude Desktop / Cursor / Cline config for the MCP server alongside the agent.env.example— the env vars you need
The MCP server itself does the heavy lifting (multi-DEX routing, Jito bundling, signing, Ed25519 verification). The cookbook code is the strategy layered on top.
They're the patterns we've seen agent builders ask about most often. Each one demonstrates a different feature of the MCP server's 21 tools:
01—auto_swap(swap → sign → /protect in one call)02—place_twap_order(server-monitored time-weighted execution)03—place_trailing_order(trailing percentage)04—place_limit_ordertriggered byget_mcappolling05—place_limit_trailing_twap_order(the full combo, 11-field params_hash)08—get_holdingsindirectly via Helius +auto_swap(production read/write split pattern)09—place_limit_orderwithtrigger_type: "mcap"+connect_websocket+get_fill_logfor verified callbacks
All run unmodified against npx -y @traderouter/trade-router-mcp@latest.
Built something cool with TradeRouter? Open a PR adding it to this cookbook. Strong preference for examples that:
- Run in under 30 lines of code
- Use
TRADEROUTER_DRY_RUN=trueby default in.env.example - Document risks and slippage assumptions
- Show real-world output from a test wallet (devnet acceptable for screenshots)
- MCP server:
@traderouter/trade-router-mcp - API docs: traderouter.ai
- Threat model: SECURITY.md
- MCP Registry:
ai.traderouter/trade-router-mcp - Glama listing: glama.ai/mcp/servers/TradeRouter/trade-router-mcp
MIT. See LICENSE.