@codespar/mcp-ap2
Advanced tools
+9
-0
@@ -23,2 +23,11 @@ #!/usr/bin/env node | ||
| * - list_transactions: List transactions with filters | ||
| * - create_intent_mandate: Create a Verifiable Credential intent mandate (user → agent intent to transact) | ||
| * - create_cart_mandate: Create a cart mandate (signed, locked-cart commitment) | ||
| * - create_payment_mandate: Create a payment mandate (final payment authorization VC) | ||
| * - verify_credential: Verify a Verifiable Credential (intent / cart / payment mandate) | ||
| * - create_presentation: Create a Verifiable Presentation bundling one or more credentials | ||
| * - verify_presentation: Verify a Verifiable Presentation and its embedded credentials | ||
| * - resolve_did: Resolve a Decentralized Identifier (DID) to its DID document | ||
| * - create_receipt: Create a signed receipt for a settled payment | ||
| * - verify_receipt: Verify a receipt's signature and integrity | ||
| * | ||
@@ -25,0 +34,0 @@ * Environment: |
+254
-2
@@ -23,2 +23,11 @@ #!/usr/bin/env node | ||
| * - list_transactions: List transactions with filters | ||
| * - create_intent_mandate: Create a Verifiable Credential intent mandate (user → agent intent to transact) | ||
| * - create_cart_mandate: Create a cart mandate (signed, locked-cart commitment) | ||
| * - create_payment_mandate: Create a payment mandate (final payment authorization VC) | ||
| * - verify_credential: Verify a Verifiable Credential (intent / cart / payment mandate) | ||
| * - create_presentation: Create a Verifiable Presentation bundling one or more credentials | ||
| * - verify_presentation: Verify a Verifiable Presentation and its embedded credentials | ||
| * - resolve_did: Resolve a Decentralized Identifier (DID) to its DID document | ||
| * - create_receipt: Create a signed receipt for a settled payment | ||
| * - verify_receipt: Verify a receipt's signature and integrity | ||
| * | ||
@@ -57,3 +66,3 @@ * Environment: | ||
| } | ||
| const server = new Server({ name: "mcp-ap2", version: "0.1.0" }, { capabilities: { tools: {} } }); | ||
| const server = new Server({ name: "mcp-ap2", version: "0.2.0-alpha.1" }, { capabilities: { tools: {} } }); | ||
| server.setRequestHandler(ListToolsRequestSchema, async () => ({ | ||
@@ -243,2 +252,139 @@ tools: [ | ||
| }, | ||
| { | ||
| name: "create_intent_mandate", | ||
| description: "Create an AP2 intent mandate — a Verifiable Credential expressing the user's intent to delegate a transaction to an agent (scope, constraints, expiry).", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| subjectDid: { type: "string", description: "DID of the user delegating intent" }, | ||
| agentDid: { type: "string", description: "DID of the agent receiving the intent" }, | ||
| scope: { type: "string", description: "Free-form scope (e.g. 'purchase running shoes under $200')" }, | ||
| maxAmount: { type: "string", description: "Maximum amount the agent can spend" }, | ||
| currency: { type: "string", description: "Currency code (e.g. 'USD')" }, | ||
| merchantAllowList: { type: "array", items: { type: "string" }, description: "Optional list of merchant DIDs/IDs the agent may transact with" }, | ||
| expiresAt: { type: "string", description: "Expiry timestamp (ISO 8601)" }, | ||
| metadata: { type: "object", description: "Custom metadata key-value pairs" }, | ||
| }, | ||
| required: ["subjectDid", "agentDid", "scope", "maxAmount", "currency"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "create_cart_mandate", | ||
| description: "Create an AP2 cart mandate — a signed, locked-cart commitment from a merchant binding line items, totals, and merchant attestation.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| intentMandateId: { type: "string", description: "Linked intent mandate VC ID" }, | ||
| merchantDid: { type: "string", description: "DID of the merchant" }, | ||
| items: { | ||
| type: "array", | ||
| items: { | ||
| type: "object", | ||
| properties: { | ||
| sku: { type: "string", description: "Product SKU" }, | ||
| name: { type: "string", description: "Item name" }, | ||
| quantity: { type: "number", description: "Quantity" }, | ||
| unitPrice: { type: "string", description: "Unit price" }, | ||
| }, | ||
| required: ["name", "quantity", "unitPrice"], | ||
| }, | ||
| description: "Cart line items", | ||
| }, | ||
| total: { type: "string", description: "Cart total amount" }, | ||
| currency: { type: "string", description: "Currency code" }, | ||
| expiresAt: { type: "string", description: "Cart expiry (ISO 8601)" }, | ||
| }, | ||
| required: ["intentMandateId", "merchantDid", "items", "total", "currency"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "create_payment_mandate", | ||
| description: "Create an AP2 payment mandate — the final Verifiable Credential authorizing settlement against a cart mandate.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| cartMandateId: { type: "string", description: "Linked cart mandate VC ID" }, | ||
| payerDid: { type: "string", description: "DID of the payer (typically the user)" }, | ||
| paymentMethodId: { type: "string", description: "Payment method ID to settle against" }, | ||
| amount: { type: "string", description: "Final payment amount" }, | ||
| currency: { type: "string", description: "Currency code" }, | ||
| metadata: { type: "object", description: "Custom metadata key-value pairs" }, | ||
| }, | ||
| required: ["cartMandateId", "payerDid", "amount", "currency"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "verify_credential", | ||
| description: "Verify a Verifiable Credential (intent, cart, or payment mandate). Checks signature, issuer trust, expiry, and revocation status.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| credential: { type: "object", description: "The Verifiable Credential JSON-LD object to verify" }, | ||
| credentialId: { type: "string", description: "Alternatively, the ID of a stored credential to verify" }, | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| name: "create_presentation", | ||
| description: "Create a Verifiable Presentation bundling one or more credentials (e.g. intent + cart + payment mandates) for a given audience/verifier.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| holderDid: { type: "string", description: "DID of the presentation holder" }, | ||
| credentialIds: { type: "array", items: { type: "string" }, description: "IDs of credentials to include" }, | ||
| audience: { type: "string", description: "Intended verifier DID or URI" }, | ||
| challenge: { type: "string", description: "Optional challenge nonce supplied by the verifier" }, | ||
| }, | ||
| required: ["holderDid", "credentialIds", "audience"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "verify_presentation", | ||
| description: "Verify a Verifiable Presentation and all embedded credentials, including holder binding and challenge nonce.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| presentation: { type: "object", description: "The Verifiable Presentation JSON-LD object" }, | ||
| challenge: { type: "string", description: "Expected challenge nonce, if used" }, | ||
| audience: { type: "string", description: "Expected audience (verifier DID)" }, | ||
| }, | ||
| required: ["presentation"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "resolve_did", | ||
| description: "Resolve a Decentralized Identifier (DID) to its DID document via the AP2 universal resolver.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| did: { type: "string", description: "The DID to resolve (e.g. 'did:web:merchant.example')" }, | ||
| }, | ||
| required: ["did"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "create_receipt", | ||
| description: "Create a signed receipt for a settled payment — a tamper-evident record linking transaction, mandates, and settlement.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| transactionId: { type: "string", description: "Settled transaction ID" }, | ||
| paymentMandateId: { type: "string", description: "Payment mandate VC ID" }, | ||
| notes: { type: "string", description: "Optional human-readable notes" }, | ||
| metadata: { type: "object", description: "Custom metadata key-value pairs" }, | ||
| }, | ||
| required: ["transactionId"], | ||
| }, | ||
| }, | ||
| { | ||
| name: "verify_receipt", | ||
| description: "Verify a receipt's signature, issuer, and chain back to the originating mandates.", | ||
| inputSchema: { | ||
| type: "object", | ||
| properties: { | ||
| receiptId: { type: "string", description: "Receipt ID to verify" }, | ||
| receipt: { type: "object", description: "Alternatively, the receipt object itself" }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
@@ -415,2 +561,108 @@ })); | ||
| } | ||
| case "create_intent_mandate": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/mandates/intent", { | ||
| subjectDid: args?.subjectDid, | ||
| agentDid: args?.agentDid, | ||
| scope: args?.scope, | ||
| maxAmount: args?.maxAmount, | ||
| currency: args?.currency, | ||
| merchantAllowList: args?.merchantAllowList, | ||
| expiresAt: args?.expiresAt, | ||
| metadata: args?.metadata, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "create_cart_mandate": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/mandates/cart", { | ||
| intentMandateId: args?.intentMandateId, | ||
| merchantDid: args?.merchantDid, | ||
| items: args?.items, | ||
| total: args?.total, | ||
| currency: args?.currency, | ||
| expiresAt: args?.expiresAt, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "create_payment_mandate": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/mandates/payment", { | ||
| cartMandateId: args?.cartMandateId, | ||
| payerDid: args?.payerDid, | ||
| paymentMethodId: args?.paymentMethodId, | ||
| amount: args?.amount, | ||
| currency: args?.currency, | ||
| metadata: args?.metadata, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "verify_credential": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/credentials/verify", { | ||
| credential: args?.credential, | ||
| credentialId: args?.credentialId, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "create_presentation": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/presentations", { | ||
| holderDid: args?.holderDid, | ||
| credentialIds: args?.credentialIds, | ||
| audience: args?.audience, | ||
| challenge: args?.challenge, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "verify_presentation": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/presentations/verify", { | ||
| presentation: args?.presentation, | ||
| challenge: args?.challenge, | ||
| audience: args?.audience, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "resolve_did": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("GET", `/did/resolve/${encodeURIComponent(String(args?.did))}`), null, 2), | ||
| }], | ||
| }; | ||
| case "create_receipt": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/receipts", { | ||
| transactionId: args?.transactionId, | ||
| paymentMandateId: args?.paymentMandateId, | ||
| notes: args?.notes, | ||
| metadata: args?.metadata, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| case "verify_receipt": | ||
| return { | ||
| content: [{ | ||
| type: "text", | ||
| text: JSON.stringify(await ap2Request("POST", "/receipts/verify", { | ||
| receiptId: args?.receiptId, | ||
| receipt: args?.receipt, | ||
| }), null, 2), | ||
| }], | ||
| }; | ||
| default: | ||
@@ -442,3 +694,3 @@ return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true }; | ||
| transports.delete(t.sessionId); }; | ||
| const s = new Server({ name: "mcp-ap2", version: "0.1.0" }, { capabilities: { tools: {} } }); | ||
| const s = new Server({ name: "mcp-ap2", version: "0.2.0-alpha.1" }, { capabilities: { tools: {} } }); | ||
| server._requestHandlers.forEach((v, k) => s._requestHandlers.set(k, v)); | ||
@@ -445,0 +697,0 @@ server._notificationHandlers?.forEach((v, k) => s._notificationHandlers.set(k, v)); |
+1
-1
| { | ||
| "name": "@codespar/mcp-ap2", | ||
| "version": "0.1.2", | ||
| "version": "0.2.0-alpha.1", | ||
| "description": "MCP server for AP2 — Google's Agent-to-Agent Payment Protocol (authorization, audit, trust)", | ||
@@ -5,0 +5,0 @@ "type": "module", |
43147
49.7%753
53.05%