Skip to content

feat(connectors): expose shared MCP servers under a collision-safe literal alias - #1906

Open
cy1990 wants to merge 1 commit into
TencentCloud:developfrom
cy1990:feature/shared-connector-literal-alias
Open

cy1990 wants to merge 1 commit into
TencentCloud:developfrom
cy1990:feature/shared-connector-literal-alias

Conversation

@cy1990

@cy1990 cy1990 commented Oct 11, 2026

Copy link
Copy Markdown

What

Make a shared MCP connector usable when referenced by its plain (literal) name
by a non-owner viewer, instead of only by the internal mangled key
custom__<parentInstanceId>__<serverName>.

Two coordinated, minimal additions (one commit):

  1. Runtime / authorization (service.py):

    • ConnectorService.list_active_mcp_server_names additionally yields the literal
      server name for a shared server (next to the mangled key).
    • ConnectorService.custom_harness_configs materializes the harness spec under the
      literal name too.
    • Both are collision-safe: a viewer's own server always wins the literal name
      (if name not in names/configs); the mangled key is always kept, so existing
      bindings that persist the mangled key keep working unchanged.
  2. UI / list surface (custom_mcp.py):

    • expand_custom_instances(shared_view=True) emits, right after each mangled entry,
      an extra alias entry with the same instance_id but mcp_server_name = <plain name>,
      so the plain name appears in listInstances and stays selectable in the chat composer.

Why

Before this change, a shared parent row only surfaced the mangled key to viewers.
Binding an assistant to the plain name therefore:

  • got silently dropped by merge_turn_mcp_servers at runtime (the plain name wasn't in
    the authorized set), and
  • even the service.py-only half left the composer broken: listInstances
    (expand_custom_instances(shared_view=True)) still returned only the mangled key, so the
    front-end resolveInitialConnectors allowed-set lacked the plain name, dropped the agent's
    plain-name binding from the turn, and MCPToolMiddleware stripped every MCP tool
    (observed as filter: mcp=28 -> 0).

Net effect: a shared connector could not be maintained/bound by plain name from the UI at all.
This PR closes that gap symmetrically across both surfaces (authorization + list).

Independence

This is split out of #1845 (per-user identity injection into connector url/headers). It does
not depend on or touch ${octop.*} placeholders; it concerns shared-connector name
visibility
only. #1845 remains orthogonal.

Tests

Adds unit tests for both surfaces (tests/unit/connectors/test_custom_mcp.py):

  • authorization/materialisation of the literal alias + own-wins-on-collision,
  • expand_custom_instances(shared_view=True) yields the literal alias next to the mangled key.

Full CI-equivalent gate run on the resulting image (toolchain pinned to repo lockfile):

  • ruff check src tests / ruff format --check src tests: clean
  • mypy src/octop: no issues
  • pytest tests/unit/connectors: all pass (incl. the new alias cases)
  • dual-layer probe: stock MISS / patched HIT for both symbols

Notes / limits

…iteral alias

Two coordinated additions make a shared connector bound by its PLAIN name usable
for non-owner viewers:
  * service.list_active_mcp_server_names + custom_harness_configs authorise and
    materialise the plain name (own servers win it; the mangled key always stays).
  * custom_mcp.expand_custom_instances (shared_view) emits the plain alias next
    to the mangled key so it appears in listInstances and stays selectable in the
    chat composer. Without the UI half, resolveInitialConnectors drops the agent's
    literal binding from the allowed set and MCPToolMiddleware strips every tool.
Independent of the per-user identity-template feature; this only concerns shared-
connector name visibility. Adds unit tests for both surfaces.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant