Skip to content

Add example: agent identity verification before x402 payment - #142

Open
saneGuy wants to merge 2 commits into
edgeandnode:mainfrom
saneGuy:example/agent-identity-gate
Open

Add example: agent identity verification before x402 payment#142
saneGuy wants to merge 2 commits into
edgeandnode:mainfrom
saneGuy:example/agent-identity-gate

Conversation

@saneGuy

@saneGuy saneGuy commented Jun 28, 2026

Copy link
Copy Markdown

Summary

Adds an example service that verifies an AI agent's identity and permissions before accepting x402 payments. Follows the pattern of existing examples (e.g., fastmcp-x402-server).

The problem: ampersend manages x402 payments, but any wallet-equipped agent can pay for a service. There's no standard way to check whether the agent behind the wallet is authorized to access the endpoint.

What this example does:

  • Runs a FastMCP-based x402 server with an identity verification gate
  • Before serving a paid request, verifies the agent holds a valid operator-signed credential with the required permissions
  • Uses zero-knowledge proofs so the agent proves authorization without exposing its operator's secrets
  • Includes a CLI tool for testing the full flow

Files added:

  • typescript/examples/agent-identity-gate/src/server.ts — MCP server with identity gate
  • typescript/examples/agent-identity-gate/src/identity.ts — identity verification logic
  • typescript/examples/agent-identity-gate/src/cli.ts — CLI for testing
  • typescript/examples/agent-identity-gate/src/index.ts — entry point
  • typescript/examples/agent-identity-gate/README.md — setup and usage
  • typescript/examples/agent-identity-gate/package.json — dependencies

Uses @bolyra/sdk for the identity verification layer. Related to #119 (seller-side server patterns).

Test plan

  • npm install in the example directory
  • npm run build compiles cleanly
  • npm start runs the server with identity verification
  • npm run cli tests the full authorize → pay → serve flow

saneGuy and others added 2 commits June 28, 2026 16:58
Signed-off-by: lordviswa <lordviswa@lordviswas-MacBook-Air.local>
- Remove @bolyra/sdk from dependencies (was never imported)
- Remove @edgeandnode/ scope from package name
- Replace Bolyra-specific types with generic IdentityVerifier<TProof> interface
- Fix payment as any cast: read agent proof from context.requestMetadata
- Trim README: less Bolyra, more generic, honest about structural-only stub
- Separate identity verification (withIdentityGate) from payment settlement

Signed-off-by: Viswanadha Pratap Kondoju <kondojuviswanadha@gmail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Viswanadha Pratap Kondoju <kondojuviswanadha@gmail.com>
@saneGuy
saneGuy force-pushed the example/agent-identity-gate branch from 0089a48 to ba132d8 Compare June 28, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant