Management API tokens + /api guard: foundation for a management CLI
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 活跃
- 技术栈
- openapi, postgresql, typescript
调研方向
Start by reading AGENTS.md and the existing MCP auth guards, RolesGuard, rate-limit guard and middleware, plus the /api/mcp-keys controller and Prisma schema. The issue requires agreement on credential shape and scope semantics before implementation, then calls for auth and rate-limit tests, a Prisma migration, minting UI changes, and OpenAPI annotations in the File Search and file-share controllers. Done means those decisions are agreed and the listed tasks are implemented.
由索引模型根据 Issue 内容生成。
描述
Summary
Add a management-scoped API credential and a guard that lets it authorize the
/api/* management endpoints, as the foundation for a full management CLI
(configure connectors, MCP servers, roles, users, SSO, code mode, settings,
memory/skills/knowledge-graph from the terminal — and by a connected agent).
This is a discussion-first issue per AGENTS.md (it changes authentication
and the Prisma schema). No code until the approach here is agreed.
Problem (verified in source)
There are two auth realms:
- MCP realm — the MCP API key is authenticated by
McpAuthMiddleware/
McpCombinedAuthGuard, bound only to.forRoutes('mcp'), and resolves to a
user pinned to onemcpServerId+mcpRoleId(a tool allow-list). It exists
to call tools. - Management realm — every
/api/*controller is guarded by
AuthGuard('jwt')(browser session cookie) +@Roles('ADMIN')on sensitive
routes. The MCP key cannot reach it, and cookie+CSRF is unusable from a CLI/CI.
Cloud SSO users have no username/password login at all.
So a CLI cannot manage an instance today with the existing credential.
Proposal
Extend the existing API-key machinery rather than build a parallel system:
- Scope on the credential — add a scope to
McpApiKey
(mcp|management-read|management-admin). The key carries the user's
identity and role; the scope is a downward cap, never an elevation.
Effective power = min(user role, key scope). A non-admin's key still gets the
same@Roles('ADMIN')403s as in the dashboard. - Guard — a guard that accepts a valid session JWT or a management
key on/api/*, composing with the existingRolesGuard. - Rate limiting — apply the existing per-principal rate-limit
(mcp-principal-rate-limit.guard/mcp-rate-limit.middleware) to/api/*
keyed to the management key, plus a per-key daily op cap. Protects against a
looping tool/agent hammering the backend. - Self-service minting —
/api/mcp-keysis already JWT-only and
user-scoped, so any user mints their own key; add the scope selector (offer
only scopes <= the user's role). Agent-issued keys default to read-only.
Deployment behavior
Same feature on Cloud and self-hosted. Self-hosted gets it for free; on Cloud it
is the only non-interactive path for SSO users. No Cloud operator procedures are
part of this change.
Security
Least privilege (read vs admin scope), revocation, per-principal rate limit +
per-key quota, every management mutation already lands in the audit log, and
registration / forgot-password stay off the CLI (launcher-only to the web page,
no API call, no email).
Schema change + migration
New scope column (enum) on McpApiKey; migration included with the
implementation PR. Open to a separate ManagementApiKey table instead if we
prefer to keep MCP and management credentials fully distinct — a design question
for this thread.
Pre-work found
OpenAPI coverage audit: 179 / 207 management routes already carry
@ApiOperation. The gap is almost entirely File Search (file-search 3/23,
file-share 0/8, ~29 routes). Those two controllers need annotation before we
generate a typed CLI client from /api/docs.
Out of scope (follow-ups)
- Browser OAuth
loginfor human ergonomics / SSO (fast-follow; reuses the
OAuth2 server already in the repo). - The CLI command surface itself (225 management commands mapped; one command
per controller route) and public npm distribution. - Declarative
apply/export("instance as code").
Tasks
- Agree credential shape (scope on
McpApiKeyvs separate table) - Define scope semantics (read = GET only; admin = all, role-capped)
- Guard design (JWT-or-management-key) + tests
- Apply per-principal rate limit + per-key quota to
/api/* - Prisma migration
- Mint UI +
/api/mcp-keysscope selector (cap to role; agent default read-only) - Annotate File Search / file-share controllers for OpenAPI
- 主要语言
- TypeScript
- 星标
- 856
- 派生
- 82
- 平均合并
- 6 小时 23 分钟
- 30 天内合并 PR
- 430
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
HelpCode-ai/anythingmcp 的其他 Issue
-
adapter-request good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100
HelpCode-ai/anythingmcp#1405 ·
维护者通常 1 天内回复
-
TikTok Shop: server-level public app and App Store installs可能已有人在做 @helpcodeai 今天认领。 未关闭
难度 5/5 一周以上 新手友好度 20/100
HelpCode-ai/anythingmcp#1533 ·
维护者通常 1 天内回复
-
Upload the new social preview可能已有人在做 @helpcodeai 于 2 天前认领。 未关闭
HelpCode-ai/anythingmcp#1455 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 38/100
HelpCode-ai/anythingmcp#1418 ·
维护者通常 1 天内回复
-
Adapter: TGStat可能已有人在做 @abinyads-dev 今天认领。 未关闭adapter-request good first issue help wanted
难度 3/5 1-2 天 新手友好度 75/100
HelpCode-ai/anythingmcp#1413 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 HelpCode-ai/anythingmcp 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
vercel-labs/durable-harness#53 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
area/docs area/ui enhancement
难度 1/5 1-3 小时 新手友好度 88/100
melgarafael/DeskcommCRM#4098 ·
维护者通常 1 天内回复
-
bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 86/100
kerti/balances-v2#801 ·
维护者通常 1 天内回复
-
lesson-submission pending-review
难度 1/5 1 小时以内 新手友好度 84/100
Ikalus1988/MisakaNet#4510 ·
维护者通常 1 天内回复