A complete local demo showing how Claude Desktop can call MCP tools that:
- Use Facinet for gasless USDC payment flows
- List active facilitators on Avalanche Fuji
- Execute contract calls through Facinet
This README is written as a judge runbook: clone, configure, run, and test in minutes.
- MCP integration with Claude Desktop via stdio (
mcp/index.ts) - Paid tool execution with x402 (
src/index.ts) - AI agent backend with LangGraph (
agents/langgraph/app) - Gasless payment utilities with Facinet SDK (
mcp/index.ts,mcp/scripts/facinet_bridge.js) - Avalanche Fuji network configuration end-to-end
-
src/index.ts
x402-protected resource/proxy server (port5000) -
mcp/index.ts
MCP server launched by Claude Desktop (stdio). Exposes tools:facinet-list-facilitatorsfacinet-pay-usdcfacinet-execute-contract
-
agents/langgraph/app/__main__.py
Python LangGraph agent (port10000) -
mcp/scripts/facinet_bridge.js
Node bridge used by Python agent for Facinet actions
Use different wallets for payer and admin/payee.
-
Payer wallet (customer side):
PRIVATE_KEYin Claude MCP config (claude_desktop_config.json)- Used by MCP/x402 client signing
-
Admin/payee wallet (merchant side):
PUBLIC_KEYin root.env- Used by x402 server as recipient/verification identity
If payer and payee are the same, payment behavior may be rejected or confusing.
- Node.js 20+
- Python 3.12
uvpackage manager- Claude Desktop
- Avalanche Fuji test funds (AVAX + USDC for payer wallet)
Windows note: if PowerShell blocks npm, use npm.cmd.
Create/verify root .env using .env.example:
PUBLIC_KEY→ admin/payee wallet addressX402_NETWORK=avalanche-fujiPRIVATE_KEY(used by some local scripts/bridge)BASE_URL=http://localhost:5000FACINET_NETWORK=avalanche-fujiGOOGLE_API_KEYfor LangGraph model
mcp/.env.example exists for local MCP script runs.
For Claude Desktop, MCP env is usually passed in claude_desktop_config.json.
Edit:
%AppData%\Claude\claude_desktop_config.json
Use:
{
"mcpServers": {
"mcpay": {
"command": "C:\\Program Files\\nodejs\\npm.cmd",
"args": [
"--silent",
"--prefix",
"d:\\project\\agentX\\mcp",
"run",
"dev"
],
"env": {
"PRIVATE_KEY": "0xYOUR_PAYER_PRIVATE_KEY",
"BASE_URL": "http://localhost:5000",
"FACINET_NETWORK": "avalanche-fuji"
}
}
},
"preferences": {
"coworkScheduledTasksEnabled": false,
"ccdScheduledTasksEnabled": false,
"coworkWebSearchEnabled": true,
"sidebarMode": "chat"
}
}Then fully restart Claude Desktop.
From repo root:
npm.cmd install
npm.cmd --prefix d:\project\agentX\mcp install
cd d:\project\agentX\agents\langgraph
uv synccd d:\project\agentX\agents\langgraph
uv run app --host localhost --port 10000cd d:\project\agentX
npm.cmd run devClaude Desktop usually starts MCP automatically.
For debugging only:
cd d:\project\agentX\mcp
$env:PRIVATE_KEY="0xYOUR_PAYER_PRIVATE_KEY"
$env:BASE_URL="http://localhost:5000"
$env:FACINET_NETWORK="avalanche-fuji"
npm.cmd run devIn Claude Desktop chat:
-
Facilitator discovery (Facinet path)
List facilitators on avalanche-fuji using Facinet.
-
Payment action (Facinet path)
Pay 1 USDC to 0xRecipientAddress on avalanche-fuji via Facinet.
-
Contract call action (Facinet path)
Execute contract function register on 0xYourContractAddress with ABI [...] and args [...] on avalanche-fuji via Facinet.
Claude → MCP tool (facinet-list-facilitators / facinet-pay-usdc / facinet-execute-contract) → Facinet SDK → facilitator network execution on Avalanche Fuji
Cause: non-protocol logs written to stdout in stdio mode.
Status: fixed in mcp/index.ts by redirecting debug/info logs to stderr.
Action: restart MCP and Claude Desktop.
Select interpreter:
d:\project\agentX\agents\langgraph\.venv\Scripts\python.exe
Then reload VS Code window.
Use npm.cmd instead of npm in PowerShell.
Check:
FACINET_NETWORK=avalanche-fujiin Claude MCP config- payer wallet has required Fuji funds
- payer and payee wallets are different
- contract address / ABI / args are valid for target chain
- Never commit real private keys.
- Rotate any exposed test keys immediately.
- Use low-value test funds for demos.
Stop listeners on key ports:
Get-NetTCPConnection -LocalPort 5000,10000 -State Listen |
Select-Object -ExpandProperty OwningProcess -Unique |
ForEach-Object { Stop-Process -Id $_ -Force }Restart core services:
cd d:\project\agentX\agents\langgraph
uv run app --host localhost --port 10000
# new terminal
cd d:\project\agentX
npm.cmd run dev- MCP tool availability in Claude Desktop
- Facinet network/tool usability on Avalanche Fuji
- Clear wallet-role separation (payer vs admin/payee)