Repository navigation
Conversation
…d headers
A shared connector carries one static target and header set, so a multi-tenant
MCP server cannot tell which end user a call belongs to: every user collapses
onto the same tenant session. Connector url paths and header values may now
reference the requesting user through ${octop.user_id} or ${octop.username}.
Templates are stored verbatim (admins still configure one connector, the
dashboard keeps showing the template) and substituted only when Octop
materializes the connection spec for a given user, so each user presents their
own identity on the same shared configuration.
Safety properties, chosen because a wrong identity is worse than no identity:
- Substituted values are constrained to the charset and length the downstream
tenant resolver accepts ([A-Za-z0-9._-], <= 64) and are CR/LF-free. A value
outside that envelope is not rejected by the server, it is silently remapped
to the default tenant, which would leak one user's data into another's.
- Over-budget or degenerate names fall back to the numeric user id instead of
being truncated, so two long names can never collide on one key.
- A literal template that cannot fit at all raises, and the unresolvable server
is dropped for that user rather than sent with an ambiguous identity.
- Placeholders in the url are only allowed below the host, so templating cannot
be used to redirect a request to another server; the host is validated at
save time against a token-filled preview while the template is kept stored.
- Unknown tokens are rejected at save and probe time; probes take the same
substitution path as real calls, so what passes the test button is what runs.
When a username cannot be resolved the placeholders degrade to the numeric id
and a warning is logged, so the degradation is observable instead of silent.
The connector editor documents both placeholders next to the header field.
refs TencentCloud#1827
cy1990
force-pushed
the
feature/connector-dynamic-user-header
branch
from
October 9, 2026 07:43
783d0bc to
b6bba9f
Compare
Author
|
本地已按 另:上一版提交里
|
4 of 12 tasks
7 of 15 tasks
This branch has not been deployed
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
一份共享连接器只有一套静态
url/ header,多租户 MCP 服务器无从判断这次调用属于哪个最终用户——所有用户塌进同一个服务端会话/租户。本 PR 让自定义 MCP 服务器的url路径与 header 值可以引用当前请求用户:${octop.user_id}、${octop.username}。模板原样入库:管理员仍然只配置一份连接器,dashboard 里看到的也是模板本身;替换只发生在 Octop 为某个具体用户物化连接配置的那一刻。于是同一份共享配置下,每个用户带着自己的身份访问下游。
Target branch
develop(feature / fix — default)main(release/*orhotfix/*only)Type of change
Test plan
质量门禁按
uv.lock锁定的工具版本复现(ruff 0.15.20 / mypy 2.1.0,与make lint/make typecheck同命令),Python 3.12、工作区为 rebase 到origin/develop后的代码:即
make lint与make typecheck两个 step 在本地已是干净的,没有任何遗留告警需要维护者甄别。新增
tests/unit/connectors/test_user_scope_headers.py(16 例)覆盖:header 与 url 两种模板的存原文/取替换、用户名优先与数字 id 回落、CR/LF 与非法字符清洗、超预算不截断、host 段占位符拒绝、未知 token 拒绝、探测与真实调用同路、无法解析的服务器被跳过而不影响其余工具面。除单测外还做了真实容器端到端(多用户 + 一份
shared: true连接器 + 真实多租户 MCP 服务器):make all未完整跑通:它额外要求前端构建(dashboard/node_modules,本机无该目录,无法构建与类型检查)。本次前端改动只有两个 locale 新增键与连接器卡片的一处提示节点,未做构建验证;后端部分(ruff / mypy / pytest)已按上述 CI 同版本命令全量跑过。Checklist
CHANGELOG.md(if user-facing)docs/api.md自定义 MCP 一节补充占位符与约束make allpasses locally(原因见 Test plan:前端依赖缺失)Refs #1827