Repository navigation
feat: create user files from scoped MCP tool artifacts - #838
Open
Stella-sea wants to merge 5 commits into
Open
Stella-sea wants to merge 5 commits into
Stella-sea wants to merge 5 commits into
Conversation
Stella-sea
marked this pull request as ready for review
October 6, 2026 16:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
关联 #818。
这是 create-only 的可运行 Draft 实现提案,供维护者评审授权契约;不代表 #818 的协议已获上游批准,也不建议未经评审直接启用。
外部 MCP 生成完成的文件,可以在本次已登记工具调用授权内直接创建为当前用户的 DEEIX 正式文件对象,进入已有文件列表和配额/处理流程,不需要用户先下载再手工上传。
基线:
dev@19d60fec8f9356a4bdd997e8b71a5a8a9a0baec9。最小契约
fileCreateEnabled: true,默认关闭。首版是管理员授权后的自动创建,不把模型confirm=true当成用户确认;临时聊天、附件预处理和发现不签发授权。tools/call前签发 32 字节随机、10 分钟有效的一文件 capability,仅通过X-Deeix-File-Create-Token发给登记服务。数据库仅保存哈希,绑定服务、目标用户、工具、调用 ID 和撤销代数。现有共享 HMAC 上下文、出站 MCP token、用户 JWT 都不是反向凭证。POST /api/v1/mcp/servers/{id}/files接收唯一一个限量 multipartfile,归属完全由 capability 确定,拒绝额外字段/用户 ID/URL。复用 UploadService 文件策略、对象存储 port、文件元数据及配额事务。file_id,改变内容/名称/MIME 返回冲突。内容reused与请求replayed分开表示。Change type
Affected areas
管理员开关通过已有 API 配置;未增加前端设置页,前端仅补齐新错误码翻译。
Verification
最终版本已通过:
make lint test(backend 工作目录;等同make -C backend lint test):Linux 容器内 Go 1.26.8,包含 gofmt、go vet、staticcheck、deadcode、完整go test ./...。go test -race ./...:同一 Linux Go 1.26.8 环境完整通过。go build ./...。go build -tags nopostgres,noredis,nos3,noswagger,nomsgpack,nootlp ./...。pnpm api:generate、pnpm api:check。pnpm turbo run check --filter=@deeix/web --filter=./packages/* --env-mode=loose。pnpm --filter @deeix/web build。git diff --check、相对 dev 的完整差异检查、独立只读安全审查。聚焦回归覆盖:用户归属与列表/配额、正常创建和重放、错服务/伪造 token/共享 HMAC 不能授权、过期与撤销后重新启用、连接快照失效、大小/类型/配额拒绝、跨实例并发、Put/提交响应丢失、事务回滚、过期候选清理/失败重试/跨用户引用保护、真实处理恢复及浏览器初始化竞态、审计凭据/内容隔离、调用重试和 discovery/redirect 凭证边界。
环境限制已绕过:Windows 根级
pnpm check因缺少make失败;本机 Node 22 无法直接运行现有.ts测试。后端在独立 Linux checkout 用仓库锁定 Go 版本完成原检查,Node 测试在 CI 使用的 Node 24 完成。未运行完整 Rust 桌面cargo check或桌面打包;已完成 Go sidecar tag 构建/测试。现有 CI 未自动设置集成测试 DSN,因此 PostgreSQL/Redis 特定测试在普通 CI 会跳过,本地实测结果如上。Screenshots, API examples, or logs
外部服务的 DEEIX 地址与登记服务 ID 由部署者配置,不从模型参数或 Host 推断:
{ "errorMsg": "", "data": { "file_id": "file_example", "file_name": "report.txt", "size_bytes": 123, "sha256": "<64 hex characters>", "reused": false, "replayed": false, "processing_status": "queued", "extract_status": "none", "embed_status": "none", "processing_ready": false } }完整错误、幂等、部分失败及过期语义见
docs/MCP_FILE_CREATE.md。Configuration, migration, and compatibility notes
mcp_file_create_grantsreceipt 表;MCP 服务新增默认关闭字段及撤销代数,由既有 schema migration 管理。/api/v1/files鉴权不变,未授权 MCP 服务不获得 capability。packages/api-contract/src/types.generated.ts由生成流水线更新,未手改。请维护者决定
Documentation
新增
docs/MCP_FILE_CREATE.md,明确这是待评审契约,backend README 增加入口。Security and privacy
Checklist
.pycfiles,.envfiles, and local storage data are not committed.