Skip to main content

Agent Frameworks

Agent Wallet integrates with popular AI agent frameworks through two approaches: MCP-native (if the framework supports MCP) or FDX CLI wrapping (the framework calls FDX as a shell tool).

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 call' for available methods."""
    result = subprocess.run(
        ["fdx", "call"] + 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 --recipientAddress 0x... --amount 5'"""
    result = subprocess.run(
        ["fdx", "call"] + 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", "call"] + 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 createWalletClient() {
  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 createWalletClient();

// Check balance
const balance = await client.callTool({
  name: "check_balance",
  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 call 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. Test on testnet first. Use the Testnet Faucet to get test tokens. Validate your agent’s behavior before connecting a funded wallet. Handle errors gracefully. Agents should check for insufficient balance, failed transactions, and network errors — and communicate these clearly rather than retrying blindly.