Skip to main content

Overview

The MCP (Model Context Protocol) server provides a standardized interface for AI agents to interact with the Agentic Wallet platform. It exposes curated tools and a generic gateway proxy for schema-validated API access. Port: 3008 (default)

Architecture

The MCP server acts as a tool invocation layer between AI agents and the API Gateway.

Endpoints

List Tools

Get all available MCP tools with descriptions.
GET /mcp/tools
Response:
{
  "data": [
    {
      "name": "wallet.create",
      "description": "Create a wallet"
    },
    {
      "name": "wallet.balance",
      "description": "Get wallet SOL balance"
    },
    {
      "name": "tx.create",
      "description": "Create a transaction from intent"
    },
    {
      "name": "gateway.request",
      "description": "Call any API gateway /api/v1 endpoint with schema validation"
    }
  ]
}

Call Tool

Invoke a specific MCP tool with arguments.
POST /mcp/call
Content-Type: application/json

{
  "tool": "wallet.balance",
  "args": {
    "walletId": "wallet-uuid"
  }
}
Response:
{
  "data": {
    "walletId": "wallet-uuid",
    "publicKey": "base58-pubkey",
    "lamports": 1000000000,
    "sol": 1.0
  }
}

Available Tools

The MCP server provides 70+ curated tools across all platform capabilities.

Wallet Tools

ToolDescriptionRequired Args
wallet.createCreate a walletlabel?
wallet.listList walletspublicKey?
wallet.getGet wallet metadatawalletId
wallet.balanceGet wallet SOL balancewalletId
wallet.tokensGet wallet SPL balanceswalletId
wallet.sign_messageSign a base64 messagewalletId, message
wallet.sign_transactionSign a base64 transactionwalletId, transaction
Example:
{
  "tool": "wallet.create",
  "args": {
    "label": "trading-bot"
  }
}

Transaction Tools

ToolDescriptionRequired Args
tx.createCreate a transaction from intentwalletId, type, protocol, intent
tx.getFetch transaction by idtxId
tx.retryRetry a transactiontxId
tx.approveApprove approval-gated transactiontxId
tx.rejectReject approval-gated transactiontxId
tx.proofGet execution prooftxId
tx.replayGet deterministic replay datatxId
tx.list_by_walletList wallet transactionswalletId
tx.pending_approvalsList pending approvalswalletId
tx.positionsList protocol positionswalletId
tx.escrowsList escrow recordswalletId
Example:
{
  "tool": "tx.create",
  "args": {
    "walletId": "wallet-uuid",
    "type": "transfer_sol",
    "protocol": "system-program",
    "intent": {
      "destination": "recipient-pubkey",
      "lamports": 1000000
    }
  }
}

Policy Tools

ToolDescriptionRequired Args
policy.createCreate a policywalletId, name, rules, active
policy.list_walletList policies for walletwalletId
policy.compatibility_checkCheck rule compatibilityrules
policy.migrateMigrate policy versionpolicyId, targetVersion
policy.evaluateEvaluate policy decisionwalletId, type, protocol
Example:
{
  "tool": "policy.evaluate",
  "args": {
    "walletId": "wallet-uuid",
    "type": "transfer_sol",
    "protocol": "system-program",
    "amountLamports": 500000
  }
}

Agent Tools

ToolDescriptionRequired Args
agent.createCreate an agentname, executionMode, allowedIntents
agent.listList agents-
agent.getGet agent detailsagentId
agent.capabilities_updateUpdate agent capabilitiesagentId, allowedIntents
agent.startStart agent scheduleragentId
agent.stopStop agent scheduleragentId
agent.pausePause an agentagentId, reason?
agent.resumeResume an agentagentId
agent.budgetGet agent budget statusagentId
agent.manifest_issueIssue capability manifestagentId, allowedIntents, allowedProtocols
agent.manifest_verifyVerify capability manifestagentId, manifest
agent.executeExecute intent as agentagentId, type, protocol, intent
Example:
{
  "tool": "agent.execute",
  "args": {
    "agentId": "agent-uuid",
    "type": "swap",
    "protocol": "jupiter",
    "intent": {
      "inputMint": "SOL_MINT",
      "outputMint": "USDC_MINT",
      "amount": "1000000",
      "slippageBps": 50
    }
  }
}

