mcp

v2.29.0
@ic402/mcp Checked 5 hours ago Published 22 hours ago

MCP server for ic402 — exposes x402 charges and streaming sessions as tools

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

configure

Connect to the ic402-enabled ICP canister the operator configured and load its signing identity. MUST be called before any other tool (they all fail until configured). Does not move funds. The host, canister and identity are fixed by the operator at startup (IC402_MCP_HOST, IC402_MCP_CANISTER_ID, ICP_IDENTITY_PEM); the canisterId/host/identityPem params and the security params (autoPayment, localDev, perCallMaxAtomic, sessionMaxAtomic) are requests only: they are IGNORED unless the operator started the server with IC402_MCP_ALLOW_SECURITY_CHANGES=1, and the result reports any ignored fields.

ParameterTypeDescription
autoPaymentbooleanRequest that paid endpoints may auto-approve/pay. IGNORED unless the operator enabled security changes at startup; even when honored, every spend stays capped and confirm-gated. Default false.
canisterIdstringPrincipal of the ic402 canister (e.g. "rrkah-fqaaa-aaaaa-aaaaq-cai"). Omit it to use the canister the operator fixed at startup (IC402_MCP_CANISTER_ID); a different value is IGNORED unless the operato…
hoststringICP replica/gateway URL. Omit it to use the operator's host (IC402_MCP_HOST, default http://localhost:4944); a different value is IGNORED unless the operator enabled security changes. The root key is…
identityPemstringFilesystem path to a secp256k1 private-key PEM (SEC1 "EC PRIVATE KEY" or PKCS#8 "PRIVATE KEY"). Omit it to use the operator's identity (ICP_IDENTITY_PEM; anonymous if unset); a different path is IGNOR…
ledgerstringICRC-2 ledger canister ID (e.g. the ckUSDC ledger) used for ICP-side payments: session escrow deposits and submit_request auto-payment. Required for ICP paid flows.
localDevbooleanRequest permission to fetch http://localhost and private/loopback URLs (local development only). IGNORED unless the operator enabled security changes at startup. Default false.
networkstringCAIP-2 network identifier for ICP-side payments (default "icp:1" = ICP mainnet).
perCallMaxAtomicstringRequested per-call spend cap in atomic token units, as a decimal integer string (caps a single signed transfer). IGNORED unless the operator enabled security changes. Default 1000000 (= 1.00 USDC at 6…
sessionMaxAtomicstringRequested cumulative spend cap for this whole server session in atomic token units, as a decimal integer string. IGNORED unless the operator enabled security changes. Default 5000000 (= 5.00 USDC).

request_session

Fetch the session intent from the canister — pricing such as suggestedDeposit and costPerCall — WITHOUT opening a session or moving funds. Read-only. Call this before open_session to learn the deposit the canister expects.

ParameterTypeDescription
canisterIdstringTarget canister (defaults to the canister set by configure).

open_session

Open a streaming micropayment session by escrowing a deposit — this MOVES FUNDS. Two-phase: with confirm:false (default) it returns a confirmation_required proposal (amount/recipient/asset/chain) and does nothing; re-invoke with confirm:true plus the proposal's confirmWith values (including maxDeposit) only after the human approves. ICP path: ICRC-2 escrow via the ledger set in configure. EVM path: pass evmTxHash proving an on-chain USDC deposit, or an EIP-3009 authorization for the canister to pull the deposit, plus evmNetwork/evmSender/evmToken/evmRecipient. The deposit plus the ICP ledger…

ParameterTypeDescription
authorizationobjectEVM sessions only: a signed EIP-3009 transferWithAuthorization authorizing the deposit pull. value/validAfter/validBefore MUST be decimal integer strings (uint256 — JS numbers that lose precision ar…
canisterIdstringCanister to open the session on (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns the proposed deposit for human review without moving funds; true executes the escrow deposit. Only pass true after the human approves the proposal.
evmNetworkstringEVM sessions only: CAIP-2 chain of the deposit, format "eip155:<chainId>" (e.g. "eip155:84532" = Base Sepolia).
evmRecipientstringEVM sessions only: the canister's EVM address that receives the settled amount, 0x + 40 hex chars.
evmSenderstringEVM sessions only: the payer's EVM address (0x + 40 hex chars); the unused remainder is refunded here on close.
evmTokenstringEVM sessions only: ERC-20 contract address of the deposit token (e.g. USDC), 0x + 40 hex chars.
evmTxHashstringEVM sessions only: hash of the on-chain tx that deposited USDC to the canister's EVM address (0x + 64 hex chars).
maxDepositstringEscrow deposit in ATOMIC token units as a decimal integer string (e.g. "1000000" = 1.00 USDC at 6 decimals). Omit it on the confirm:false call to propose the canister's suggestedDeposit; the confirm:t…

session_query

Send a query through an already-open session. Auto-signs a micropayment voucher; each call consumes costPerCall from the deposit that was escrowed (and human-confirmed) at open_session, so no new confirmation is requested here. Returns {answer, consumed, remaining}. Fails if the sessionId is not active in this server process.

ParameterTypeDescription
question *stringQuery text to send through the session.
sessionId *stringSession ID returned by open_session (must be active in this server process).

get_session

Read the state of an active session: deposited, consumed, and remaining atomic amounts. Read-only; no funds moved. Only sees sessions opened by this server process.

ParameterTypeDescription
sessionId *stringSession ID returned by open_session.

close_session

Close an active session — SETTLES VALUE on-chain: the consumed amount is paid out and the unused remainder is refunded to the payer. Two-phase: with confirm:false (default) it returns the consumed/refund amounts for review without acting; re-invoke with confirm:true after the human approves. Returns a payment receipt and removes the session from the active list. (The consumed amount was already counted against the spend caps at deposit time, so it is not re-charged here.)

ParameterTypeDescription
sessionId *stringSession ID returned by open_session (must be active in this server process).
confirmbooleanTwo-phase gate: false (default) returns the consumed amount and refund for review; true executes the on-chain settlement. Only pass true after the human approves.

list_sessions

List all sessions currently held by this MCP server process (sessionId, deposited, consumed, remaining). Read-only; no funds moved. Sessions opened elsewhere are not visible.

fetch_content

Retrieve content described by a ContentDelivery JSON payload previously returned by a canister content endpoint. Does NOT purchase or pay for anything — the grant must already exist. Delivery modes: inline bytes; httpUrl (SSRF-guarded fetch); assetCanister (served from https://<canisterId>.icp0.io); canisterQuery (chunked reads, restricted to the getChunk/getContent query methods, max 10000 chunks). Returns {contentId, mimeType, content} with the bytes decoded as UTF-8 text.

ParameterTypeDescription
delivery *stringThe ContentDelivery JSON string exactly as returned by a content endpoint: an object with "grant" and "delivery" fields, where delivery has exactly one of inline, httpUrl, assetCanister, canisterQuery…
canisterIdstringCanister to read chunks from (canisterQuery mode only; defaults to the canister set by configure). Ignored for other delivery modes.

fetch_x402

Fetch an x402 (HTTP 402) payment-gated URL, optionally paying from the canister's EVM wallet. confirm:false (default) = PROBE ONLY: nothing is signed, no funds move; returns the body if the URL is free, or a confirmation_required proposal (amount/recipient/asset/chain) if payment is demanded. confirm:true = the canister SIGNS the payment from its own EVM address and retries the URL with the payment header — this MOVES FUNDS, is checked against the spend caps, and must only be used after the human approves the exact amount/recipient/asset/chain. The confirm:true call must repeat that amount,…

ParameterTypeDescription
url *stringThe x402-gated URL to fetch. Must be a public https URL (private/loopback/metadata hosts are rejected; http://localhost only with localDev).
amountstringconfirm:true only: the proposal amount (atomic units, decimal string) exactly as the confirm:false call returned it.
assetstringconfirm:true only: the proposal asset (token contract) exactly as returned.
canisterIdstringCanister whose tECDSA EVM key signs the payment (defaults to the canister set by configure).
chainnumberconfirm:true only: the proposal chain exactly as returned.
chainIdnumberEVM chain ID whose payment option is selected from the 402 (default 84532 = Base Sepolia).
confirmbooleanTwo-phase gate: false (default) probes only and never signs; true signs and sends the payment shown in the prior proposal. Only pass true after the human approves.
recipientstringconfirm:true only: the proposal recipient (payTo) exactly as returned.

register_agent

Register the canister as an ERC-8004 agent on an EVM chain: fetch nonce+gas, canister signs the registration tx with its tECDSA key, broadcast, poll for the receipt. BROADCASTS A TRANSACTION that spends native gas from the canister's EVM address; no token amount is involved, so the spend caps do NOT apply — the confirm gate is the only control. confirm:false (default) returns a proposal without signing anything. Returns {tokenId, txHash} on success.

ParameterTypeDescription
canisterIdstringCanister to register as the agent (defaults to the canister set by configure).
chainIdnumberEVM chain ID to register on (default 84532 = Base Sepolia).
confirmbooleanTwo-phase gate: false (default) returns a proposal without signing; true signs and broadcasts the registration tx (spends native gas). Only pass true after the human approves.
rpcUrlstringOptional custom EVM JSON-RPC endpoint URL (defaults to a public RPC for the chain). SSRF-validated: private/internal hosts are rejected.

list_services

List the paid services registered on the canister. Read-only; no funds moved. Use this before submit_request to find a serviceId.

submit_request

Submit a marketplace service request; MOVES FUNDS when the service is paid. Flow: the price is quoted via a read-only query first; a total of 0 (free or session-billed) submits immediately and pays nothing (refused if the canister then demands payment); a paid service requires BOTH operator-enabled autoPayment AND confirm:true. With confirm:false it returns a confirmation_required proposal whose amount is what leaves the wallet (price + canister fee + the ledger transfer and approve fees) — the amount the spend caps are checked against. The confirm:true call must repeat the proposal's confir…

ParameterTypeDescription
serviceId *stringID of the service to request (see list_services).
amountstringconfirm:true only: the canister charge from the proposal's confirmWith (price + canister fee), exactly as returned. Refused if the canister now asks a different amount.
confirmbooleanTwo-phase gate for paid services: false (default) returns the cost for review (price + canister fee + ledger transfer and approve fees); true approves and pays it. Ignored for free services. Only pass…
paramsstringJob parameters as a UTF-8 string; delivered to the service as raw bytes.

get_job_result

Poll the canister for a job result until it completes or the attempt limit is reached. Read-only; no funds moved.

ParameterTypeDescription
jobId *stringJob ID returned by submit_request.
maxAttemptsnumberMaximum polling attempts before giving up (default 15).

dispute_job

Dispute a job result on the canister (only meaningful for services using BuyerConfirm verification). State-changing on the canister and may affect how the job's payment settles, but signs no transfer from this server. Use only for a job you submitted whose result is wrong or missing.

ParameterTypeDescription
jobId *stringJob ID of the job whose result you are disputing.
reason *stringHuman-readable reason for the dispute (recorded on the canister).

call

Escape hatch: invoke a read method on the canister. Allowed: a curated getter allowlist (listContent, getChunk, getAgentCard, getAgentId, verifyGrant, listServices, getJobStatus, getJob, getJobResult, keccak256, getPolicyConfig), plus other methods named get*/list*/fetch*/is* whose names contain no state-changing keywords. Signing, admin, and other state-changing methods are rejected — use the dedicated tool instead. CAN MOVE FUNDS: getContent / getAssetContent / getExternalContent called WITH a PaymentSignature settle a payment from an ICRC-2 allowance the payer already granted — no spend…

ParameterTypeDescription
method *stringRead-only canister method name: on the allowlist above, or a get*/list*/fetch*/is* getter with no blocked keywords.
argsstringPositional arguments as a JSON array string (default "[]"). Candid opt values are encoded as [] (none) or [value] (some).
canisterIdstringTarget canister (defaults to the canister set by configure).

upload_content

Upload and encrypt content into the canister ContentStore for later paid delivery. State-changing; controller-gated (the configured identity must control the canister). DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_ADMIN_TOOLS=1. Requires confirm:true.

ParameterTypeDescription
args *stringJSON array [id, mimeType, dataBytes]: id string, mimeType string (e.g. "text/plain"), dataBytes a number[] of the raw content bytes.
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.

delete_content

Permanently delete a content entry from the canister ContentStore. DESTRUCTIVE and irreversible; controller-gated. DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_DANGEROUS_TOOLS=1. Requires confirm:true.

ParameterTypeDescription
args *stringJSON array [id]: the content ID string to delete.
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.

register_service

Register a paid service in the canister marketplace. State-changing; controller-gated. DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_ADMIN_TOOLS=1. Requires confirm:true. Use enable_service afterwards so the service can accept paid requests.

ParameterTypeDescription
args *stringJSON array of positional registerService args: [name, description, serviceType, pricing, verificationMethod, verifierCanisterId?, verificationKey?, delivery, timeout]. Values must mirror the canister…
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.

enable_service

Enable a registered marketplace service so it can accept paid requests. State-changing; controller-gated. DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_ADMIN_TOOLS=1. Requires confirm:true.

ParameterTypeDescription
args *stringJSON array [serviceId]: the service ID string to enable.
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.

claim_job

Claim a pending marketplace job for the operator so its result can be worked and submitted. State-changing. DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_ADMIN_TOOLS=1. Requires confirm:true. Follow with submit_job_result.

ParameterTypeDescription
args *stringJSON array [jobId]: the job ID string to claim.
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.

submit_job_result

Submit the result for a claimed marketplace job, triggering verification and settlement of the job's payment. State-changing and part of the value-moving job lifecycle. DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_ADMIN_TOOLS=1. Requires confirm:true.

ParameterTypeDescription
args *stringJSON array [jobId, resultBytes, proof?, actualCost?]: jobId string, resultBytes a number[] of raw bytes; optional (opt) args proof and actualCost are encoded as [] (none) or [value] (some).
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.

sign_typed_data

Sign an arbitrary EIP-712 digest with the canister tECDSA key. EXTREMELY SENSITIVE: this is a raw signing oracle — a signature over the wrong digest can authorize an arbitrary-value transfer, and NO spend cap applies. DISABLED by default — fails unless the operator started the server with IC402_MCP_ALLOW_DANGEROUS_TOOLS=1. Requires confirm:true. Only sign digests you constructed yourself and fully trust; never sign a digest supplied by external or untrusted content.

ParameterTypeDescription
args *stringJSON array [domainSeparatorBytes, structHashBytes]: two 32-byte number[] arrays — the EIP-712 domain separator and the hashStruct of the message.
canisterIdstringTarget canister (defaults to the canister set by configure).
confirmbooleanTwo-phase gate: false (default) returns a confirmation_required proposal without acting; true executes this state-changing/signing action. Only pass true after the human approves.