DeFi MCP
Connect an AI assistant or IDE to Blockdaemon's DeFi APIs over the Model Context Protocol — no HTTP client code required.
Connect an AI assistant or IDE to Blockdaemon's DeFi APIs over the Model Context Protocol (MCP), so you can query balances, request swap quotes, and build transactions conversationally — without writing HTTP client code.
Who this is for
Developers of any experience level. Used an MCP server before? Skip to Quickstart. New to MCP? Start with Overview.
At a glance
https://svc.blockdaemon.com/defi/v1/mcp/httpStreamable HTTP (no stdio)
X-Api-Key header, same key as other Blockdaemon APIs
Claude Code · VS Code · Codex CLI · Cursor · Claude Desktop (via proxy)
Overview
What it is
The DeFi MCP Server exposes Blockdaemon's DeFi APIs as MCP tools. Connect your assistant to the server once, and from then on it discovers the available tools and calls them on your behalf in response to ordinary prompts.
What it solves
| Without MCP | With the DeFi MCP Server |
|---|---|
| Hand-write request builders, auth headers, and response parsers per endpoint | The client handles tool discovery and invocation |
| DeFi data lives outside your editor | Balances, quotes, and liquidity data are one prompt away |
| A separate integration per tool or IDE | One endpoint works with every MCP-compatible client |
What you can do
Balances, blocks, transactions, gas prices, contract calls
Swap quotes, swaps, liquidity pools, routes
Cross-chain routes, quotes, swaps
Pool data, deposits, borrows, repayments, user positions
Stake and unstake, rewards, APR
Vault and pool balances, deposits, withdrawals
Balances, metadata, ownership
Account abstraction, oracles, and derivatives
Note
The tool list is defined by the server and evolves over time. For the authoritative list of supported operations, see the DeFi API documentation.
Before you begin
You need three things.
1. A Blockdaemon API key
Create one in the Blockdaemon dashboard. New to Blockdaemon? Follow Get your API credentials for step-by-step instructions.
The key must have access to the DeFi product. You can reuse the key you already use for other Blockdaemon APIs — no separate MCP key is required.
2. The endpoint
https://svc.blockdaemon.com/defi/v1/mcp/httpThis is an MCP-over-HTTP endpoint using the Streamable HTTP transport. Your client connects to this single URL — there's no local process to install. Any client that supports the http (sometimes called streamable-http) transport type can connect; you don't need a Blockdaemon-specific client.
stdio is not supported
The server only speaks Streamable HTTP. Clients that only support stdio need a bridging proxy — see Claude Desktop.
3. Authentication
Every request must carry your key in an X-Api-Key header:
X-Api-Key: <YOUR_BLOCKDAEMON_API_KEY>Requests without a valid key are rejected before reaching any tool. Each client section below shows how to supply the header without hardcoding the key in a committed file.
Quickstart
Pick your client, then follow the matching section. All five point at the same endpoint.
| Client | Config file | How the header is passed |
|---|---|---|
| Claude Code | .mcp.json (project) or ~/.claude.json (user) | "type": "http" + headers |
| Visual Studio Code | .vscode/mcp.json | "type": "http" + headers with ${input:...} |
| OpenAI Codex CLI | ~/.codex/config.toml | url + env_http_headers |
| Cursor | .cursor/mcp.json (project) or ~/.cursor/mcp.json (user) | url + headers |
| Claude Desktop | claude_desktop_config.json | via the mcp-remote proxy (stdio → HTTP) |
Claude Code, VS Code, Codex CLI, and Cursor pass custom headers natively and are the better choice for authenticated or automated workflows. Claude Desktop requires a proxy.
Client setup
Each section follows the same order: prerequisites → configuration → authentication → verification → troubleshooting.
Claude Code
Prerequisites
- Claude Code installed and signed in.
Add via CLI (recommended)
Choose a scope explicitly. Without --scope, the server is added at user scope, which is easy to forget later.
# Project scope — writes .mcp.json in the repo root, shared with your team
claude mcp add --scope project --transport http blockdaemon-defi \
https://svc.blockdaemon.com/defi/v1/mcp/http \
--header "X-Api-Key: ${BLOCKDAEMON_API_KEY}"
# User scope — writes ~/.claude.json, available in all your projects
claude mcp add --scope user --transport http blockdaemon-defi \
https://svc.blockdaemon.com/defi/v1/mcp/http \
--header "X-Api-Key: ${BLOCKDAEMON_API_KEY}"Or configure by hand
.mcp.json in the project root:
{
"mcpServers": {
"blockdaemon-defi": {
"type": "http",
"url": "https://svc.blockdaemon.com/defi/v1/mcp/http",
"headers": {
"X-Api-Key": "${BLOCKDAEMON_API_KEY}"
}
}
}
}Authentication
Export the key before launching Claude Code, and reference it as ${BLOCKDAEMON_API_KEY} so the raw value never enters a committed file:
export BLOCKDAEMON_API_KEY="your-api-key"Verify
claude mcp listConfirm blockdaemon-defi reports as connected, then ask Claude to list the tools for that server.
Troubleshooting
| Symptom | Fix |
|---|---|
401 / 403 | Check the key value and that the header is exactly X-Api-Key: <key>. |
| Server not listed | Confirm you passed --transport http; Claude Code defaults to stdio. |
| Added to the wrong place | Re-run with an explicit --scope, and remove the stale entry. |
| Hanging connection | Raise the timeout with the MCP_TIMEOUT environment variable. |
Visual Studio Code
Prerequisites
- A recent VS Code build with MCP support. Confirm by checking that the Command Palette offers MCP: List Servers.
Configuration
- Workspace (committable):
.vscode/mcp.json - User level: Command Palette → MCP: Open User Configuration
{
"inputs": [
{
"type": "promptString",
"id": "blockdaemon-api-key",
"description": "Blockdaemon API Key",
"password": true
}
],
"servers": {
"blockdaemon-defi": {
"type": "http",
"url": "https://svc.blockdaemon.com/defi/v1/mcp/http",
"headers": {
"X-Api-Key": "${input:blockdaemon-api-key}"
}
}
}
}Authentication
${input:...} prompts for the key once and caches it securely, so the raw key never lands in a committed mcp.json. To use an already-exported variable instead, replace the value with ${env:BLOCKDAEMON_API_KEY}.
Verify
Command Palette → MCP: List Servers → select blockdaemon-defi and confirm it's running. Tools also appear under Configure Tools in the Chat view.
Troubleshooting
| Symptom | Fix |
|---|---|
| Server errors | MCP: List Servers → select the server → Show Output for logs. |
| Header appears to be dropped | Some VS Code releases have had issues forwarding custom headers on HTTP MCP servers; update to the latest version. |
| Key prompt never appears | Ensure inputs is at the top level of mcp.json, alongside servers rather than inside it. |
OpenAI Codex CLI
Prerequisites
- Codex CLI installed (
npm install -g @openai/codexor equivalent) and signed in.
Configuration
- Global:
~/.codex/config.toml - Project scoped:
.codex/config.tomlin the project directory
Add the server, then add the header by editing config.toml — codex mcp add does not currently accept a custom-header flag.
codex mcp add blockdaemon-defi \
--url https://svc.blockdaemon.com/defi/v1/mcp/http[mcp_servers.blockdaemon-defi]
url = "https://svc.blockdaemon.com/defi/v1/mcp/http"
# IMPORTANT: the value below is the NAME of an environment variable,
# not the API key itself. Do not paste your key here.
env_http_headers = { "X-Api-Key" = "BLOCKDAEMON_API_KEY" }
startup_timeout_sec = 20.0
tool_timeout_sec = 60.0Authentication
env_http_headers maps a header name to the name of an environment variable that holds the value. Export the variable in the shell Codex is launched from:
export BLOCKDAEMON_API_KEY="your-api-key"Note
Codex CLI's custom-header field name has changed across releases. If the header isn't picked up, run
codex mcp add --helpand checkcodex --versionagainst the Codex CLI docs, then adjust the field name.
Verify
codex mcp list
codex mcp get blockdaemon-defiTroubleshooting
| Symptom | Fix |
|---|---|
| Shows as configured but calls fail | Confirm BLOCKDAEMON_API_KEY is exported in the same shell session Codex runs in. |
| Connection refused or timeout | Increase startup_timeout_sec; confirm outbound access to svc.blockdaemon.com. |
| Tools missing | Check for enabled_tools / disabled_tools filters excluding DeFi tools. |
Cursor
Prerequisites
- Cursor installed and signed in.
Configuration
- Project scope (committable):
.cursor/mcp.jsonin the repo root - User scope (all projects):
~/.cursor/mcp.json
{
"mcpServers": {
"blockdaemon-defi": {
"url": "https://svc.blockdaemon.com/defi/v1/mcp/http",
"headers": {
"X-Api-Key": "YOUR_BLOCKDAEMON_API_KEY"
}
}
}
}Authentication
Replace YOUR_BLOCKDAEMON_API_KEY with your key. If using the project-scope file, keep it out of version control by adding .cursor/mcp.json to .gitignore, or use the user-scope file (~/.cursor/mcp.json) so the key never enters the repo.
Verify
Open Cursor, go to Settings → Tools & MCPs → Installed MCP Servers, and confirm blockdaemon-defi shows as connected.
Troubleshooting
| Symptom | Fix |
|---|---|
| Server not listed | Confirm the file is valid JSON and restart Cursor. |
401 / 403 | Check the X-Api-Key value; confirm the key has DeFi product access. |
| Tools not visible | Open Settings → MCP and check the server's error output. |
Claude Desktop
Prerequisites
- Claude Desktop installed and signed in.
- Node.js, which provides
npxfor the proxy below.
Configuration
| OS | Path |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| Linux | ~/.config/Claude/claude_desktop_config.json |
Custom headers need a proxy
Claude Desktop can't attach custom auth headers to a direct HTTP server entry. Bridge the connection through the
mcp-remoteproxy, which forwards a custom header to the remote HTTP endpoint over a local stdio connection.
Option A — key from an environment variable (recommended for shared or managed machines)
{
"mcpServers": {
"blockdaemon-defi": {
"command": "npx",
"args": [
"mcp-remote",
"https://svc.blockdaemon.com/defi/v1/mcp/http",
"--header",
"X-Api-Key:${BLOCKDAEMON_API_KEY}"
],
"env": {
"BLOCKDAEMON_API_KEY": "your-api-key"
}
}
}
}This keeps the key in a single named field rather than embedded in an argument string, which makes it easier to swap and rotate. To keep the key out of the file entirely, choose one of the following:
- Omit the
envblock. IfBLOCKDAEMON_API_KEYis already set in the system environment Claude Desktop inherits, the substitution resolves without the block. This is the most secure option. - Treat
"your-api-key"as a placeholder. On managed machines, leave a placeholder value and have your MDM or configuration tooling overwrite it at provisioning time, so the real key never sits in a hand-edited file.
Storing a literal key in the env block is no more secure than Option B below — the advantage is only that the value is isolated and easy to replace.
Watch the spacing
When substituting a variable inside a
--headerargument, writeX-Api-Key:${VAR}with no space after the colon. Arguments are split on whitespace, so a space breaks the substitution.
Option B — key inline (acceptable on a personal machine)
{
"mcpServers": {
"blockdaemon-defi": {
"command": "npx",
"args": [
"mcp-remote",
"https://svc.blockdaemon.com/defi/v1/mcp/http",
"--header",
"X-Api-Key: YOUR_BLOCKDAEMON_API_KEY"
]
}
}
}claude_desktop_config.json is a local, per-user file that isn't committed, so an inline key is workable for a single-user machine. Restrict file permissions, and rotate the key if the machine is shared or lost.
Verify
Restart Claude Desktop fully, then open Settings → Connectors and confirm blockdaemon-defi shows as connected. A tools icon in the chat input is a second confirmation.
Troubleshooting
| Symptom | Fix |
|---|---|
| Server does not appear | Validate the JSON — a trailing comma is the usual cause — and restart the app completely. |
| Auth failures | Check the --header string. Use X-Api-Key: <key> for a literal key, X-Api-Key:${VAR} with no space for a variable. |
| No tools listed | Inspect the mcp-remote logs at Settings → Developer → open logs folder. |
Example workflows
Once connected, you interact in plain language — the assistant selects the tool.
"What's the USDC balance of wallet
0xabc123...on Ethereum?"
The assistant calls the balance tool with the address, chain, and token, and returns a readable result — for example, the wallet holds 1,250.42 USDC on Ethereum mainnet.
"Get me a quote to swap 1 ETH for USDC on Ethereum."
The assistant calls the DEX quote tool with the token pair, chain, and amount, and returns the expected output, route, and fees — with no need to know the underlying aggregator's request shape.
"Get a quote for swapping 1 ETH to USDC, then show me my current ETH balance on that wallet."
The assistant invokes multiple tools in sequence and combines the results.
"What's the cheapest route to bridge 500 USDC from Ethereum to Arbitrum? Show me the breakdown."
The assistant calls the bridge quote tool with the source chain, destination chain, token, and amount, then returns the available routes ranked by cost — including protocol fees, gas estimates on both chains, and expected arrival time.
"Show me my current borrow position on Aave for wallet
0xabc123...on Ethereum — what's my health factor and how much can I safely borrow?"
The assistant calls the user account data tool to retrieve the collateral value, total debt, available borrow capacity, and health factor, presenting a summary that makes the risk level immediately clear.
Best practices
Protect your API key
- Never commit keys. Use each client's secret mechanism:
${VAR}in Claude Code,${input:...}in VS Code,env_http_headersin Codex, user-scope config in Cursor, anenvblock in Claude Desktop. - Scope keys narrowly and rotate them on a schedule via the Blockdaemon dashboard.
Respect rate limits
- Limits are enforced per API key. Batch or cache repeated lookups — balances rarely need sub-second polling. For current limits by plan, see the Blockdaemon documentation.
Handle errors deliberately
- Treat MCP tool errors like any API error: read the code and message before retrying. Don't blind-retry
4xxresponses such as invalid parameters or bad auth.
Choose the right client for the job
- For automated or CI-adjacent workflows, prefer Claude Code, Codex CLI, VS Code, or Cursor — they pass headers natively.
- For Claude Desktop in a team, standardize on the
mcp-remoteproxy with theenvpattern and document key rotation for shared machines.
Troubleshooting
Start here for issues that aren't client-specific.
| Issue | Likely cause | Fix |
|---|---|---|
401 / 403 | Missing or malformed X-Api-Key header | Confirm the header is exactly X-Api-Key: <key> and the key is current |
| Invalid API key | Key revoked, expired, or mistyped | Generate a new key at app.blockdaemon.com |
| Connection errors | Wrong transport configured, e.g. stdio instead of HTTP | Configure the client for HTTP / Streamable HTTP, not a local process |
| Requests never reach the server | Network or proxy blocking egress | Confirm outbound access to svc.blockdaemon.com |
| Timeouts | Slow network or an unusually large request | Raise the client's connection and tool timeouts (see the client sections) |
Still stuck?
Capture your client's MCP log output and contact Blockdaemon support.
FAQ
Do I need a separate API key for the MCP server?
No. Use the same Blockdaemon key you use elsewhere, provided it has DeFi product access.
Which clients are supported?
Any client that supports the Streamable HTTP transport. This guide covers Claude Code, VS Code, Codex CLI, Cursor, and Claude Desktop.
Does the server support stdio?
No — HTTP only. Clients limited to stdio, such as Claude Desktop natively, need a bridging proxy like mcp-remote.
Is the tool list the same across clients?
Yes. The server defines the tool list, so every client on the same endpoint sees the same tools.
Are there rate limits?
Yes, standard Blockdaemon per-key limits apply. See the Blockdaemon documentation for current figures.
Reference
- Blockdaemon documentation
- DeFi API overview
- Get your API credentials
- API key management
- Model Context Protocol specification
- Blockdaemon support
👋 Need Help?
Contact us through email or our support page for any issues, bugs, or assistance you may need.
Updated about 2 hours ago
