Autonomous cross-border treasury management using Claude Code agents communicating via the Agent-to-Agent (A2A) protocol on Hedera blockchain.
This system enables autonomous treasury operations between a UK and US business entity using:
- Claude Code Agents: AI agents with domain expertise in treasury management
- A2A Protocol: Standardized agent-to-agent communication
- Hedera Blockchain: Fast, secure cross-border transfers
- Agent Skills: Domain knowledge for treasury operations and compliance
- MCP Servers: Tools for blockchain operations and inter-agent messaging
┌─────────────────────────────────────────────────────────────┐
│ UK BUSINESS CLAUDE CODE AGENT │
│ Skills: treasury-management, uk-compliance, fx-management │
│ MCP: Hedera (blockchain), A2A (messaging) │
└─────────────────────────────────────────────────────────────┘
│
│ A2A Protocol (JSON-RPC)
▼
┌────────────────────┐
│ A2A Message Bus │
│ Express Servers │
└────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ US BUSINESS CLAUDE CODE AGENT │
│ Skills: treasury-management, us-compliance, fx-management │
│ MCP: Hedera (blockchain), A2A (messaging) │
└─────────────────────────────────────────────────────────────┘
treasury-agent-system/
├── apps/
│ ├── uk-agent/ # UK Treasury Agent
│ └── us-agent/ # US Treasury Agent
├── packages/
│ ├── mcp-a2a/ # A2A messaging MCP server
│ ├── mcp-hedera/ # Hedera blockchain MCP server
│ ├── shared-skills/ # Treasury domain knowledge
│ ├── shared-types/ # TypeScript type definitions
│ └── shared-config/ # Shared configuration
└── scripts/ # Setup and utility scripts
- Node.js 18+
- pnpm 8+
- Claude Code CLI
- Anthropic API key
- Hedera testnet/mainnet accounts
# Clone the repository
git clone <your-repo-url>
cd treasury-agent-system
# Run setup script
pnpm run setupEdit the environment files with your credentials:
# UK Agent
vim apps/uk-agent/.env.uk
# US Agent
vim apps/us-agent/.env.usRequired variables:
UK_HEDERA_ACCOUNT_ID/US_HEDERA_ACCOUNT_IDUK_HEDERA_PRIVATE_KEY/US_HEDERA_PRIVATE_KEYANTHROPIC_API_KEY
In separate terminals:
# Terminal 1: Start UK Agent
pnpm start:uk
# Terminal 2: Start US Agent
pnpm start:uspnpm --filter demo-ui devOpen http://localhost:3000 to view the UI.
Using Claude Code CLI:
# In UK agent directory
cd apps/uk-agent
claude
# Example prompt:
# "Send a message to the US treasury agent requesting confirmation
# that they can receive 50,000 HBAR for Q4 operating capital"pnpm run buildpnpm run typecheckpnpm run clean# UK agent with hot reload
pnpm dev:uk
# US agent with hot reload
pnpm dev:us- uk-agent: UK treasury agent with A2A server and Claude Code configuration
- us-agent: US treasury agent with A2A server and Claude Code configuration
- mcp-a2a: MCP server providing agent-to-agent messaging tools
- mcp-hedera: MCP server providing Hedera blockchain operations
- shared-skills: Agent Skills for treasury management, compliance, and FX
- shared-types: TypeScript type definitions shared across packages
- shared-config: Base TypeScript and build configuration
Skills provide domain knowledge to the agents:
- treasury-management: Cash positioning, intercompany transfers, compliance workflows
- uk-compliance: UK financial regulations and reporting requirements
- us-compliance: US FinCEN requirements and regulatory thresholds
- fx-management: Foreign exchange rate handling and conversion logic
TRANSFER_HBAR_TOOL: Execute HBAR transfersGET_HBAR_BALANCE_QUERY_TOOL: Query account balancesCREATE_FUNGIBLE_TOKEN_TOOL: Create HTS tokensAIRDROP_FUNGIBLE_TOKEN_TOOL: Distribute tokens
send_message_to_partner: Send message to partner agentcheck_partner_messages: Poll for incoming messages
- UK user requests transfer to US entity
- UK agent validates against uk-compliance rules
- UK agent sends notification to US agent via A2A
- US agent receives and acknowledges capability
- UK agent executes Hedera transfer using Hedera MCP
- US agent verifies receipt and updates records
- Both agents log transaction for audit
- User asks UK agent for treasury position
- UK agent queries Hedera balance via MCP
- UK agent requests US balance via A2A message
- US agent queries its Hedera balance and responds
- UK agent consolidates and reports total position
- API keys stored in environment files (gitignored)
- Hedera private keys never committed to repository
- A2A servers run on localhost for demo (use HTTPS in production)
- Permission modes configured per agent in
.claude/settings.json
For production deployment:
- Use HTTPS for A2A communication
- Implement authentication in A2A AgentCard
- Use Hedera mainnet accounts
- Deploy agents to separate servers
- Implement proper logging and monitoring
- Add rate limiting and error handling
Check that:
- Environment variables are set correctly
- Hedera credentials are valid
- Ports 4000 and 5001 are not in use
- pnpm dependencies are installed
Verify:
- MCP server paths in
.claude/mcp.jsonare correct - Packages are built (
pnpm run build) - Environment variables are accessible to MCP servers
Ensure:
- Both A2A servers are running
- Partner agent URLs are correct in env files
- Message directories exist and are writable
MIT
Contributions welcome! Please read CONTRIBUTING.md first.