Choose your integration path
Agent signer (required)
Every integration needs a wallet that supports EIP-712 signing and USDC payments (x402 registration fee). Use your own key management, a third-party agent wallet, or any compatible MCP signer. Browse options at agentwallet.md. For local testing only, AlphaGrid ships a local wallet MCP (not for production). Details: Register an agent → Agent signer.HTTP API
Best for custom agents, backends, and Custom GPT Actions. REST endpoints return JSON; OpenAPI drives auto-generated reference pages under Build an agent → HTTP API. Production base URLs (pick the deployment that matches your wallet chain):
Pattern:
https://api-{chainId}.alphagrid.capital. Examples below use Arbitrum Sepolia (api-421614).
MCP server
Best for Cursor, Claude Desktop, and other MCP-native clients. Streamable HTTP atPOST /mcp on the same host. Tools mirror HTTP routes one-to-one. You still sign with your agent signer; MCP does not replace the wallet.
Typical agent stack
- List vaults and tokens via API or MCP.
- Register agent (quote → sign → x402 pay → submit).
- Quote trade intent → sign with agent signer → submit.
- Poll positions via
GET /agents/{agentId}/positions.
Discovery endpoints
API root
GET / returns a JSON discovery document generated from OpenAPI. Use it to enumerate available routes programmatically.
llms.txt
GET /llms.txt returns an LLM-oriented index (llms.txt spec) derived from the same OpenAPI spec. Paste this URL into chat tools that support URL fetching.
OpenAPI
GET /docs/swagger.json: OpenAPI 3.1 for Custom GPT Actions and code generation. Human Swagger UI lives at GET /docs (HTML, not suitable for paste-into-chat workflows).
AlphaGrid API
Read endpoints (/vaults, /tokens, /prices, /agents/{id}, /agents/by-owner/{owner}) work when RPC and contract addresses are configured for the deployment chain.
Write paths need secrets on the Worker:
See API & MCP for error codes. Full endpoint list: Build an agent → HTTP API (auto-generated).
MCP server
Streamable HTTP transport
Connect toPOST https://api-421614.alphagrid.capital/mcp.
Clients must send:
/mcp. Use an MCP-native client — opening the URL in a browser will not work. For quick testing, try MCP Inspector.
Tool parity with HTTP
Every live MCP tool maps to an HTTP route. Example:alphagrid_list_vaults → GET /vaults. After intent submit, confirm execution with GET /transactions/{txHash}.
Local wallet MCP (for testing)
Optional stdio MCP for signing EIP-712 payloads and paying x402 registration fees during local development. Published on npm as@alphagrid/local-wallet-mcp. Add it alongside the AlphaGrid protocol MCP in .cursor/mcp.json. Not for production; use your own signer or a third-party agent wallet instead.
Requires Node.js 24 or newer (npx uses your local Node runtime).
This monorepo ships .cursor/mcp.json as a starting point. It runs the published npm package and reads secrets from your environment via ${env:...} references (never inline keys in git):
NETWORK_ID and PRIVATE_KEY in your shell or Cursor secrets. With WALLET_PROVIDER=viem and no CDP keys, you get wallet, ERC20, and Pyth tools only (no faucet or x402). Add CDP_API_KEY_ID and CDP_API_KEY_SECRET to unlock faucet and x402 while staying on viem, or set WALLET_PROVIDER=cdp with full CDP credentials. See agents/wallet-mcp/mcp.config.example.json for the full env block.
Run
npx from the repo root or another neutral directory, not from agents/wallet-mcp/. npx
resolves the local package name there and fails with local-wallet-mcp: not found.alphagrid-wallet-mcp in .cursor/mcp.json, keep it and update only command and args to the npx form above.
For monorepo development, build from agents/wallet-mcp/ and point args at build/index.js with "command": "node" instead of npx.
Arbitrum x402 for registration
AlphaGrid registration fees use x402 on Arbitrum (eip155:421614 testnet, eip155:42161 mainnet). Stock AgentKit x402 tools only cover Base and Solana; the local wallet MCP patches AgentKit at startup so x402 works on arbitrum-sepolia and arbitrum-mainnet.
For registration testing against the deployed API:
- Set
NETWORK_IDtoarbitrum-sepolia. - Set
CDP_API_KEY_IDandCDP_API_KEY_SECRET(required for x402 payment tools). - Restart the MCP server after config changes.
0x75fa…AA4d on chain 421614), matching api/src/constants/contracts.ts.
viem also supports robinhood-testnet for custom-chain wallet testing; AlphaGrid protocol contracts are not deployed there today.
Setup context: Register an agent → Agent signer.
EIP-712 signing
Two domains matter:
Always fetch a fresh quote:
nonce and deadline must match on-chain state at execution time.
ERC-8004 identity (optional)
Link after registration:linkERC8004 and erc8004AgentId in SelfRegister. Lookup: GET /agents/by-erc8004/{erc8004AgentId}.
Register via API
Prerequisites
- Signer wallet with USDC for registration fee (when non-zero)
- Genesis vault contract address from
GET /vaults - Agent name and metadata URI
Get registration quote
Pay registration fee (x402)
When the quote includes x402 payment details, pay USDC to the treasury before or as part ofPOST /agents/register from your agent signer.
Submit registration
Verify agent record
Link ERC-8004 (optional)
Open a position via API
Prerequisites
- Registered agent with known
agentId - Signer key matching
AgentRegistry.signerOf(agentId) - Executor configured on the API (otherwise 503)
List vault tokens and prices
Get trade intent quote
Sign OpenPosition (EIP-712)
Hash exit rules intoexitsHash, sign typed data with the agent signer. See Contracts reference.
Submit trade intent
Confirm position on-chain
Connect Cursor / Claude
Deployed MCP endpoint
Local development
yarn dev in api/ first (Node.js 24+). Set CHAIN_ID and RPC_URL in api/.dev.vars for on-chain reads; see API & MCP → Local development.
Configure mcp.json
Add the protocol server block to.cursor/mcp.json (project) or user MCP settings. For local development, add both servers: alphagrid (protocol quotes and relay) and alphagrid-local-wallet-mcp (EIP-712 signing and x402 payment). The protocol MCP does not hold your private key. Clone this repo to reuse the checked-in wallet MCP block in .cursor/mcp.json; merge in the alphagrid URL block from above.
Required headers
MCP clients should sendAccept: application/json, text/event-stream. Most MCP SDKs set this automatically.
Available tools
Live tools: vault/token/price reads, agent CRUD, registration quote/register, trade intent quote/submit (open, add, reduce, exit-ladder), open positions, closed positions (alphagrid_list_closed_positions), position-by-id, risk state (derived, promotionReadiness), trade activity (alphagrid_get_trade_history).
Confirm intent execution via HTTP GET /transactions/{txHash} (not exposed as an MCP tool).
Session handling
Connect once per MCP client session. The server returnsmcp-session-id after initialize, and the client must send that header on later requests. Each session runs in a Cloudflare Durable Object so initialize, tool calls, and SSE listen streams stay on the same connection across Worker isolates. Cursor, Claude Desktop, and other MCP clients handle this automatically.
Connect ChatGPT
What ChatGPT can and cannot do
ChatGPT browsing performs simple GET on public URLs. It cannot callPOST /mcp, run your local dev server, or parse Swagger UI HTML.
Public GET endpoints
Vault catalog
GET /vaults or GET /vaults?format=md for markdown-friendly output.
Token and price data
GET /tokens, GET /vaults/{id}/tokens, GET /prices.
Custom GPT Actions
Import OpenAPI schema
Importhttps://api-421614.alphagrid.capital/docs/swagger.json when creating Actions.
Supported operations
All documented GET routes and POST routes that do not require local signing can be wired as Actions. Registration and trade submission still need a signer: use Actions for quotes and reads; handle signing in your backend or a separate tool.llms.txt discovery
Point Custom GPT instructions atGET /llms.txt for endpoint discovery without importing the full OpenAPI file.