You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motivation
OpenViking 的 MCP 端点目前只能通过远程 URL(http(s) / git / ssh)添加资源。本地文件路径在桌面 Claude Code 上可以靠
ovCLI 解决,但在沙箱化的 agent 环境(Claude web、Manus 等)有三个硬约束:ovCLI —— 沙箱镜像不允许任意 binary这个 RFC 提出一个 progressive 单入口 设计:agent 只需调用
add_resource(path=...),server 在检测到本地路径后返回一份散文形式的两步上传指令,agent 跟着指令上传文件,然后用temp_file_id再次调用同一个工具完成入库。设计已经在 PR #1847 实现并 merge-ready。这个 RFC 的目的是把设计选择和权衡公开化、收集后续优化建议。
Pain Points (from real usage)
Proposed Design
流程图
agent 视角(只看一个工具):
Why prose, not JSON
实测当工具返回 JSON 时,LLM 倾向于把它当数据原样转述给用户("I got back this JSON: {...}");而散文 +
Step 1/Step 2排版能可靠触发"按步骤执行"的行为。URL 单独缩进成行也利于 verbatim 提取,避免长 URL 被截断或改写。Why short stateful token, not HMAC-signed
dict.pop一气呵成6 字符 + 短 TTL + 绑定 server-chosen
temp_file_id(122-bit UUID)+ 每租户子目录隔离,实际攻击面极窄。Public base URL 解析
5 层 fallback,前两层 explicit、后三层 inferred:
OPENVIKING_PUBLIC_BASE_URL环境变量ServerConfig.public_base_urlX-Forwarded-Host+X-Forwarded-Proto(反代链转发)Hostheader(直连)http://{listen_host}:{listen_port}兜底inferred 时,响应自动附带提示:"如果上传失败,请在 server 端设置
OPENVIKING_PUBLIC_BASE_URL"。生产环境(MCP proxy + nginx)推荐显式配置。API Surface
MCP
add_resource(path: str = "", temp_file_id: str = "", description: str = "")—— 单一入口,三分支语义。返回str:成功消息或散文上传指令。REST(新增)
POST /api/v1/resources/temp_upload_signed?token=...&temp_file_id=...Depends(get_request_context),token 即身份filebody,Content-Length+ 流式 size 双重限制{upload_dir}/{aid}/{uid}/{tfid},带.ov_upload.meta配置
ServerConfig新增三项:public_base_url、upload_signed_ttl_seconds(默认 600)、upload_signed_max_bytes(默认 100MB)。Trade-offs / Alternatives Considered
Existing vs. New
temp_uploadREST(CLI 用)resolve_uploaded_temp_file_id_cleanup_temp_filesrglob以覆盖 per-tenant 子目录ResourceService.add_resource_IdentityASGIMiddlewareX-Forwarded-*进 contextvarupload_token_storetemp_upload_signedRESTadd_resourceOut of Scope (Follow-ups)
temp_uploadto per-tenant layout(需要历史数据 migration)Open Questions
viking://resources/<filename>,和 git/URL fetch 混在同一层。是否应该默认带parent="viking://resources/uploads"之类的子前缀,把 conversational uploads 和 curated imports 分开?temp_file_id长度:当前沿用旧temp_upload路由的upload_<uuid4.hex>.<ext>(39+ 字符)。从碰撞安全角度严重过头(10 min TTL + 单租户视角下,16 hex 甚至 12 base62 都绰绰有余)。要不要顺手缩短?利好是上传 URL 总长能压到 ~110 字符,agent verbatim 复制更稳。代价是改动旧路由产物格式,理论上影响第三方依赖。_resolve_unique_uri用_1_2后缀,长期会很难看。是否应该改用日期前缀或哈希?add_resource_inline(name, content_b64)作为兜底通道(给沙箱无 outbound HTTP 的极端情况)?References
ov setup)All reactions