Overview
PromptRepo’s MCP server uses API key authentication to verify caller identity and enforce access control. API keys are cryptographically hashed and stored in the database — the plaintext key is shown only once during generation.Generating an API Key
Copy Key Immediately
The plaintext key is displayed once. Copy it to a secure location (password manager, environment variable file, etc.).
Once you close the modal, the plaintext key cannot be retrieved — you’ll need to generate a new one.
Store Securely
Add the key to your AI client’s configuration (see Configuration for examples).
Authentication Headers
When making requests toPOST /api/mcp, include your API key in one of two headers:
How Verification Works
The authentication flow is handled insrc/app/api/mcp/route.ts:
Anonymous Access
If no API key is provided in the request:userIdis set tonull- All tools return public prompts only
- Private prompts are inaccessible
Anonymous access is useful for testing or read-only integrations where you only need public prompts.
Revoking API Keys
Find the Key
Locate the key in the API Keys table (identified by creation date and last 8 characters).
Access Control Rules
Once authenticated, tool handlers enforce these access policies:| Tool | Authenticated User | Anonymous User |
|---|---|---|
list_prompts | Own prompts + public prompts | Public prompts only |
get_prompt | Own prompts (public/private) + others’ public | Public prompts only |
resolve_prompt | Same as get_prompt | Public prompts only |
search_prompts | Own prompts + public prompts | Public prompts only |
Security Best Practices
Use Environment Variables
Use Environment Variables
Store API keys in environment variables or secret management tools — never hardcode them:
Rotate Keys Regularly
Rotate Keys Regularly
Generate new keys every 90 days and revoke old ones. This limits the damage if a key is compromised.
Use Separate Keys per Client
Use Separate Keys per Client
Generate different API keys for each AI client (Claude Desktop, Claude Code, CI/CD) to enable granular revocation.
Monitor Usage
Monitor Usage
Check the “Last Used” timestamp in
/profile to detect anomalies or unused keys that should be revoked.Error Responses
| Scenario | HTTP Status | JSON-RPC Error Code | Message |
|---|---|---|---|
| No key provided | 200 | N/A | Request succeeds (anonymous access) |
| Invalid key format | 200 | -32001 | ”Invalid API key.” |
| Revoked key | 200 | -32001 | ”Invalid API key.” |
| Unknown key | 200 | -32001 | ”Invalid API key.” |
Why HTTP 200? JSON-RPC 2.0 requires all responses (including errors) to use HTTP 200. Errors are transmitted inside the JSON envelope.
Implementation Reference
API key verification is implemented insrc/lib/api-keys/verify.ts:
src/lib/api-keys/verify.ts
src/app/api/mcp/route.ts:71-96 for the full route handler integration.
Next Steps
Configuration
Configure Claude Desktop, Claude Code, and other MCP clients with your API key