A minimal MCP server demonstrating cryptographic identity, proof generation, and tool protection.
From the repository root (kya-os-mcp/):
# Install dependencies
pnpm install
# Start the server (SSE on port 3001)
npx tsx examples/node-server/server.tsThen open MCP Inspector and connect:
- Transport Type: SSE
- URL:
http://localhost:3001/sse
Once connected in the Inspector, go to Tools and try the following:
Call greet with:
{
"name": "DIF"
}The response includes:
- Tool result:
Hello, DIF! _meta.proof— a detached Ed25519 proof containing:jws— compact JWS signature over the canonical payloadmeta.did— agent DID that signed itmeta.kid— key identifiermeta.requestHash/meta.responseHash— SHA-256 hashes of the canonical request/responsemeta.sessionId— session bindingmeta.nonce— replay protectionmeta.ts— signature timestamp
Sessions are created automatically — no manual handshake step needed. In production, KYA-OS-aware clients handle the handshake transparently.
Call restricted_greet with:
{
"name": "Agent"
}The server returns an KYA_NEEDS_AUTHORIZATION error with:
scopeId— the required delegation scope (greeting:restricted)consentUrl— where the user approves the delegationarchitecture— a 5-step explanation of the consent/delegation flow
This demonstrates how protected tools work in production:
- Agent calls restricted tool
- Server returns
KYA_NEEDS_AUTHORIZATIONwith consent URL - User approves delegation at the consent URL
- A Verifiable Credential (delegation) is issued
- Agent presents the delegation credential on the next call
For use with npx @modelcontextprotocol/inspector auto-connect:
npx @modelcontextprotocol/inspector npx tsx examples/node-server/server.ts --stdioOr run the server directly on stdio:
npx tsx examples/node-server/server.ts --stdioCopy the proof JSON from the _meta response and verify it:
echo '<proof-json>' | npx tsx examples/verify-proof/verify.tsClient (Inspector) Server (this example)
| |
|-- greet ------------------>| Auto-session created (or reused)
| | Tool executes
| | ProofGenerator signs (request, response, session)
|<-- result + _meta.proof ---| Detached JWS over canonical payload
| |
|-- restricted_greet ------->| Tool protection check
|<-- NEEDS_AUTHORIZATION ----| Returns scopeId + consentUrl + architecture
| |
| Tool | Description |
|---|---|
greet |
Returns a greeting with a detached Ed25519 proof via _meta |
restricted_greet |
Protected tool — returns KYA_NEEDS_AUTHORIZATION with delegation instructions |