Commit 522a9e9
* feat(auth): add agent tokens design spec and implementation plan
Design and speckit artifacts for scoped agent tokens feature.
Agent tokens allow autonomous AI agents to access MCPProxy with
restricted server access, permission tiers, and automatic expiry.
## Artifacts
- Design doc: docs/plans/2026-03-06-agent-tokens-design.md
- Teams auth design: docs/plans/2026-03-06-mcpproxy-teams-auth-design.md
- Spec: specs/028-agent-tokens/spec.md (6 user stories, 20 FRs)
- Plan: specs/028-agent-tokens/plan.md
- Research: specs/028-agent-tokens/research.md
- Data model: specs/028-agent-tokens/data-model.md
- API contracts: specs/028-agent-tokens/contracts/agent-tokens-api.yaml
- Tasks: specs/028-agent-tokens/tasks.md (43 tasks across 8 phases)
* feat(auth): implement agent token foundation (Phase 1+2, T001-T009)
Add the internal/auth package with token generation, HMAC-SHA256
hashing, format validation, permission constants, AuthContext for
request-scoped identity propagation, and file-based HMAC key
management. Add BBolt storage layer with dual-bucket design
(hash->record, name->hash) supporting CRUD, revocation, regeneration,
last-used tracking, and token validation with expiry/revocation checks.
Includes 37 passing tests covering all functionality with race
detection clean.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(auth): implement REST API token management and auth middleware (Phase 3+4, T010-T022)
Phase 3 (Auth Middleware):
- Add AuthContext injection in apiKeyAuthMiddleware for admin/agent token auth
- Add mcpAuthMiddleware for MCP endpoint agent token scope enforcement
- Support agent token validation via mcp_agt_ prefix in X-API-Key header
- Wire ExtractToken helper for unified token extraction from headers/query params
- Tray connections automatically get admin AuthContext
Phase 4 (REST API Token Management):
- Create internal/httpapi/tokens.go with 5 REST handlers:
- POST /api/v1/tokens (create with name/permissions/servers/expiry validation)
- GET /api/v1/tokens (list without secrets)
- GET /api/v1/tokens/{name} (get single token info)
- DELETE /api/v1/tokens/{name} (revoke)
- POST /api/v1/tokens/{name}/regenerate (regenerate secret)
- All endpoints reject agent token auth with 403
- TokenStore interface for testable storage abstraction
- Validation helpers: name regex, permissions, expiry parsing (max 365d), server names
- Wire storage via SetTokenStore() in server initialization
- Register routes in setupRoutes() under /api/v1/tokens
Tests (27 test functions):
- Token CRUD lifecycle tests (create, list, get, revoke, regenerate)
- Validation: name format, permissions, expiry duration, allowed servers
- Security: agent token rejection (403), admin access, no-store handling (500)
- Validation helper unit tests (name, expiry, allowed servers)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(auth): add CLI token commands and comprehensive auth/scope tests (Phase 3 completion)
Add token CLI subcommands (create/list/show/revoke) and test suites for:
- Auth middleware: token extraction priority, agent token validation
(valid/expired/revoked/Bearer), admin context propagation, tray bypass
- MCP scope enforcement: server access blocking, permission tier checks
(read/write/destructive), admin passthrough, upstream server list
filtering, quarantine security blocking for agent tokens
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(cli): add token regenerate subcommand (T026, T023)
Add `mcpproxy token regenerate <name>` CLI command that calls
POST /api/v1/tokens/{name}/regenerate to invalidate the old secret
and generate a new one. Displays the new token with a save warning,
supports -o json output. Includes test verifying command registration
and argument validation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(activity): add agent identity metadata to activity logging (Phase 6, T028-T031)
Add auth identity tracking to activity records so tool calls can be
attributed to specific agent tokens. Includes:
- getAuthMetadata/injectAuthMetadata helpers in mcp.go that extract
auth context and inject _auth_ prefixed fields into activity args
- Auth metadata injected in handleRetrieveTools, handleCallToolVariant,
and legacy handleCallTool before any activity emit calls
- AgentName and AuthType filters on ActivityFilter (storage + httpapi)
- CLI --agent and --auth-type flags on activity list command
- Swagger annotations for new query parameters
- Unit tests for getAuthMetadata and injectAuthMetadata functions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): add Agent Tokens web UI page (Phase 7, T034-T037)
Add complete web UI for managing agent tokens:
- Token API methods in api.ts (list, create, revoke, regenerate)
- AgentTokens.vue view with stats bar, table, create dialog, and
token secret display with copy-to-clipboard
- Route at /tokens and sidebar navigation entry
- TypeScript types for AgentTokenInfo, CreateAgentTokenRequest,
CreateAgentTokenResponse
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: fix lint issues — remove unused field and function
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: update CLAUDE.md with agent tokens tech context
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add agent tokens feature documentation
Covers motivation, quick start, permission tiers, server scoping,
require_mcp_auth enforcement, token management CLI/API, activity
logging integration, and security model.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(auth): add require_mcp_auth config flag to enforce /mcp authentication
When enabled, the /mcp endpoint rejects unauthenticated requests with 401.
Tray/socket connections always bypass this check (OS-level auth). Adds CLI
flag --require-mcp-auth and config field require_mcp_auth (default: false).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): improve agent tokens with server checkbox list and fix API responses
Replace text input for allowed_servers with a checkbox list showing all
configured servers with connected/offline badges, plus an "All servers"
wildcard option. Fix token API handlers to wrap responses in the standard
{success, data} envelope expected by the frontend.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(test): update token tests for API response envelope format
Tests now unwrap the {success, data} envelope before asserting on
response fields, matching the writeSuccess/NewSuccessResponse changes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): add agent/auth filters to Activity Log and fix token UI issues
- Add Auth Type filter (Admin/Agent) and Agent Name filter to Activity Log
- Agent name dropdown auto-populates from activity metadata
- Fix token secret display: use bg-neutral for dark theme visibility
- Fix Copy button: use btn-neutral for dark theme contrast
- Fix revoke: handle 204 No Content response in API client
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(test): skip HMAC key file permissions check on Windows
Windows does not support Unix file permissions, so os.FileMode(0600)
assertion always fails. Skip this check on Windows.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: remove docs/plans/ from tracked files
Keep design docs as local-only uncommitted files.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Code <noreply@anthropic.com>
1 parent ed10f89 commit 522a9e9
43 files changed
Lines changed: 6940 additions & 28 deletions
File tree
- cmd/mcpproxy
- docs/features
- frontend/src
- components
- router
- services
- types
- views
- internal
- auth
- cliclient
- config
- httpapi
- server
- storage
- oas
- specs/028-agent-tokens
- checklists
- contracts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
99 | 110 | | |
100 | 111 | | |
101 | 112 | | |
| |||
153 | 164 | | |
154 | 165 | | |
155 | 166 | | |
| 167 | + | |
156 | 168 | | |
157 | 169 | | |
158 | 170 | | |
| |||
220 | 232 | | |
221 | 233 | | |
222 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
223 | 240 | | |
224 | 241 | | |
225 | 242 | | |
| |||
322 | 339 | | |
323 | 340 | | |
324 | 341 | | |
| 342 | + | |
| 343 | + | |
325 | 344 | | |
326 | 345 | | |
327 | 346 | | |
328 | | - | |
| 347 | + | |
329 | 348 | | |
330 | 349 | | |
331 | 350 | | |
| |||
496 | 515 | | |
497 | 516 | | |
498 | 517 | | |
| 518 | + | |
| 519 | + | |
499 | 520 | | |
500 | 521 | | |
501 | 522 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| 77 | + | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
| |||
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
147 | 166 | | |
148 | 167 | | |
149 | 168 | | |
| |||
213 | 232 | | |
214 | 233 | | |
215 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
216 | 242 | | |
217 | 243 | | |
218 | 244 | | |
| |||
722 | 748 | | |
723 | 749 | | |
724 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
725 | 754 | | |
726 | 755 | | |
727 | 756 | | |
| |||
816 | 845 | | |
817 | 846 | | |
818 | 847 | | |
| 848 | + | |
| 849 | + | |
819 | 850 | | |
820 | 851 | | |
821 | 852 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
| 126 | + | |
125 | 127 | | |
126 | 128 | | |
127 | 129 | | |
| |||
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
167 | 172 | | |
168 | 173 | | |
169 | 174 | | |
| |||
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
| 186 | + | |
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
| |||
384 | 390 | | |
385 | 391 | | |
386 | 392 | | |
| 393 | + | |
387 | 394 | | |
388 | 395 | | |
389 | 396 | | |
| |||
473 | 480 | | |
474 | 481 | | |
475 | 482 | | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
476 | 486 | | |
477 | 487 | | |
478 | 488 | | |
| |||
492 | 502 | | |
493 | 503 | | |
494 | 504 | | |
| 505 | + | |
495 | 506 | | |
496 | 507 | | |
497 | 508 | | |
| |||
0 commit comments