KLAIM MCP server
by Omicron6
README.md
# KLAIM
### Pay-Per-Use Human Verification API for AI Agents
> **Verify users without exposing their documents.**
KLAIM is a privacy-first verification infrastructure that allows applications and AI agents to verify claims about a user โ such as **Age > 18** โ without receiving the user's underlying identity documents or raw PII.
[](https://algorand.com/)
[](https://www.x402.org/)
[](https://modelcontextprotocol.io/)
[](https://midnight.network/)
---
## ๐ What is KLAIM?
Modern applications increasingly need to verify that a user is eligible for a service.
For example:
- Is this user over 18?
- Is this user a resident of a particular country?
- Does this user possess a valid credential?
- Has this user completed a required verification?
- Is this a verified human?
The traditional approach is to collect the actual identity document.
That creates a major privacy problem.
An application may only need to know:
```text
Age > 18 = TRUE
````
but instead receives:
```text
Name
Date of Birth
Address
Aadhaar/PAN information
Document number
Issuer information
Full document
```
### KLAIM changes this model.
Instead of applications receiving documents, KLAIM exposes a **pay-per-use human verification API**.
The application or AI agent asks:
```text
"Is this person over 18?"
```
KLAIM performs the verification internally and returns:
```json
{
"verified": true,
"claim": "AGE_OVER_18"
}
```
The underlying credential and personal information remain private.
> **KLAIM sells verification, not identity data.**
## ๐ Verified Algorand Testnet Transactions
KLAIM uses the **x402 payment protocol** to enable pay-per-use human verification.
For the MVP, payments are settled in **USDC on Algorand Testnet**. The following transactions are real on-chain transfers from the **payer wallet โ provider wallet**, each representing a **0.01 USDC verification payment**.
> These are not simulated transaction IDs. They are real Algorand Testnet transactions and can be independently verified using the AlgoKit Lora explorer.
### Live x402 Payment Evidence
| # | Amount | Network | Flow | Transaction |
|---|---:|---|---|---|
| 1 | 0.01 USDC | Algorand Testnet | Payer โ Provider | [View on Lora](https://lora.algokit.io/testnet/transaction/NFK244G4UE5OEBFXQEK4CFSFPZLLHLBOANA3IA47ACHYB2YIUF5Q) |
| 2 | 0.01 USDC | Algorand Testnet | Payer โ Provider | [View on Lora](https://lora.algokit.io/testnet/transaction/7LI27EZD7MZZYZKMTE4IMIQDPDD3BOPB5TPJURM7CIIYL2VROKZA) |
| 3 | 0.01 USDC | Algorand Testnet | Payer โ Provider | [View on Lora](https://lora.algokit.io/testnet/transaction/C7DO3LR4ZCTVP2IMATXQFDCSYPW2NE2ZATNREQ65G7ZOJUPOEL5A) |
| 4 | 0.01 USDC | Algorand Testnet | Payer โ Provider | [View on Lora](https://lora.algokit.io/testnet/transaction/4CSDN7BOSMTCCXMOKGNGNLITPSULC5H4OAZKK7OAHQROSX4ZIQ4A) |
### What This Demonstrates
The payment layer is designed around the following flow:
```text
AI Agent
โ
โ MCP tool call
โผ
KLAIM Verification API
โ
โ No payment
โผ
HTTP 402 Payment Required
โ
โ x402 payment requirements
โผ
AI Agent / Payer Wallet
โ
โ Sign USDC payment
โผ
GoPlausible Facilitator
โ
โ Verify + settle
โผ
Algorand Testnet
โ
โ Real USDC transaction
โผ
Provider Wallet
โ
โ Settlement confirmed
โผ
KLAIM Verification
โ
โผ
Verified Claim
---
# ๐ฏ Problem
Digital onboarding and AI-agent workflows have three major problems.
### 1. Over-collection of personal information
Applications collect complete identity documents even when they only need one attribute.
### 2. AI agents cannot easily perform trusted identity verification
AI agents can interact with APIs and tools, but identity verification still requires manual document workflows.
### 3. Verification APIs are not naturally machine-payable
Traditional verification providers usually depend on subscriptions, accounts, billing systems, or manual payment workflows.
KLAIM combines:
* **MCP** for AI-agent interoperability
* **x402** for machine-to-machine payments
* **Algorand** for on-chain settlement
* **DID / VC** for identity
* **Zero-Knowledge Proofs** for privacy-preserving verification
into a single verification infrastructure layer.
---
# ๐ก The Core Idea
KLAIM separates identity from verification.
### Traditional Verification
```text
User
โ
โ Upload document
โผ
Application
โ
โโโ Name
โโโ DOB
โโโ Address
โโโ ID Number
โโโ Full Document
```
### KLAIM Archetecture
<img width="1536" height="695" alt="architecture-klaim" src="https://github.com/user-attachments/assets/381f3c8c-bcd3-4ad3-85de-d7c2fa3c2c8c" />
```text
User
โ
โ Credential + Consent
โผ
KLAIM
โ
โ Verify privately
โ
โ ZK Proof
โผ
Application / AI Agent
โ
โโโ "AGE > 18 = TRUE"
```
The application receives the **answer**, not the document.
---
# ๐๏ธ Architecture
```mermaid
flowchart TD
H[Human User]
DL[DigiLocker / Credential Issuer]
DID[DID + Verifiable Credential]
H -->|Consent| DL
DL -->|Credential| DID
A[AI Agent<br/>Claude / GPT / Custom Agent]
MCP[KLAIM MCP Server]
X402[x402 Payment Middleware]
FAC[GoPlausible Facilitator]
ALGO[Algorand Testnet]
API[Verification API]
PA[Provider Agent<br/>Strands]
ZK[ZK Proof Engine<br/>Midnight-ready]
RESULT[Verified Claim<br/>No Raw PII]
A -->|MCP Tool Call| MCP
MCP --> API
API --> X402
X402 -->|402 Payment Required| A
A -->|USDC Payment| X402
X402 --> FAC
FAC --> ALGO
ALGO -->|Settlement TX| X402
X402 --> API
API --> PA
PA -->|Check DID| DID
PA -->|Check Credential| DID
PA -->|Check Claim| DID
PA --> ZK
ZK --> RESULT
RESULT --> API
API --> MCP
MCP --> A
```
---
# ๐ Complete Verification Flow
## 1. Human onboarding
The user connects their identity credential source.
For the MVP, DigiLocker is the intended credential source.
```text
Human
โ
โผ
DigiLocker
โ
โผ
Credential
โ
โผ
KLAIM DID
```
KLAIM stores credential references and derived claims rather than exposing complete identity documents to verification consumers.
---
## 2. AI Agent connects through MCP
AI agents connect to KLAIM through the **Model Context Protocol (MCP)**.
```text
Claude / GPT / Custom Agent
โ
โ MCP
โผ
KLAIM MCP Server
```
The MCP server exposes verification tools such as:
```text
verify_human_age
```
An agent can therefore request:
```text
Verify whether DID xyz is over 18.
```
---
## 3. Agent authentication
Every verifier receives a unique KLAIM agent credential.
Example:
```text
Agent ID:
agent_xxxxxxxxx
Agent Key:
klm_xxxxxxxxxxxxxxxxx
```
The key is:
* generated by KLAIM
* displayed once
* hashed before storage
* revocable
* rotatable
---
# 4. Verification Request
The MCP tool calls the protected verification API.
```http
POST /api/v1/verify/age
```
Example:
```json
{
"did": "did:klaim:demo-user-001"
}
```
---
# 5. x402 Payment Boundary
The verification API is protected by **x402**.
If no valid payment is attached:
```http
HTTP/1.1 402 Payment Required
```
The x402 layer provides the payment requirements required by the client.
The flow becomes:
```text
AI Agent
โ
โ POST /verify/age
โผ
KLAIM
โ
โ HTTP 402
โผ
AI Agent
โ
โ Prepare payment
โผ
x402
```
---
# 6. USDC Payment
The verifier agent pays for the verification using USDC on **Algorand Testnet**.
```text
AI Agent
โ
โ USDC
โผ
x402
โ
โผ
GoPlausible Facilitator
โ
โผ
Algorand Testnet
```
The payment is settled on-chain.
A successful verification contains the settlement transaction ID.
Example:
```json
{
"payment": {
"txId": "REAL_ALGORAND_TX_ID",
"explorerUrl": "https://lora.algokit.io/testnet/transaction/..."
}
}
```
---
# 7. Provider Agent
Only after successful payment settlement does the verification pipeline execute.
The KLAIM Provider Agent is designed around the **Strands Agents SDK**, with a deterministic fallback for the MVP.
The verification pipeline is:
```text
check_did
โ
check_credential
โ
check_claim
โ
generate_zk_proof
โ
verify_zk_proof
```
### Critical invariant
```text
NO PAYMENT
โ
NO VERIFICATION
```
The verification business logic does not execute before the payment boundary succeeds.
---
# 8. Credential Verification
The Provider Agent checks whether the requested credential exists for the user's DID.
For example:
```text
Requested:
AGE > 18
Available:
DigiLocker Credential
โ
โโโ DOB available
```
The required claim is derived internally.
The actual DOB is never returned to the verifier.
---
# 9. Zero-Knowledge Verification
KLAIM follows a simple principle:
> **Prove the claim without revealing the underlying data.**
Instead of exposing:
```text
Date of Birth:
12/03/2002
```
KLAIM aims to produce a proof of:
```text
AGE > 18
```
The verifier only needs:
```text
verified = true
```
The architecture contains a ZK abstraction layer designed to connect with a Midnight prover.
Current MVP architecture:
```text
ZK Service
โ
โโโ Local / deterministic engine
โ
โโโ Midnight prover integration point
```
The system explicitly identifies the proof engine rather than falsely representing a local simulation as production cryptographic ZK.
---
# ๐ Privacy Model
KLAIM follows a **minimum-disclosure architecture**.
### Data that remains private
```text
Name
Date of Birth
Address
Aadhaar
PAN
Document Number
Raw Identity Document
```
### Data returned
```text
Verification Result
Claim
Proof Descriptor
Payment Receipt
Algorand Transaction ID
```
Example:
```json
{
"verified": true,
"claim": "AGE_OVER_18",
"proof": {
"type": "zk",
"notDisclosed": [
"date_of_birth",
"name",
"address",
"document"
]
}
}
```
---
# ๐ค AI Agent Architecture
KLAIM is designed specifically for machine-to-machine verification.
```mermaid
sequenceDiagram
participant C as Claude / AI Agent
participant M as KLAIM MCP
participant API as Verification API
participant X as x402
participant F as GoPlausible
participant A as Algorand
participant P as Provider Agent
participant Z as ZK Engine
C->>M: verify_human_age(DID)
M->>API: POST /verify/age
API->>X: Check payment
X-->>C: HTTP 402 + requirements
C->>X: Signed USDC payment
X->>F: Verify + settle
F->>A: Algorand Testnet settlement
A-->>F: Transaction ID
F-->>X: Settlement successful
X->>API: Payment verified
API->>P: Start verification
P->>P: Check DID
P->>P: Check credential
P->>P: Evaluate claim
P->>Z: Generate / verify proof
Z-->>P: Proof
P-->>API: Verified claim
API-->>M: Result + TX ID
M-->>C: Verified claim
```
---
# ๐งฉ Why MCP?
Without MCP, every AI agent would require a custom KLAIM integration.
```text
Claude โ Custom SDK
GPT โ Custom SDK
Agent X โ Custom SDK
Agent Y โ Custom SDK
```
With MCP:
```text
Claude
GPT
Custom Agent
โ
โผ
MCP
โ
โผ
KLAIM
```
KLAIM becomes a reusable verification capability that AI agents can discover and invoke.
---
# ๐ฐ Why x402?
x402 enables HTTP-native machine payments.
The agent does not need:
* subscriptions
* manual checkout
* credit-card forms
* human billing intervention
Instead:
```text
Request
โ
402
โ
Pay
โ
Retry
โ
Verification
```
This creates a natural model for **pay-per-verification APIs**.
---
# ๐ Why Algorand?
Algorand is used as the settlement network for the MVP because it provides:
* fast settlement
* low transaction costs
* USDC support
* accessible testnet infrastructure
* independently verifiable transactions
The payment receipt can be inspected on Algorand Testnet.
---
# โญ USP
## KLAIM is not another identity dashboard.
KLAIM is a **verification infrastructure layer for AI agents**.
### Traditional identity verification
```text
Application
โ
โผ
Identity Provider
โ
โผ
Upload Document
โ
โผ
PII Processing
โ
โผ
Verification
```
### KLAIM
```text
AI Agent
โ
โผ
MCP
โ
โผ
x402 Payment
โ
โผ
KLAIM
โ
โโโ DID / Credential
โโโ Provider Agent
โโโ ZK Proof
โ
โผ
Boolean Verification
```
### The key difference
> **KLAIM sells verification, not identity data.**
---
# ๐ฅ Product Roles
## Human
The human controls their identity.
Capabilities:
* Create / manage DID
* Connect credentials
* View credentials
* Delete credentials
* Manage verification permissions
* View verification history
The human does not pay for verification.
---
## Verifier
The verifier represents an application or AI agent.
Capabilities:
* Create AI agents
* Generate MCP credentials
* Rotate / revoke agent keys
* Connect MCP to Claude
* Request verification
* Monitor x402 payments
* View transaction history
* View verification activity
---
# ๐ Agent Authentication
KLAIM generates unique credentials for verifier agents.
Example:
```text
Agent ID
agent_xxxxxxxxx
Agent Key
klm_xxxxxxxxxxxxxxxxx
```
The raw key is shown once.
KLAIM stores a SHA-256 hash of the key.
```text
Agent Key
โ
โผ
SHA-256
โ
โผ
Stored Hash
```
---
# ๐๏ธ Project Structure
```text
KLAIM/
โ
โโโ src/
โ โโโ routes/
โ โ โโโ api/
โ โ โ โโโ public/
โ โ โ โ โโโ mcp.ts
โ โ โ โ
โ โ โ โโโ v1/
โ โ โ โโโ verify/
โ โ โ โ โโโ age.ts
โ โ โ โโโ agents.ts
โ โ โ โโโ credentials.ts
โ โ โ โโโ digilocker.ts
โ โ โ โโโ integrations.ts
โ โ โ โโโ transactions.ts
โ โ โ
โ โ โโโ human.*
โ โ โโโ verifier.*
โ โ โโโ index.tsx
โ โ
โ โโโ lib/
โ โ โโโ klaim/
โ โ โโโ server/
โ โ โ โโโ mcp.server.ts
โ โ โ โโโ x402.server.ts
โ โ โ โโโ provider-agent.server.ts
โ โ โ โโโ zkp.server.ts
โ โ โ โโโ digilocker.server.ts
โ โ โ โโโ store.server.ts
โ โ โ โโโ env.server.ts
โ โ โ
โ โ โโโ api.ts
โ โ โโโ services.ts
โ โ โโโ types.ts
โ โ โโโ mock-data.ts
โ โ
โ โโโ components/
โ โโโ app/
โ โโโ ui/
โ โโโ klaim-landing.tsx
โ
โโโ scripts/
โ โโโ provision-agent.ts
โ โโโ test-x402.ts
โ
โโโ tests/
โ โโโ mcp-x402-flow.test.ts
โ
โโโ .env.example
โโโ package.json
โโโ README.md
```
---
# ๐ ๏ธ Technology Stack
| Layer | Technology |
| ----------------- | -------------------------------- |
| Frontend | React |
| Framework | TanStack Start |
| Routing | TanStack Router |
| Styling | Tailwind CSS |
| UI | shadcn/ui / Radix |
| Backend | Nitro / TanStack server routes |
| Language | TypeScript |
| Runtime | Bun / Node |
| AI Agent | Strands Agents SDK |
| AI Integration | MCP |
| Payment | x402 |
| Facilitator | GoPlausible |
| Blockchain | Algorand Testnet |
| Payment Asset | USDC |
| Identity | DID / VC |
| Credential Source | DigiLocker |
| ZK Layer | Midnight-ready abstraction |
| State | Repository-based ephemeral store |
---
# ๐งช Running Locally
## Requirements
Install:
* Node.js or Bun
* Git
* Claude Desktop (optional for MCP testing)
Clone the repository:
```bash
git clone <YOUR_GITHUB_REPOSITORY_URL>
cd KLAIM
```
Install dependencies:
```bash
npm install
```
or:
```bash
bun install
```
Create your environment file:
```bash
cp .env.example .env
```
Start the development server:
```bash
npm run dev
```
The application will be available at:
```text
http://localhost:8080
```
---
# ๐ Testing MCP
The MCP endpoint is:
```text
http://localhost:8080/api/public/mcp
```
The MCP server supports:
```text
initialize
ping
tools/list
tools/call
```
The main verification tool is:
```text
verify_human_age
```
---
# ๐ค Connect Claude Desktop
After provisioning a KLAIM verifier agent, configure Claude Desktop with:
```json
{
"mcpServers": {
"klaim": {
"type": "http",
"url": "http://localhost:8080/api/public/mcp",
"headers": {
"X-KLAIM-Agent-Id": "YOUR_AGENT_ID",
"Authorization": "Bearer YOUR_AGENT_KEY"
}
}
}
}
```
Restart Claude Desktop.
Then ask:
```text
Use KLAIM to verify whether did:klaim:demo-user-001 is over 18.
```
Claude should discover and invoke:
```text
verify_human_age
```
---
# ๐ณ Testing x402
Configure the required Algorand Testnet wallets.
The complete flow is:
```text
POST /api/v1/verify/age
โ
โผ
HTTP 402
โ
โผ
Payment Requirements
โ
โผ
USDC Payment
โ
โผ
GoPlausible
โ
โผ
Algorand Testnet
โ
โผ
Settlement TX
โ
โผ
Provider Agent
โ
โผ
Verification
โ
โผ
HTTP 200
```
Run the independent x402 test client:
```bash
npm run test:x402
```
A successful result should contain a real Algorand Testnet transaction ID.
---
# ๐ Algorand Testnet Transaction
A successful KLAIM x402 transaction can be independently verified using Lora.
### Example
Replace the placeholder below with an actual transaction generated by the project:
```text
https://lora.algokit.io/testnet/transaction/YOUR_REAL_TX_ID
```
> **Important:** The transaction link above must be replaced with a real KLAIM transaction before final submission.
---
# ๐งช Complete Demo Flow
Run the system in the following order.
### Terminal 1 โ Start KLAIM
```bash
npm run dev
```
### Terminal 2 โ Provision an agent
```bash
npx tsx scripts/provision-agent.ts
```
Store the generated:
```text
KLAIM_AGENT_ID
KLAIM_AGENT_KEY
```
in the appropriate environment/configuration.
### Terminal 3 โ Execute x402 test
```bash
npm run test:x402
```
Then connect Claude Desktop to:
```text
/api/public/mcp
```
Ask Claude:
```text
Verify whether the user is over 18 using KLAIM.
```
Expected architecture:
```text
Claude
โ
MCP
โ
KLAIM
โ
HTTP 402
โ
USDC Payment
โ
GoPlausible
โ
Algorand Testnet
โ
Provider Agent
โ
Credential Verification
โ
ZK Proof
โ
Verified Claim
โ
Claude
```
---
# ๐ Security & Privacy
KLAIM is designed around data minimization.
### KLAIM does not expose:
```text
โ Aadhaar number
โ PAN number
โ Date of Birth
โ Address
โ Raw identity document
โ Private wallet keys
โ Agent private credentials
```
### KLAIM exposes:
```text
โ Verification result
โ Claim
โ Proof metadata
โ Payment receipt
โ Algorand transaction ID
```
---
# โ ๏ธ MVP Status
KLAIM is currently an MVP / hackathon implementation.
The architecture intentionally separates production integrations behind service interfaces.
### Implemented
* Human / Verifier role separation
* DID-oriented identity model
* Credential management
* MCP server
* MCP authentication
* MCP tool discovery
* Verification API
* x402 payment boundary
* Algorand Testnet settlement flow
* GoPlausible facilitator integration
* Provider Agent architecture
* Strands integration point
* ZK abstraction
* DigiLocker integration interface
* Agent provisioning
* Agent key rotation / revocation
* Verification history
* Transaction history
### Integration-dependent
```text
DigiLocker production credentials
โ
Official DigiLocker OAuth / issuer integration
Midnight prover
โ
MIDNIGHT_PROVER_URL
Strands / Bedrock
โ
AWS credentials + model configuration
```
These integrations can be enabled without changing the core MCP and x402 architecture.
---
# ๐ Roadmap
## Phase 1 โ MVP
```text
โ MCP
โ x402
โ Algorand Testnet
โ USDC settlement
โ Agent authentication
โ Credential abstraction
โ Provider Agent
โ Verification API
โ ZK abstraction
```
## Phase 2 โ Production Identity
```text
DigiLocker production integration
โ
Verifiable Credentials
โ
DID interoperability
```
## Phase 3 โ Production ZK
```text
Midnight prover
โ
Cryptographically verifiable claims
```
## Phase 4 โ Agent Economy
KLAIM can become a general-purpose verification marketplace for autonomous agents.
Potential APIs:
```text
verify_age
verify_residency
verify_credential
verify_student_status
verify_business_registration
verify_human
```
Each verification becomes a machine-payable API.
---
# ๐ Use Cases
### Age-restricted applications
```text
AI Agent
โ
KLAIM
โ
AGE > 18
```
No DOB is exposed.
### Financial onboarding
```text
AI Agent
โ
KLAIM
โ
Credential Valid
```
The application does not need the complete identity document.
### Education
```text
AI Agent
โ
KLAIM
โ
Student Credential = TRUE
```
### Human-only services
```text
AI Agent
โ
KLAIM
โ
Human Verification
```
---
# ๐ Why KLAIM?
Most identity systems ask:
> **"Who is this person?"**
KLAIM asks:
> **"Can I verify the one thing I need to know without seeing everything else?"**
KLAIM combines:
```text
Privacy-Preserving Verification
+
AI Agent Interoperability
+
Pay-Per-Use Payments
+
Zero-Knowledge Architecture
+
On-Chain Settlement
```
into a single verification API.
---
# ๐ License
MIT
---
## KLAIM
### Human Verification Infrastructure for the Agent Economy
> **Don't send the document.**
>
> **Prove the claim.**
```
```
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues