Skip to content

Self-improving AI Employees for everyone

fix(connectors): a key in a connector's URL path stays encrypted

trohitgb41906650521
diff --git a/docs-internal/mcp_connectors.md b/docs-internal/mcp_connectors.md
index 42e6f7b6..ac7682f5 100644
--- a/docs-internal/mcp_connectors.md
+++ b/docs-internal/mcp_connectors.md
@@ -70,7 +70,9 @@ kept:
- `mcp:<slug>`: the sign-in, encrypted. Its `model_params["_mcp"]` holds the
rest in plain text, so no secret ever goes there:
- the name and host;
- - the address, without credentials;
+ - the address as the server's origin (scheme, host and port): a path,
+ like a query, can carry a key (`…/s/<token>/mcp`), so the full URL is
+ kept only in the encrypted row below;
- the transport;
- the sign-in's kind, and its header name;
- the server's name, title and version;
diff --git a/server/nodes/mcp/_store.py b/server/nodes/mcp/_store.py
index 6255902c..75d7a34c 100644
--- a/server/nodes/mcp/_store.py
+++ b/server/nodes/mcp/_store.py
@@ -3,9 +3,10 @@ OpenAI-compatible endpoints are kept, through ``AuthService``.
- ``mcp:<slug>``: the sign-in, encrypted. Its ``model_params["_mcp"]`` holds
the rest, which is not encrypted, so no secret ever goes there: the name,
- the server's address without credentials, the sign-in's kind and header
- name, the server's name, the tools as last accepted with the owner's
- settings for them, and a refresh waiting to be accepted.
+ the server's origin (scheme, host and port: a path can carry a key, as in
+ ``…/s/<token>/mcp``), the sign-in's kind and header name, the server's
+ name, the tools as last accepted with the owner's settings for them, and a
+ refresh waiting to be accepted.
- ``mcp:<slug>_proxy``: the server's URL, encrypted, since it may carry a key.
An OAuth sign-in's tokens are kept in the OAuth token store under
@@ -22,7 +23,7 @@ import re
from dataclasses import dataclass
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional
-from urllib.parse import urlsplit
+from urllib.parse import urlsplit, urlunsplit
from ._client import ConnectorError, Discovery, SignIn, snapshots
@@ -83,7 +84,7 @@ def describe_new(slug: str, name: str, url: str, sign_in: SignIn, found: Discove
return {
"name": name,
"host": (urlsplit(url).hostname or "").lower(),
- "address": redact_url(url),
+ "address": redact_url(urlunsplit(urlsplit(url)._replace(path=""))),
"transport": found.transport,
"sign_in": sign_in.public(),
"server": found.server,
diff --git a/server/tests/nodes/test_mcp_connector.py b/server/tests/nodes/test_mcp_connector.py
index d1d3b0c0..27750577 100644
--- a/server/tests/nodes/test_mcp_connector.py
+++ b/server/tests/nodes/test_mcp_connector.py
@@ -21,9 +21,9 @@ from mcp.server.fastmcp import FastMCP
from mcp.types import Tool, ToolAnnotations
from nodes.mcp import _client, _handlers, _oauth, mcp_connector
-from nodes.mcp._client import ConnectorError, SignIn, check_arguments, check_server, snapshots
+from nodes.mcp._client import ConnectorError, Discovery, SignIn, check_arguments, check_server, snapshots
from nodes.mcp._credentials import McpConnectorCredential
-from nodes.mcp._store import new_slug
+from nodes.mcp._store import describe_new, new_slug
from nodes.mcp.mcp_connector import McpConnectorNode
from services.plugin import NodeContext
@@ -205,6 +205,14 @@ class TestSignIn:
assert SignIn.load(sign_in.dump()) == sign_in
+def test_a_key_in_the_urls_path_is_never_kept_in_plain_text():
+ url = "https://mcp.example.com:8443/s/tok-123/mcp?key=q-456"
+ found = Discovery(transport="streamable_http", server={"name": "Orders"}, instructions=None, tools=[])
+ meta = describe_new("orders", "Orders", url, SignIn(), found)
+ assert meta["address"] == "https://mcp.example.com:8443"
+ assert "tok-123" not in json.dumps(meta) and "q-456" not in json.dumps(meta)
+
+
def test_a_slug_starts_with_a_letter_as_a_tool_name_must():
assert new_slug("Orders", URL) == "orders"
assert new_slug("", URL) == "mcp-127-0-0-1"
@@ -343,7 +351,7 @@ class TestTheConnectorsPage:
assert (card["consumer_category"], card["publisher"], card["verified"]) == ("custom", "you", False)
assert card["description"] == "Custom connection · 127.0.0.1"
assert card["stored"] is True and card["connected"] is True
- assert card["mcp"]["address"] == URL and card["mcp"]["sign_in"] == {"kind": "bearer"}
+ assert card["mcp"]["address"] == SERVER and card["mcp"]["sign_in"] == {"kind": "bearer"}
assert [(tool["name"], tool["enabled"], tool["ask"]) for tool in card["mcp"]["tools"]] == [
("lookup_order", True, False),
("send_reply", True, True),