Protocol Tools

ToolDescriptionRequired Args
protocol.listList available protocols-
protocol.capabilitiesGet protocol capabilitiesprotocol
protocol.health_allGet health for all protocols-
protocol.healthGet health for a protocolprotocol
protocol.quoteFetch swap quoteprotocol, inputMint, outputMint, amount, walletAddress
protocol.swapBuild swap transactionSame as quote
protocol.stakeBuild staking transactionprotocol, walletAddress, amount
protocol.unstakeBuild unstake transactionSame as stake
protocol.lend_supplyBuild lending supplyprotocol, walletAddress, mint, amount
protocol.lend_borrowBuild lending borrowSame as supply
protocol.escrow_createBuild create escrowwalletAddress, intent
protocol.escrow_acceptBuild accept escrowescrowId, walletAddress
protocol.escrow_releaseBuild release escrowSame as accept
protocol.escrow_refundBuild refund escrowSame as accept
protocol.escrow_disputeBuild dispute escrowSame as accept
protocol.escrow_resolveBuild resolve escrowSame as accept
Example:
{
  "tool": "protocol.quote",
  "args": {
    "protocol": "jupiter",
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000",
    "walletAddress": "wallet-pubkey",
    "slippageBps": 50
  }
}

Risk Tools

ToolDescriptionRequired Args
risk.list_protocolsList protocol risk configs-
risk.get_protocolGet protocol risk configprotocol
risk.set_protocolUpdate protocol risk configprotocol, config fields
risk.list_portfolioList portfolio risk controls-
risk.get_portfolioGet wallet portfolio controlswalletId
risk.set_portfolioUpdate portfolio controlswalletId, control fields
risk.get_chaosGet chaos switchboard settings-
risk.set_chaosUpdate chaos settingsenabled?, failureRates?, latencyMs?
Example:
{
  "tool": "risk.set_protocol",
  "args": {
    "protocol": "jupiter",
    "maxSlippageBps": 100,
    "requireOracleForSwap": true
  }
}

Strategy & Treasury Tools

ToolDescriptionRequired Args
strategy.backtestRun strategy backtestwalletId, name, steps
strategy.paper_executeExecute paper tradeagentId, walletId, type, protocol, intent
strategy.paper_listList paper tradesagentId
treasury.allocateAllocate treasury budgettargetAgentId, lamports
treasury.rebalanceRebalance treasurysourceAgentId, targetAgentId, lamports
Example:
{
  "tool": "treasury.allocate",
  "args": {
    "targetAgentId": "agent-uuid",
    "lamports": 10000000,
    "reason": "Initial allocation"
  }
}

Audit Tools

ToolDescriptionRequired Args
audit.eventsList audit eventsfilters (all optional)
audit.metricsGet metrics snapshot-
Example:
{
  "tool": "audit.events",
  "args": {
    "agentId": "agent-uuid",
    "protocol": "jupiter"
  }
}

Gateway Request Tool

The gateway.request tool provides schema-validated access to any /api/v1 endpoint.

Usage

Request Format
{
  "tool": "gateway.request",
  "args": {
    "path": "/api/v1/...",
    "method": "GET" | "POST" | "PUT" | "PATCH" | "DELETE",
    "query": { ... },  // optional, for GET/DELETE
    "body": { ... }    // optional, for POST/PUT/PATCH
  }
}

Schema Validation

The tool validates:
  • path must match /^/api/v1/[a-zA-Z0-9/_:-]*$/
  • method must be valid HTTP method
  • query must be record of string/number/boolean
  • body must be valid JSON object

Examples

