> ## Documentation Index
> Fetch the complete documentation index at: https://developers.fd.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Frameworks

> Add real crypto wallet capabilities to LangChain, CrewAI, AutoGen, and more — no MCP client required.

If your framework supports MCP, connect directly to the Agent Wallet MCP server. If not, wrap the [FDX CLI](/agent-wallet/ai-integration/cli) as a shell tool. Both approaches give the same wallet capabilities.

## Integration Approaches

| Framework       | MCP Support                    | Recommended Approach |
| --------------- | ------------------------------ | -------------------- |
| LangChain       | Via MCP adapter                | MCP native           |
| CrewAI          | Via MCP adapter or shell tools | FDX CLI wrapping     |
| AutoGen         | Via MCP adapter                | MCP native           |
| Semantic Kernel | Via adapter                    | MCP native           |
| Custom          | Depends on implementation      | MCP 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

### MCP Integration (Recommended)

```python theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
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://wallet-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

```python theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
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

```python theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
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

```python theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
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:

```typescript theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
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://wallet-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: "transferTokens",
  arguments: {
    to: "0x1234...5678",
    amount: "5",
    token: "USDC",
  },
});
```

See the [MCP SDK documentation](https://modelcontextprotocol.io/docs) 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.
