BonafideMCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
BonafideMCP
Concept implementation of agent verification using multi-turn MCP challenges.
BonafideMCP is named after the documents that secret agents carry to prove their 'bona fide' identities.
BonafideMCP is an open-source MCP server that demonstrates how MCP's sampling/createMessage primitive could be used to conduct multi-turn, chained verification challenges — verifying that a connecting system is a genuine AI agent with an LLM runtime, not a human or a classic bot. This is a concept test and should not be used for real authentication.
The Idea
CAPCTHA systems are used to keep bots out of websites, proving the client system is really a human. But what if you want to keep humans out and only allow AI Agents?
For this project, we define an AI Agent (i.e. AI Application) as a system that is being driven by an LLM and implements the features outlines in the MCP specification. This definition is a moving target.
There are several recent implementations of reverse CAPTCHAs such as MoltCaptcha, Clawptcha, and BOTCHA. These systems use a single HTTP challenge-response protocol and heavily rely on timing (an important measure in all Auth frameworks) to validate if the responder was human or AI. In this system, we implement an MCP-native authentication protocol that issues a series of challenges, all building on the prior response. This multi-turn conversation increases the ability to detect timing signals from a non-AI actor (or man-in-the-middle).
For the MCP protocol, we take advantage of the new sampling/createMessage primitive which allows AI Applications to prompt their LLMs to support an MCP server's prompt. If the AI Application does not implement sampling (it's new and has security concerns of its own) then the protocol has a fallback to standard tool call/response. The challenge types are designed to not require an LLM for validation, but still be answers only an LLM could have provided. The completed challenges plus the associated latency is used for final validation. Once validated, the signed jwt is posted as an MCP resource to token/{session_id}.
Related MCP server: AgentTrust MCP Server
Quick Start
npm install bonafide-mcpAdd to your MCP client
{
"mcpServers": {
"bonafide": {
"command": "npx",
"args": ["bonafide-mcp"]
}
}
}Run directly
npx bonafide-mcpHow It Works
Sampling Mode (Preferred)
When the connecting client declares Sampling support, verification runs automatically within a single agent_verification tool call:
Agent BonafideMCP Server
│ tools/call: "agent_verification" │
│ ───────────────────────────────────▸│ Starts timer
│ │
│ sampling/createMessage (Round 1) │
│ ◂───────────────────────────────────│ Constrained text challenge
│ Response ─────────────────────────▸│ Verify deterministically
│ │
│ sampling/createMessage (Round 2) │
│ ◂───────────────────────────────────│ Depends on Round 1
│ Response ─────────────────────────▸│ Verify deterministically
│ │
│ sampling/createMessage (Round 3) │
│ ◂───────────────────────────────────│ Depends on Round 2
│ Response ─────────────────────────▸│ Verify · Stop timer
│ │
│ Tool result: ✓ verified │
│ { token_uri: "bonafide://..." } │
│ ◂───────────────────────────────────│Tool-Based Fallback
When Sampling isn't available, verification falls back to a tool-based flow where challenges are embedded in tool responses:
Agent → tools/call: "agent_verification" → gets Round 1 challenge
Agent → tools/call: "submit_response" → gets Round 2 challenge
Agent → tools/call: "submit_response" → gets Round 3 challenge or resultSame challenges, same chaining, but reduced proxy resistance (closer to HTTP-based).
Tools
Tool | Description |
| Start verification. Accepts |
| Submit a challenge response (tool-based fallback only). |
| Check verification status for a session. |
Resources
URI | Description |
| Signed JWT credential (available after passing verification). |
| Session status metadata. |
Challenge Types
Constrained Text Generation (SMHL-Inspired)
Generate text satisfying simultaneous semantic and structural constraints: a topic, a starting letter, an exact word count, and a required keyword. Adapted from MoltCaptcha's SMHL approach.
Computed-Field Structured Output
Produce a JSON object where some fields require world knowledge (a real city, its country) and others are mathematical derivations (letter count, ASCII sum). Verified by deterministic computation.
Chaining
Each round's challenge is generated from the previous round's verified response. This creates serial dependencies that cannot be parallelized, compounds proxy relay latency, and requires full context maintenance.
Configuration
Environment variables:
Variable | Default | Description |
| (ephemeral key generated at startup) | PEM-encoded EC P-256 private key for JWT signing. Required for production. |
|
| JWT issuer claim |
To generate a key pair:
openssl ecparam -genkey -name prime256v1 -noout | openssl pkcs8 -topk8 -nocrypt -out bonafide.pem
openssl ec -in bonafide.pem -pubout -out bonafide.pub
export BONAFIDE_EC_PRIVATE_KEY="$(cat bonafide.pem)"If BONAFIDE_EC_PRIVATE_KEY is not set, the server generates an ephemeral key pair on startup and logs a warning. Tokens issued with an ephemeral key will not survive a server restart. A real implementation would use stronger key gen and storage primitevs.
Project Structure
bonafide-mcp/
├── src/
│ ├── index.ts # Entry point (stdio transport)
│ ├── server.ts # MCP server: tools, resources, verification flow
│ ├── challenges/
│ │ ├── types.ts # Shared types and config
│ │ ├── constrained-text.ts # SMHL-inspired text challenges
│ │ ├── computed-field.ts # Structured JSON challenges
│ │ └── chain.ts # Round chaining logic
│ ├── verification/
│ │ └── verifier.ts # Response verification engine
│ ├── session/
│ │ └── manager.ts # Session state management
│ └── credentials/
│ └── jwt.ts # JWT issuance and validation
├── data/
│ └── cities.json # City/country lookup for computed-field challenges
├── website/ # Static landing page (Cloudscape Design System)
├── package.json
└── tsconfig.jsonCredits
BonafideMCP builds on work by others:
MoltCaptcha — SMHL challenges. BonafideMCP's challenge types are directly inspired by this approach.
aCAPTCHA — HTTP-based multi-round verification with cross-round dependency.
IETF Web Bot Auth — Cryptographic agent identity (complementary to BonafideMCP).
Model Context Protocol — The protocol that makes this approach possible.
Limitations
BonafideMCP is not unbreakable. A sufficiently motivated adversary with a fast LLM endpoint and an optimized MCP relay could potentially pass verification. The system raises the bar significantly compared to HTTP-based verification, but it is not a cryptographic guarantee.
For stronger assurance, combine BonafideMCP with cryptographic identity (Web Bot Auth, client certificates).
Security Considerations
BonafideMCP is a research project and reference implementation. It has not undergone a formal security audit and should be evaluated carefully before use in any production or trust-bearing context.
Known design and implementation limitations to consider:
Proof-of-AI, not proof-of-identity. Passing verification proves that the connecting system has access to a capable LLM, not that any specific agent or user is authorized. A relay that forwards challenges to another LLM could pass. For identity assurance, combine BonafideMCP with cryptographic mechanisms (client certificates, Web Bot Auth).
Tool-based mode is weaker. In tool-based fallback mode, challenges are returned as plaintext tool results visible to any middleware in the stack. Sampling mode pushes challenges directly into the model and is meaningfully more resistant to proxy attacks.
In-memory session store. All sessions and tokens are held in process memory and are lost on restart. There is no persistence layer, clustering support, or token revocation mechanism. Issued JWTs are valid until they expire (15 minutes).
No per-client rate limiting. The server enforces a global cap on concurrent sessions (100) but does not rate-limit individual clients. A single client could exhaust the session pool.
Challenge predictability. Challenge parameters (topics, letters, word counts) are selected using
Math.random(), which is not cryptographically secure. An adversary who can predict the RNG state could pre-compute responses.
This is a concept implementation meant for experimentation and testing. Do not use on real applications.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Reverse CAPTCHA for AI agents: prove you're an agent and get a verified, scoped, signed pass.
Reverse CAPTCHA: prove a language model is on the other end and get a signed attestation.
Authenticated LLM MCP Agent
Tamper-evident proof creation and verification for AI agents via MCP, A2A, and REST.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP Server for AI agent identity and authorization. Create, verify, and manage agent identities with trust scores and scoped authorization tokens.77 PyPIMIT
- AlicenseNot gradedqualityDmaintenanceEvaluates AI agent and MCP server competency across 6 quality dimensions using challenge-response tests, returning quality scores and W3C Verifiable Credentials.MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP-compatible LLM clients to execute server-verified agent workflows, with enforced transitions, invocation caps, and signed audit trails.MIT
- FlicenseNot gradedqualityDmaintenanceEnables users to verify that an AI agent is who it claims to be by combining domain verification, agent-card checks, and a live MCP handshake, with paid requests handled via x402 on Base Sepolia testnet.-