Skip to content

feat: MCP request_key tool and agent identity headers (Stories 2.2 + 2.4)#130

Merged
farovictor merged 1 commit intomainfrom
feat/mcp-request-key
Apr 5, 2026
Merged

feat: MCP request_key tool and agent identity headers (Stories 2.2 + 2.4)#130
farovictor merged 1 commit intomainfrom
feat/mcp-request-key

Conversation

@farovictor
Copy link
Copy Markdown
Owner

Summary

  • Story 2.2request_key MCP tool: agents call tools/call with service_name to get a short-lived virtual key; ttl_seconds (default 3600) and rate_limit (default 60) are optional. Issued keys are tagged source: "mcp" and appear in GET /v1/keys.
  • Story 2.4 — Agent identity headers injected server-side on every proxied request:
    • X-Bifrost-Key-ID — always present, identifies the virtual key used
    • X-Bifrost-Agent-ID — present only on MCP-issued keys, identifies the agent session
  • Adds source column to virtual_keys table (migration 007)
  • Documents both in doc/api.md + regenerated swagger spec

Test plan

  • TestMCPRequestKey — happy path: key issued, stored, tagged source=mcp
  • TestMCPRequestKeyDefaults — default TTL=3600s, rate_limit=60
  • TestMCPRequestKeyServiceNotFound — returns JSON-RPC error
  • TestMCPRequestKeyMissingServiceName — returns JSON-RPC error
  • TestProxyInjectsKeyIDHeaderX-Bifrost-Key-ID on all requests
  • TestProxyInjectsAgentIDForMCPKeyX-Bifrost-Agent-ID on MCP keys
  • TestProxyNoAgentIDForRegularKey — header absent for regular keys
  • Full suite green

🤖 Generated with Claude Code

…2.4)

- Implement request_key MCP tool: accepts service_name, ttl_seconds (default
  3600), rate_limit (default 60); issues a virtual key tagged source=mcp
- Add Source field to VirtualKey model + migration 007
- Inject X-Bifrost-Key-ID on all proxied requests (server-side, unspoofable)
- Inject X-Bifrost-Agent-ID on proxied requests when key source=mcp
- Document injected headers and MCP tools in doc/api.md
- Add 7 new tests: request_key happy path, defaults, service not found,
  missing service_name, key-id header, agent-id header for MCP, no agent-id
  for regular keys
- Regenerate swagger spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@farovictor farovictor merged commit 4a72984 into main Apr 5, 2026
8 checks passed
@farovictor farovictor deleted the feat/mcp-request-key branch April 5, 2026 21:41
@farovictor farovictor self-assigned this Apr 5, 2026
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