Elyrail MCP server
@elyrail/mcp exposes the Elyrail tools to any MCP client over stdio or streamable HTTP. Each tool uses the same zod schema the library uses. Descriptions are static: no text from tokens, contracts or APIs ever appears in a tool description.
1. Write a config file#
The server reads one JSON file. Secrets are not stored in it. Each password comes from a file or an environment variable that the config names. Relative paths resolve against the config file's directory.
Read-only, testnet, no keys:
{
"version": 1,
"agentId": "agent-1",
"network": "testnet",
"stateDir": "./elyrail-state"
}With a wallet, a policy and Hyperliquid:
{
"version": 1,
"agentId": "agent-1",
"network": "testnet",
"stateDir": "./elyrail-state",
"policyFile": "./policy.json",
"wallet": { "keystoreFile": "./wallet.keystore.json", "passwordFile": "./wallet.password" },
"hyperliquid": {
"network": "testnet",
"user": "0xYourHyperliquidAccount",
"agent": { "keystoreFile": "./hl-agent.keystore.json", "passwordEnv": "ELYRAIL_HL_PASSWORD" }
},
"approval": {
"type": "webhook",
"url": "https://approvals.example.com/elyrail",
"secretFile": "./webhook.secret"
}
}Rules the server enforces when it starts:
- Every RPC endpoint must report the configured chain ID.
- The audit log's hash chain must verify.
- The policy's chain must match
network. - A wallet or Hyperliquid agent key requires a
policyFile. - Signing on mainnet requires
"acknowledgeMainnetWrites": true. - Unknown fields are rejected, so a stray
"privateKey"field is an error.
stateDir holds three files:
state.json: spend reservations, rate-limit slots and nonces.audit.jsonl: the hash-chained audit log.KILL: the kill switch. Creating this file halts all signing.
Check a config without starting the server:
npx -y @elyrail/mcp --config /absolute/path/to/elyrail.json --check2. Add it to a client#
Claude Desktop#
Add this to claude_desktop_config.json. On macOS the file is ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows it is %APPDATA%\Claude\claude_desktop_config.json. Then quit Claude Desktop completely and start it again.
{
"mcpServers": {
"elyrail": {
"command": "npx",
"args": ["-y", "@elyrail/mcp", "--config", "/absolute/path/to/elyrail.json"]
}
}
}Claude Code#
For the current project only:
claude mcp add --transport stdio --scope local elyrail -- npx -y @elyrail/mcp --config /absolute/path/to/elyrail.jsonUse --scope project to write it to .mcp.json for the whole repository, or --scope user for every project. Check it with claude mcp list. Remove it with claude mcp remove elyrail.
Cursor#
Add this to .cursor/mcp.json in a project, or to ~/.cursor/mcp.json for every project:
{
"mcpServers": {
"elyrail": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@elyrail/mcp", "--config", "/absolute/path/to/elyrail.json"]
}
}
}Other MCP clients#
Start the server over stdio with:
- command:
npx - args:
["-y", "@elyrail/mcp", "--config", "/absolute/path/to/elyrail.json"]
3. Streamable HTTP#
Set a bearer token of at least 32 characters, then start the server with --http:
export ELYRAIL_MCP_TOKEN="$(openssl rand -hex 32)"npx -y @elyrail/mcp --config /absolute/path/to/elyrail.json --httpThe server listens on http://127.0.0.1:8787/mcp. It binds to loopback only; for remote access, put a TLS proxy in front of it.
- Every request must carry
Authorization: Bearer <token>. Hostmust be a loopback address on the configured port.- A request that sends
Originmust use an origin listed inhttp.allowedOrigins.
Claude Code:
claude mcp add --transport http elyrail http://127.0.0.1:8787/mcp --header "Authorization: Bearer $ELYRAIL_MCP_TOKEN"Cursor (it reads ${env:NAME} inside headers):
{
"mcpServers": {
"elyrail": {
"url": "http://127.0.0.1:8787/mcp",
"headers": {
"Authorization": "Bearer ${env:ELYRAIL_MCP_TOKEN}"
}
}
}
}Claude Desktop's local config file does not document HTTP servers with custom headers, so use stdio there.
What the agent sees#
Every tool result is a JSON envelope:
{
"ok": true,
"tool": "get_token_metadata",
"data": { "symbol": "USDC" },
"untrustedFields": ["name", "symbol"],
"notice": "…"
}Fields listed in untrustedFields came from outside sources. They are stripped of control, bidirectional and zero-width characters, and their length is capped.
Errors look like this:
{
"ok": false,
"tool": "transfer_native",
"error": { "code": "POLICY_DENIED", "message": "…", "details": { "reason": "RECIPIENT_NOT_ALLOWED" } }
}The server's instructions tell the agent to call describe_policy to see its limits. They also say a POLICY_DENIED result is final for the policy, so the agent should not split or retry an action to get around a cap.
Sources for the client formats (checked 2026-11-30)#
- Claude Code: https://code.claude.com/docs/en/mcp.md
- Claude Desktop: https://modelcontextprotocol.io/docs/develop/connect-local-servers.md
- Cursor: https://cursor.com/docs/context/mcp