TypeScriptADK-TS

MCP DeBank

An MCP server for interacting with the DeBank portfolio tracking platform

  • Package: @iqai/mcp-debank
  • Purpose: Interacting with the DeBank platform for DeFi portfolio tracking and wallet analytics.

Usage with ADK TypeScript

import {McpDebank} from "@iqai/adk";

const toolset = McpDebank({
  env: {
    DEBANK_API_KEY: process.env.DEBANK_API_KEY,
  },
})

const tools = await toolset.getTools()
import {McpToolset} from "@iqai/adk";

const toolset = new McpToolset({
  name: "Debank MCP Client",
  description: "Client for DeBank portfolio tracking",
  transport: {
    mode: "stdio",
    command: "pnpm",
    args: ["dlx", "@iqai/mcp-debank"],
    env: {
      DEBANK_API_KEY: process.env.DEBANK_API_KEY,
      PATH: process.env.PATH || "",
    },
  },
})

const tools = await toolset.getTools()
{
  "mcpServers": {
    "debank-mcp-server": {
      "command": "pnpm",
      "args": ["dlx", "@iqai/mcp-debank"],
      "env": {
        "DEBANK_API_KEY": "your_debank_api_key"
      }
    }
  }
}

Available Tools

Remote MCP Endpoint

This MCP server is hosted remotely and tools are discovered dynamically at runtime. For the full list of available tools and endpoints, see the official CoinGecko MCP documentation.

Environment Variables

The MCP supports two mutually exclusive access modes:

Option 1: Direct DeBank API access

  • DEBANK_API_KEY: Required. API key obtained from the DeBank platform.

Option 2: Gateway-proxied access

  • IQ_GATEWAY_URL: Required. Base URL of the gateway service.
  • IQ_GATEWAY_KEY: Required. Authentication key for the gateway.

Access Modes

If both modes are configured, the gateway-proxied access will be used.

Usage Examples

Here's a complete example of using MCP DeBank with an ADK agent:

import { McpDebank, AgentBuilder } from "@iqai/adk";
import dotenv from "dotenv";

dotenv.config();

async function main() {
  // Initialize DeBank MCP toolset
  const toolset = McpDebank({
    env: {
      DEBANK_API_KEY: process.env.DEBANK_API_KEY,
    },
    debug: false,
    retryOptions: {
      maxRetries: 3,
      initialDelay: 500,
    },
  });

  // Get available tools
  const debankTools = await toolset.getTools();

  // Create agent with DeBank tools
  const { runner } = await AgentBuilder.create("debank_agent")
    .withModel("gemini-2.5-flash")
    .withDescription("An agent that tracks DeFi portfolios using DeBank")
    .withTools(...debankTools)
    .build();

  try {
    // Example queries
    const response = await runner.ask(
      "Show me the DeFi portfolio for wallet 0x1234...",
    );
    console.log(response);
  } finally {
    // Clean up resources
    await toolset.close();
  }
}

main().catch(console.error);

Getting Your Credentials

DeBank API Key

  1. Visit DeBank Cloud
  2. Sign up for an account
  3. Generate an API key from the dashboard

Gateway Access (Alternative)

If using gateway-proxied access, obtain your IQ_GATEWAY_URL and IQ_GATEWAY_KEY from the IQ Gateway service.

Important

Never share your API keys or commit them to version control. Always use environment variables or secure secret management systems.

Best Practices

  • Security: Store API keys in environment variables, never hardcode them
  • Resource Cleanup: Always call await toolset.close() when done to properly close connections
  • Error Handling: Implement proper error handling for portfolio data requests
  • Rate Limits: Be aware of DeBank API rate limits and implement appropriate retry logic

Error Handling

Error Scenarios

The server handles various error scenarios gracefully.

🚨 Missing credentials: Ensure either DEBANK_API_KEY or gateway credentials are set šŸ”„ Invalid wallet addresses: Verify wallet addresses are correct 🌐 Network issues: Check your internet connection and DeBank API status

Resources