Skip to main content
If your framework supports MCP, connect directly to the Agent Wallet MCP server. If not, wrap the FDX CLI as a shell tool. Both approaches give the same wallet capabilities.

Integration Approaches

FrameworkMCP SupportRecommended Approach
LangChainVia MCP adapterMCP native
CrewAIVia MCP adapter or shell toolsFDX CLI wrapping
AutoGenVia MCP adapterMCP native
Semantic KernelVia adapterMCP native
CustomDepends on implementationMCP SDK or FDX CLI
MCP-native is preferred when available — it gives the agent direct access to wallet tools through the standard MCP tool-calling interface. FDX CLI wrapping works with any framework that can execute shell commands, which covers essentially every agent framework.

LangChain

from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_anthropic import ChatAnthropic

# Connect to Agent Wallet MCP server
async with MultiServerMCPClient(
    {
        "finance-district": {
            "url": "https://mcp.fd.xyz",
            "transport": "streamable-http",
        }
    }
) as client:
    tools = client.get_tools()

    agent = create_react_agent(
        ChatAnthropic(model="claude-sonnet-4-20250514"),
        tools
    )

    result = await agent.ainvoke(
        {"messages": [{"role": "user", "content": "Check my wallet balance"}]}
    )

FDX CLI Tool Wrapper

import subprocess
import json
from langchain.tools import tool

@tool
def wallet(method: str) -> str:
    """Execute an FDX wallet command. Pass an MCP method name and arguments.
    Example: 'getWalletOverview --chainKey ethereum'
    Run 'fdx wallet' for available methods."""
    result = subprocess.run(
        ["fdx", "wallet"] + method.split(),
        capture_output=True, text=True
    )
    return result.stdout

# Use in an agent
agent = create_react_agent(llm, [wallet])

CrewAI

from crewai import Agent, Task, Crew
from crewai.tools import tool
import subprocess
import json

@tool("Agent Wallet")
def wallet(method: str) -> str:
    """Manage crypto wallet via FDX. Pass an MCP method name and arguments.
    Example: 'getWalletOverview --chainKey ethereum' or 'transferTokens --chainKey ethereum --toAddress 0x... --amount 5 --asset USDC'"""
    result = subprocess.run(
        ["fdx", "wallet"] + method.split(),
        capture_output=True, text=True
    )
    return result.stdout

financial_agent = Agent(
    role="Financial Agent",
    goal="Manage wallet operations and execute transactions",
    tools=[wallet],
    verbose=True
)

task = Task(
    description="Check the wallet balance and swap 10 USDC for ETH if balance allows",
    agent=financial_agent
)

crew = Crew(agents=[financial_agent], tasks=[task])
result = crew.kickoff()

AutoGen

from autogen import ConversableAgent
import subprocess
import json

def wallet_command(method: str) -> str:
    result = subprocess.run(
        ["fdx", "wallet"] + method.split(),
        capture_output=True, text=True
    )
    return result.stdout

assistant = ConversableAgent(
    name="financial_assistant",
    llm_config={"model": "claude-sonnet-4-20250514"},
)

# Register wallet as a callable function
assistant.register_for_llm(
    name="wallet",
    description="Execute FDX wallet commands. Pass MCP method name and arguments."
)(wallet_command)

Custom MCP Client

For frameworks with direct MCP support or when building your own agent:
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

async function createMcpClient() {
  const transport = new StreamableHTTPClientTransport(
    new URL("https://mcp.fd.xyz"),
  );

  const client = new Client({ name: "my-agent", version: "1.0.0" });
  await client.connect(transport);

  return client;
}

// Use in your agent logic
const client = await createMcpClient();

// Check balance
const result = await client.callTool({
  name: "getWalletOverview",
  arguments: {},
});

// Transfer
const transfer = await client.callTool({
  name: "transfer",
  arguments: {
    to: "0x1234...5678",
    amount: "5",
    token: "USDC",
  },
});
See the MCP SDK documentation for full client implementation details.

Best Practices

Use MCP when possible. The MCP approach gives your agent richer context — tool descriptions, parameter schemas, and error details that help the LLM make better decisions. FDX output is always JSON. All fdx wallet / fdx prism output is structured JSON, making it straightforward for agents to parse. Write clear tool descriptions. The LLM uses your tool description to decide when and how to call the tool. Be specific about what each command does. Start with small amounts. Validate your agent’s behavior with a small balance before scaling up funding. Handle errors gracefully. Agents should check for insufficient balance, failed transactions, and network errors — and communicate these clearly rather than retrying blindly.
Last modified on April 2, 2026