{
  "tool": "gateway.request",
  "args": {
    "path": "/api/v1/wallets/wallet-uuid/balance",
    "method": "GET"
  }
}

Error Handling

MCP tools return normalized error responses.

Input Validation Errors

Invalid Tool
{
  "error": "Unknown MCP tool: invalid.tool"
}
// HTTP 404
Missing Required Argument
{
  "error": "walletId is required"
}
// HTTP 400
Invalid Schema
{
  "error": "Expected object, received string"
}
// HTTP 400

Gateway Errors

When the underlying gateway request fails:
Gateway Error
{
  "error": "Policy violation: spending limit exceeded code=POLICY_VIOLATION stage=policy traceId=abc-123"
}
// HTTP 500

Authentication

The MCP server uses environment-configured credentials to authenticate with the API Gateway.
Environment Configuration
API_BASE_URL=http://localhost:3000
API_KEY=dev-api-key
TENANT_ID=my-tenant  # optional
Headers sent to gateway:
  • x-api-key: From API_KEY env var
  • x-tenant-id: From TENANT_ID env var (if set)
  • content-type: application/json

Health Check

GET /health
Response:
{
  "status": "ok",
  "service": "mcp-server"
}

Using the SDK

The TypeScript SDK includes an MCP client for tool invocation.
SDK MCP Client
import { createAgenticWalletClient } from '@agentic-wallet/sdk';

const client = createAgenticWalletClient('http://localhost:3000', {
  apiKey: 'dev-api-key',
});

// List tools
const tools = await client.mcp.tools();

// Call tool
const balance = await client.mcp.call('wallet.balance', {
  walletId: 'wallet-uuid',
});

Integration Patterns

AI Agent Tool Use

Agent Integration
// In your AI agent code:
const availableTools = await client.mcp.tools();

// Present tools to LLM
const toolSchemas = availableTools.map(tool => ({
  name: tool.name,
  description: tool.description,
}));

// When LLM requests tool use:
const result = await client.mcp.call(
  llmToolCall.name,
  llmToolCall.arguments
);

// Return result to LLM

Orchestrator Pattern

Workflow Orchestration
// Create wallet
const wallet = await client.mcp.call('wallet.create', {
  label: 'orchestrator-wallet',
});

// Create agent
const agent = await client.mcp.call('agent.create', {
  name: 'trading-agent',
  walletId: wallet.walletId,
  executionMode: 'autonomous',
  allowedIntents: ['swap', 'query_balance'],
});

// Execute workflow
const quote = await client.mcp.call('protocol.quote', {
  protocol: 'jupiter',
  inputMint: 'SOL_MINT',
  outputMint: 'USDC_MINT',
  amount: '1000000',
  walletAddress: wallet.publicKey,
});

const tx = await client.mcp.call('agent.execute', {
  agentId: agent.agentId,
  type: 'swap',
  protocol: 'jupiter',
  intent: quote.intent,
});

Tool Discovery

Agents can dynamically discover available tools at runtime.
Dynamic Tool Discovery
const allTools = await client.mcp.tools();

// Filter by prefix
const walletTools = allTools.filter(t => t.name.startsWith('wallet.'));
const agentTools = allTools.filter(t => t.name.startsWith('agent.'));
const protocolTools = allTools.filter(t => t.name.startsWith('protocol.'));

// Build tool index
const toolIndex = new Map(
  allTools.map(t => [t.name, t.description])
);

Best Practices

Prefer named tools like wallet.create instead of gateway.request for better type safety and validation.
Always wrap MCP calls in try-catch and parse error messages for structured error codes and stages.
Call mcp.tools() once at startup and cache the result rather than fetching on every operation.
Validate tool arguments client-side before calling to reduce round-trips and error noise.

Next Steps

CLI Integration

Use the command-line interface

SDK Integration

Integrate with TypeScript SDK

SKILLS Contract

Review agent integration contract

API Reference

Explore REST API endpoints

Build docs developers (and LLMs) love