This guide shows how to build an agent that uses ACN without human intervention — it discovers services, pays for them, and processes results on its own.
Two Paths to Agent Integration
MCP (Recommended) Use ACN’s MCP server for native tool integration with Claude and other MCP-compatible agents. The agent sees ACN services as tools it can call directly.
REST API Wrap ACN’s REST API as a tool in any agent framework. Works with LangChain, CrewAI, AutoGen, Vercel AI SDK, or custom agents.
Option A: Using the MCP Server
The fastest path for MCP-compatible agents. Your agent gets ACN discovery and execution as native tools.
1. Scaffold with the CLI
npx acn-agent create my-agent
The interactive wizard will:
Ask you to choose a framework (Claude or LangChain)
Configure your LLM API key and wallet
Set up the ACN and wallet MCP server connections
Generate a ready-to-run project
Add ACN’s MCP server to your agent’s configuration:
{
"mcpServers" : {
"acn" : {
"type" : "url" ,
"url" : "https://mcp.acn.exchange/mcp" ,
"headers" : {
"x-acn-api-key" : "acn_sk_your_api_key"
}
},
"acn-wallet" : {
"type" : "stdio" ,
"command" : "npx" ,
"args" : [ "acn-agent" , "wallet-server" ],
"env" : {
"WALLET_PRIVATE_KEY" : "0xYourPrivateKey" ,
"CHAIN_ID" : "8453"
}
}
}
}
Never commit your private key or API key to version control. Use environment variables or a secrets manager.
3. Run Your Agent
npx acn-agent run "Find the current price of ETH and send it to user@example.com"
The agent will:
Call acn_discover to find a price data provider
Call acn_discover to find an email provider
Execute the price lookup (paying per-call)
Execute the email send (paying per-call)
Return the results with a cost summary
Option B: Using the REST API
Wrap ACN as a tool in any agent framework:
import { tool } from "your-agent-framework" ;
const discoverTool = tool ({
name: "acn_discover" ,
description: "Search ACN marketplace for services" ,
parameters: {
query: { type: "string" , description: "What capability do you need?" }
},
execute : async ({ query }) => {
const res = await fetch ( "https://api.acn.exchange/v1/discover" , {
method: "POST" ,
headers: { "Content-Type" : "application/json" },
body: JSON . stringify ({ query })
});
return res . json ();
}
});
const executeTool = tool ({
name: "acn_execute" ,
description: "Execute a service discovered on ACN" ,
parameters: {
provider_id: { type: "string" },
endpoint_slug: { type: "string" },
payload: { type: "object" }
},
execute : async ({ provider_id , endpoint_slug , payload }) => {
const res = await fetch (
`https://api.acn.exchange/v1/execute/ ${ provider_id } / ${ endpoint_slug } ` ,
{
method: "POST" ,
headers: {
"Content-Type" : "application/json" ,
"Authorization" : `Bearer ${ process . env . ACN_API_KEY } `
},
body: JSON . stringify ( payload )
}
);
return res . json ();
}
});
See the Agent Frameworks section for complete integration guides for each framework.
Equipping Your Agent with a Wallet
For agents to pay autonomously, they need a wallet identity. The simplest approach:
# Generate a new wallet (or use an existing private key)
# Fund it with USDC on Base
# Pass the private key as an environment variable
The wallet serves dual purposes:
Identity — The agent’s on-chain identity for authentication
Payments — Signs USDC transactions to pay for services
See Equip an Agent with a Wallet for the full guide.
What’s Next?