mcp-combiner 0.20.0.dev2__tar.gz → 0.20.0.dev4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/CHANGELOG.md +21 -3
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/PKG-INFO +1 -1
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/asgi.py +1 -1
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/binding.py +19 -10
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/config.py +64 -3
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/mockserver.py +33 -2
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/runtime.py +3 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/advertise.py +73 -15
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/pyproject.toml +1 -1
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_advertised_origin.py +43 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_binding.py +17 -7
- mcp_combiner-0.20.0.dev4/tests/test_public_url.py +65 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/uv.lock +1 -1
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/.gitignore +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/.python-version +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/LICENSE +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/README.md +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/__init__.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/__main__.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/auth.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/authprompt.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/backing.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/connections.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ctl.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/era.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/externalservers.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/fastvalidate.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/handover.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/heldcalls.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/inbound_auth.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/isolated.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/listen.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/meta_tools.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/middleware.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/mounts.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/notifications.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/nvim_channel.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/nvim_proxy.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/permissions.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/proxyfactory.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/py.typed +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/resume_transport.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/routes.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/schema.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/schemafix.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/server.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/sharedserver.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/status.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/toolcache.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/__init__.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/holder.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/routes.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/sessions.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/static/app-bridge.bundle.js +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/ui_host/templates.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/upstream_era.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/upstream_listen.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/mcp_combiner/upstream_session.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/pyrightconfig.json +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/conftest.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/fakes.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/fixtures/servers.json +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_app_meta.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_auth.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_authprompt.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_combiner_reconnect.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_config.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_connections.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_ctl_lifecycle.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_elicit_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_era.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_externalservers.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_handover.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_inbound_auth.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_isolated.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_isolated_lifecycle_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_isolated_stdio.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_live_claude.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_mockserver.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_mounts.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_notifications.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_notifications_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_nvim_channel.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_nvim_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_oauth_mock.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_permissions.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_reload_config.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_resume_transport.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_route_matrix.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_schema_fixes.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_session_filter.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_session_independence.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_sharedserver.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_tool_fetch_wedge.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_ui_host.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_upstream_restart.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_upstream_session.py +0 -0
- {mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_visibility_and_reset_e2e.py +0 -0
|
@@ -17,12 +17,30 @@ tagged `vX.Y.Z`.
|
|
|
17
17
|
silently got the `elicitUnavailable` fallback.)
|
|
18
18
|
- **Bind to several addresses.** `bind.host` (servers.json) takes a list, and
|
|
19
19
|
`--host` / `MCP_COMBINER_HOST` a comma-separated one: e.g.
|
|
20
|
-
`["127.0.0.1", "
|
|
21
|
-
LAN. `
|
|
20
|
+
`["127.0.0.1", "auto"]` serves loopback and the tailnet but not the
|
|
21
|
+
LAN. `auto` resolves to this machine's tailnet address at startup; an
|
|
22
22
|
address that isn't up is skipped with a warning (startup fails only if none
|
|
23
23
|
bind); a wildcard covers the rest. The UI relay (port + 1) follows the same
|
|
24
24
|
bind. Any non-loopback bind without an inbound bearer token warns. The pi
|
|
25
|
-
plugin connects to the first entry (loopback for a wildcard or `
|
|
25
|
+
plugin connects to the first entry (loopback for a wildcard or `auto`).
|
|
26
|
+
A host name that doesn't resolve at startup is skipped like an address
|
|
27
|
+
that isn't up.
|
|
28
|
+
- **Portable tailnet settings.** `auto` as a whole value, or `{auto}` as the
|
|
29
|
+
host inside a URL, means this machine on its tailnet, in `bind.host`,
|
|
30
|
+
`MCP_COMBINER_UI_ADVERTISE` and `oauth.public_url`. Advertise `auto` (the
|
|
31
|
+
default) now names the MagicDNS name (`tailscale status`) rather than the
|
|
32
|
+
raw tailnet IP, falling back to the IP. `oauth.public_url: "auto"` is
|
|
33
|
+
`http://<magicdns name>:<port>`; `"https://{auto}"` suits `tailscale serve`.
|
|
34
|
+
New `MCP_COMBINER_OAUTH_PUBLIC_URL` (a literal URL) overrides the setting.
|
|
35
|
+
- `MCP_COMBINER_OAUTH_PUBLIC_URL` (and a literal `public_url`) may be a bare
|
|
36
|
+
host: `http://` and, on plain http, the combiner's port are added. A bare
|
|
37
|
+
host used to become a redirect URI with no scheme, which broke the OAuth
|
|
38
|
+
connection outright.
|
|
39
|
+
- Mock server `--issuer` (`auto` = the tailnet name): the authorization server
|
|
40
|
+
URL it advertises, so a phone can complete the mock's OAuth flow.
|
|
41
|
+
- An explicit advertised origin keeps its own port
|
|
42
|
+
(`MCP_COMBINER_UI_ADVERTISE=http://host:443` gave `http://host:443:9741`),
|
|
43
|
+
and a bare IPv6 host is bracketed.
|
|
26
44
|
- **Per-server `protocol` setting** — `auto` (default), `legacy` or `2026`:
|
|
27
45
|
which MCP revision the combiner speaks to an upstream. `auto` asks the server
|
|
28
46
|
(`server/discover`) before mounting it; a server listing 2026-07-28 is
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mcp-combiner
|
|
3
|
-
Version: 0.20.0-dev.
|
|
3
|
+
Version: 0.20.0-dev.4
|
|
4
4
|
Summary: An MCP aggregator — fronts multiple MCP servers behind a single Streamable HTTP endpoint, shareable across clients.
|
|
5
5
|
Project-URL: Homepage, https://github.com/georgeharker/mcp-companion
|
|
6
6
|
Project-URL: Repository, https://github.com/georgeharker/mcp-companion
|
|
@@ -368,6 +368,7 @@ def create_app(options: ServeOptions | None = None) -> Starlette:
|
|
|
368
368
|
"""
|
|
369
369
|
if options is None:
|
|
370
370
|
options = ServeOptions.from_env()
|
|
371
|
+
RUNTIME.serve_port = options.port
|
|
371
372
|
|
|
372
373
|
combiner, proc_manager = create_combiner(
|
|
373
374
|
options.config,
|
|
@@ -444,7 +445,6 @@ def create_app(options: ServeOptions | None = None) -> Starlette:
|
|
|
444
445
|
logger.info("auth: inbound bearer required on /mcp, /sessions, /handover")
|
|
445
446
|
# The UI host's loopback clients read this to present the same bearer on
|
|
446
447
|
# their /mcp/<token> calls (the middleware does not exempt loopback).
|
|
447
|
-
from mcp_combiner.runtime import RUNTIME
|
|
448
448
|
|
|
449
449
|
RUNTIME.inbound_auth_token = options.auth_token
|
|
450
450
|
RUNTIME.local_origin = f"http://127.0.0.1:{options.port}"
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
The bind setting (CLI ``--host`` > ``MCP_COMBINER_HOST`` > servers.json
|
|
4
4
|
``bind.host`` > ``127.0.0.1``) is a list: ``"bind": {"host": ["127.0.0.1",
|
|
5
|
-
"
|
|
5
|
+
"auto"]}``, or comma-separated on the CLI / in the env var. Entries:
|
|
6
6
|
|
|
7
7
|
- an address (``127.0.0.1``, ``::1``, ``100.101.102.103``);
|
|
8
|
-
- ``
|
|
9
|
-
detection the widget URLs use, ``ui_host.advertise
|
|
8
|
+
- ``auto`` — this machine's tailnet IPv4, looked up at startup (the tailnet
|
|
9
|
+
detection the widget URLs use, ``ui_host.advertise``; an IP, so no DNS);
|
|
10
10
|
- a wildcard (``0.0.0.0`` / ``::``) — every interface; it already covers the
|
|
11
|
-
specific addresses, so a list containing one keeps only the wildcards
|
|
11
|
+
specific addresses, so a list containing one keeps only the wildcards;
|
|
12
|
+
- a host name — resolved when binding; one that doesn't resolve is skipped
|
|
13
|
+
like an address that isn't up. (Prefer ``auto`` to a MagicDNS name: same
|
|
14
|
+
address, no DNS dependency.)
|
|
12
15
|
|
|
13
16
|
An address that isn't up when the combiner starts (Tailscale down, an
|
|
14
17
|
interface gone) is skipped with a warning rather than failing startup; a
|
|
@@ -24,10 +27,11 @@ import logging
|
|
|
24
27
|
import socket
|
|
25
28
|
from collections.abc import Sequence
|
|
26
29
|
|
|
30
|
+
from mcp_combiner.ui_host.advertise import AUTO
|
|
31
|
+
|
|
27
32
|
logger = logging.getLogger("mcp-combiner")
|
|
28
33
|
|
|
29
34
|
DEFAULT_HOST = "127.0.0.1"
|
|
30
|
-
TAILSCALE = "tailscale"
|
|
31
35
|
WILDCARDS = frozenset({"0.0.0.0", "::"})
|
|
32
36
|
|
|
33
37
|
|
|
@@ -45,11 +49,11 @@ def parse_hosts(value: str | Sequence[str] | None) -> list[str]:
|
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
def resolve_hosts(entries: Sequence[str]) -> list[str]:
|
|
48
|
-
"""Concrete addresses for *entries*: ``
|
|
52
|
+
"""Concrete addresses for *entries*: ``auto`` looked up, wildcards
|
|
49
53
|
collapsed, unavailable aliases dropped (warned). ``[]`` → the default."""
|
|
50
54
|
hosts: list[str] = []
|
|
51
55
|
for entry in entries or [DEFAULT_HOST]:
|
|
52
|
-
if entry.lower() ==
|
|
56
|
+
if entry.lower() == AUTO:
|
|
53
57
|
address = tailnet_address()
|
|
54
58
|
if address is None:
|
|
55
59
|
logger.warning(
|
|
@@ -69,9 +73,9 @@ def resolve_hosts(entries: Sequence[str]) -> list[str]:
|
|
|
69
73
|
|
|
70
74
|
def tailnet_address() -> str | None:
|
|
71
75
|
"""This machine's Tailscale IPv4, or ``None``."""
|
|
72
|
-
from mcp_combiner.ui_host.advertise import
|
|
76
|
+
from mcp_combiner.ui_host.advertise import tailnet_ip
|
|
73
77
|
|
|
74
|
-
return
|
|
78
|
+
return tailnet_ip()
|
|
75
79
|
|
|
76
80
|
|
|
77
81
|
def is_loopback(host: str) -> bool:
|
|
@@ -112,7 +116,12 @@ def _bind_one(host: str, port: int) -> socket.socket | None:
|
|
|
112
116
|
sock.listen(2048)
|
|
113
117
|
except OSError as exc:
|
|
114
118
|
sock.close()
|
|
115
|
-
|
|
119
|
+
# gaierror: a name that doesn't resolve (yet) — e.g. a MagicDNS name
|
|
120
|
+
# while Tailscale is down.
|
|
121
|
+
if isinstance(exc, socket.gaierror) or exc.errno in (
|
|
122
|
+
errno.EADDRNOTAVAIL,
|
|
123
|
+
errno.EAFNOSUPPORT,
|
|
124
|
+
):
|
|
116
125
|
logger.warning("bind: %s:%d isn't available here (%s) — skipped", host, port, exc)
|
|
117
126
|
return None
|
|
118
127
|
raise
|
|
@@ -692,6 +692,12 @@ class OAuthConfig(BaseModel):
|
|
|
692
692
|
OAuth client (for Google: a Web-application client). When unset, the
|
|
693
693
|
loopback callback is used, which completes only from a browser on the
|
|
694
694
|
combiner host.
|
|
695
|
+
|
|
696
|
+
``"auto"`` keeps the config portable: this machine's Tailscale MagicDNS
|
|
697
|
+
name on the combiner's port, or unset when there is no tailnet. Inside a
|
|
698
|
+
URL, ``{auto}`` is that name (``"https://{auto}"`` for ``tailscale
|
|
699
|
+
serve``). ``$MCP_COMBINER_OAUTH_PUBLIC_URL`` (a literal URL) overrides the
|
|
700
|
+
setting. Stored resolved — see :func:`resolve_public_url`.
|
|
695
701
|
"""
|
|
696
702
|
|
|
697
703
|
prompt: AuthPrompt | None = None
|
|
@@ -711,7 +717,7 @@ class OAuthConfig(BaseModel):
|
|
|
711
717
|
public_url = data.get("public_url") or data.get("publicUrl")
|
|
712
718
|
if public_url is not None and not isinstance(public_url, str):
|
|
713
719
|
raise ValueError("oauth.public_url must be a string")
|
|
714
|
-
public_url = public_url
|
|
720
|
+
public_url = resolve_public_url(public_url)
|
|
715
721
|
raw_prompt = data.get("prompt")
|
|
716
722
|
prompt = (
|
|
717
723
|
None
|
|
@@ -726,6 +732,61 @@ class OAuthConfig(BaseModel):
|
|
|
726
732
|
)
|
|
727
733
|
|
|
728
734
|
|
|
735
|
+
PUBLIC_URL_ENV = "MCP_COMBINER_OAUTH_PUBLIC_URL"
|
|
736
|
+
|
|
737
|
+
|
|
738
|
+
def _complete_url(value: str) -> str:
|
|
739
|
+
"""A bare host becomes a URL: ``http://`` when there's no scheme, and the
|
|
740
|
+
combiner's port on plain ``http`` with none (``https`` keeps 443)."""
|
|
741
|
+
if "://" not in value:
|
|
742
|
+
value = f"http://{value}"
|
|
743
|
+
scheme, _, rest = value.partition("://")
|
|
744
|
+
authority, slash, path = rest.partition("/")
|
|
745
|
+
from mcp_combiner.ui_host.advertise import _has_port
|
|
746
|
+
|
|
747
|
+
if scheme == "http" and not _has_port(authority):
|
|
748
|
+
from mcp_combiner.runtime import RUNTIME
|
|
749
|
+
|
|
750
|
+
authority = f"{authority}:{RUNTIME.serve_port or 9741}"
|
|
751
|
+
return f"{scheme}://{authority}{slash}{path}"
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+
def resolve_public_url(setting: str | None) -> str | None:
|
|
755
|
+
"""The concrete ``oauth.public_url``.
|
|
756
|
+
|
|
757
|
+
``$MCP_COMBINER_OAUTH_PUBLIC_URL``, when set, is the URL, verbatim.
|
|
758
|
+
Otherwise the *setting*: a literal URL; ``auto`` — this machine's
|
|
759
|
+
Tailscale MagicDNS name (else its tailnet IP) on the combiner's port; or a
|
|
760
|
+
URL with ``{auto}`` as its host (``https://{auto}`` for ``tailscale
|
|
761
|
+
serve``). No tailnet → ``None``: links use the loopback callback.
|
|
762
|
+
"""
|
|
763
|
+
env = os.environ.get(PUBLIC_URL_ENV, "").strip().rstrip("/")
|
|
764
|
+
if env:
|
|
765
|
+
return _complete_url(env)
|
|
766
|
+
from mcp_combiner.ui_host.advertise import AUTO, AUTO_HOST, tailnet_host
|
|
767
|
+
|
|
768
|
+
value = (setting or "").strip().rstrip("/")
|
|
769
|
+
if not value:
|
|
770
|
+
return None
|
|
771
|
+
if value.lower() == AUTO:
|
|
772
|
+
value = f"http://{AUTO_HOST}"
|
|
773
|
+
elif "://" not in value:
|
|
774
|
+
value = f"http://{value}"
|
|
775
|
+
if AUTO_HOST not in value:
|
|
776
|
+
return _complete_url(value)
|
|
777
|
+
name = tailnet_host()
|
|
778
|
+
if name is None:
|
|
779
|
+
logger.info("oauth.public_url %s: no tailnet here — links use the loopback callback", value)
|
|
780
|
+
return None
|
|
781
|
+
scheme, _, rest = value.partition("://")
|
|
782
|
+
authority, slash, path = rest.partition("/")
|
|
783
|
+
if authority == AUTO_HOST and scheme == "http":
|
|
784
|
+
from mcp_combiner.runtime import RUNTIME
|
|
785
|
+
|
|
786
|
+
authority = f"{AUTO_HOST}:{RUNTIME.serve_port or 9741}"
|
|
787
|
+
return f"{scheme}://{authority.replace(AUTO_HOST, name)}{slash}{path}"
|
|
788
|
+
|
|
789
|
+
|
|
729
790
|
class IsolationConfig(BaseModel):
|
|
730
791
|
"""Lifecycle knobs for token-keyed isolated upstream sessions.
|
|
731
792
|
|
|
@@ -764,8 +825,8 @@ class BindConfig(BaseModel):
|
|
|
764
825
|
``0.0.0.0`` serves loopback + every interface (LAN + tailnet) — required
|
|
765
826
|
for the remote widget leg (docs/designs/advertised-ui-origin.md).
|
|
766
827
|
|
|
767
|
-
``host`` may be a list — ``["127.0.0.1", "
|
|
768
|
-
and the tailnet only (``
|
|
828
|
+
``host`` may be a list — ``["127.0.0.1", "auto"]`` listens on loopback
|
|
829
|
+
and the tailnet only (``auto`` resolves to this machine's tailnet
|
|
769
830
|
address at startup); see ``mcp_combiner.binding``.
|
|
770
831
|
"""
|
|
771
832
|
|
|
@@ -1391,6 +1391,21 @@ class MockOAuthProvider:
|
|
|
1391
1391
|
await send({"type": "http.response.body", "body": body})
|
|
1392
1392
|
|
|
1393
1393
|
|
|
1394
|
+
def _issuer_url(setting: str | None, local_host: str, port: int) -> str:
|
|
1395
|
+
"""The mock's advertised issuer: *setting* (``auto`` = the tailnet name),
|
|
1396
|
+
else ``http://<local_host>:<port>``."""
|
|
1397
|
+
if setting is None:
|
|
1398
|
+
return f"http://{local_host}:{port}"
|
|
1399
|
+
if setting.strip().lower() == "auto":
|
|
1400
|
+
from mcp_combiner.ui_host.advertise import tailnet_host
|
|
1401
|
+
|
|
1402
|
+
name = tailnet_host()
|
|
1403
|
+
if name is None:
|
|
1404
|
+
raise SystemExit("--issuer auto: no tailnet on this machine")
|
|
1405
|
+
return f"http://{name}:{port}"
|
|
1406
|
+
return setting.rstrip("/")
|
|
1407
|
+
|
|
1408
|
+
|
|
1394
1409
|
def pin_handshake_only(mcp_srv: FastMCP) -> None:
|
|
1395
1410
|
"""Answer server/discover with no supported versions, so a probing client
|
|
1396
1411
|
(and the combiner's protocol: auto) uses the handshake. HTTP only: on an
|
|
@@ -1456,6 +1471,17 @@ def main(argv: list[str] | None = None) -> None:
|
|
|
1456
1471
|
"mock__end_session and a visible session_id on mock__remember / mock__recall."
|
|
1457
1472
|
),
|
|
1458
1473
|
)
|
|
1474
|
+
parser.add_argument(
|
|
1475
|
+
"--issuer",
|
|
1476
|
+
default=None,
|
|
1477
|
+
metavar="URL",
|
|
1478
|
+
help=(
|
|
1479
|
+
"With --oauth: the authorization server URL the mock advertises, where "
|
|
1480
|
+
"browsers are sent to log in (default: http://<host>:<port>). 'auto' = "
|
|
1481
|
+
"this machine's tailnet name on --port, so a phone can authorize; bind "
|
|
1482
|
+
"--host to every interface (or the tailnet address) to serve it."
|
|
1483
|
+
),
|
|
1484
|
+
)
|
|
1459
1485
|
parser.add_argument(
|
|
1460
1486
|
"--oauth",
|
|
1461
1487
|
action="store_true",
|
|
@@ -1479,8 +1505,13 @@ def main(argv: list[str] | None = None) -> None:
|
|
|
1479
1505
|
parser.error("--oauth requires --transport http")
|
|
1480
1506
|
import uvicorn
|
|
1481
1507
|
|
|
1482
|
-
|
|
1483
|
-
|
|
1508
|
+
from mcp_combiner.binding import WILDCARDS
|
|
1509
|
+
|
|
1510
|
+
local = "127.0.0.1" if args.host in WILDCARDS else args.host
|
|
1511
|
+
issuer = _issuer_url(args.issuer, local, args.port)
|
|
1512
|
+
provider = MockOAuthProvider(
|
|
1513
|
+
resource_url=f"http://{local}:{args.port}/mcp", issuer_url=issuer
|
|
1514
|
+
)
|
|
1484
1515
|
mcp_srv, _state = build_server(
|
|
1485
1516
|
args.name, args.transport, specs, state_dir, provider, args.sessions
|
|
1486
1517
|
)
|
|
@@ -389,6 +389,9 @@ class CombinerRuntime:
|
|
|
389
389
|
# The combiner's own loopback base URL (http://127.0.0.1:<port>), set by
|
|
390
390
|
# create_app — where locally-opened links (OAuth short links) point.
|
|
391
391
|
local_origin: str | None = None
|
|
392
|
+
# The port the combiner serves on, set by create_app before the config is
|
|
393
|
+
# loaded (oauth.public_url "auto" without a port defaults to it).
|
|
394
|
+
serve_port: int | None = None
|
|
392
395
|
conn_manager: ConnectionManager | None = None
|
|
393
396
|
proc_manager: BackingProcessManager | None = None
|
|
394
397
|
|
|
@@ -8,14 +8,16 @@ advertise knob changes only the origin prefix of `/ui/<token>/…` URLs.
|
|
|
8
8
|
|
|
9
9
|
Modes (MCP_COMBINER_UI_ADVERTISE, default ``auto``):
|
|
10
10
|
|
|
11
|
-
- ``auto`` —
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
- ``auto`` — this machine's tailnet name, by :func:`tailnet_host`: (1) its
|
|
12
|
+
MagicDNS name (``tailscale status --json``, ``Self.DNSName``), (2) its
|
|
13
|
+
tailnet IP from tailscaled (``tailscale ip -4``), (3) an interface address in
|
|
14
|
+
Tailscale's reserved CGNAT range (100.64.0.0/10 — some ISPs assign CGNAT
|
|
15
|
+
space too, which is why the daemon outranks it); none → the bind host
|
|
16
|
+
(loopback).
|
|
16
17
|
- ``loopback`` — force local-only URLs (the pre-feature behavior).
|
|
17
|
-
- ``http://host[:port]`` — explicit override
|
|
18
|
-
for the tailscale-serve
|
|
18
|
+
- ``http://host[:port]`` — explicit override; ``{auto}`` as the host stands for
|
|
19
|
+
the tailnet name (``https://{auto}`` for the tailscale-serve variant), so the
|
|
20
|
+
setting stays portable. Braces can't occur in a real host name.
|
|
19
21
|
|
|
20
22
|
v1 resolves once at boot (tailnet IP changes are rare; a restart heals). The
|
|
21
23
|
design doc notes the refinement: a TTL cache behind the URL constructors so
|
|
@@ -62,6 +64,45 @@ def _tailscale_ip() -> str | None:
|
|
|
62
64
|
return None
|
|
63
65
|
|
|
64
66
|
|
|
67
|
+
def _tailscale_dns_name() -> str | None:
|
|
68
|
+
"""This machine's MagicDNS name from the tailscale daemon, or ``None``
|
|
69
|
+
(daemon absent, MagicDNS off)."""
|
|
70
|
+
import json
|
|
71
|
+
|
|
72
|
+
if shutil.which("tailscale") is None:
|
|
73
|
+
return None
|
|
74
|
+
try:
|
|
75
|
+
out = subprocess.run(
|
|
76
|
+
["tailscale", "status", "--json", "--peers=false"],
|
|
77
|
+
capture_output=True,
|
|
78
|
+
text=True,
|
|
79
|
+
timeout=_TIER1_TIMEOUT_S,
|
|
80
|
+
check=False,
|
|
81
|
+
)
|
|
82
|
+
status = json.loads(out.stdout or "{}")
|
|
83
|
+
except (OSError, subprocess.TimeoutExpired, ValueError):
|
|
84
|
+
return None
|
|
85
|
+
me = status.get("Self") if isinstance(status, dict) else None
|
|
86
|
+
name = me.get("DNSName") if isinstance(me, dict) else None
|
|
87
|
+
return name.rstrip(".") or None if isinstance(name, str) else None
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
#: A setting's whole value meaning "this machine's tailnet" (bind, advertise,
|
|
91
|
+
#: oauth.public_url), and the same as a host placeholder inside a URL.
|
|
92
|
+
AUTO = "auto"
|
|
93
|
+
AUTO_HOST = "{auto}"
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def tailnet_host() -> str | None:
|
|
97
|
+
"""This machine's tailnet name for URLs: MagicDNS name, else tailnet IP."""
|
|
98
|
+
return _tailscale_dns_name() or _tailscale_ip() or _interface_scan_ip()
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def tailnet_ip() -> str | None:
|
|
102
|
+
"""This machine's tailnet IPv4 (for binding: no DNS involved)."""
|
|
103
|
+
return _tailscale_ip() or _interface_scan_ip()
|
|
104
|
+
|
|
105
|
+
|
|
65
106
|
def _interface_scan_ip() -> str | None:
|
|
66
107
|
"""Tier 2: scan interface addresses for the CGNAT range.
|
|
67
108
|
|
|
@@ -108,22 +149,39 @@ def resolve_advertised_host(bind_host: str, mode: str | None = None) -> str:
|
|
|
108
149
|
"""
|
|
109
150
|
import os
|
|
110
151
|
|
|
111
|
-
advertise = (mode or os.environ.get(_ENV) or
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
# Bind-all is a bind, not a name — never construct URLs with it.
|
|
117
|
-
return "127.0.0.1" if bind_host in ("0.0.0.0", "::", "") else bind_host
|
|
152
|
+
advertise = (mode or os.environ.get(_ENV) or AUTO).strip().lower()
|
|
153
|
+
# Bind-all is a bind, not a name — never construct URLs with it.
|
|
154
|
+
local = "127.0.0.1" if bind_host in ("0.0.0.0", "::", "") else bind_host
|
|
155
|
+
if advertise in ("", AUTO):
|
|
156
|
+
return tailnet_host() or local
|
|
118
157
|
if advertise in ("loopback", "local", "none"):
|
|
119
158
|
return bind_host
|
|
120
159
|
# Explicit origin: accept scheme://host[:port] and a bare host alike.
|
|
121
160
|
if "://" in advertise:
|
|
122
161
|
advertise = advertise.split("://", 1)[1]
|
|
123
|
-
|
|
162
|
+
advertise = advertise.rstrip("/")
|
|
163
|
+
if AUTO_HOST in advertise:
|
|
164
|
+
name = tailnet_host()
|
|
165
|
+
if name is None:
|
|
166
|
+
return local
|
|
167
|
+
advertise = advertise.replace(AUTO_HOST, name)
|
|
168
|
+
return advertise or bind_host
|
|
124
169
|
|
|
125
170
|
|
|
126
171
|
def advertised_origin(bind_host: str, port: int, mode: str | None = None) -> str:
|
|
127
172
|
"""The full advertised origin for the UI host page (``http://<host>:<port>``)."""
|
|
128
173
|
host = resolve_advertised_host(bind_host, mode)
|
|
174
|
+
if _has_port(host):
|
|
175
|
+
return f"http://{host}" # an explicit origin's own port wins
|
|
176
|
+
if ":" in host and not host.startswith("["):
|
|
177
|
+
host = f"[{host}]" # a bare IPv6 address
|
|
129
178
|
return f"http://{host}:{port}"
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _has_port(host: str) -> bool:
|
|
182
|
+
"""Whether *host* already carries ``:port`` (``name:80``, ``[::1]:80``;
|
|
183
|
+
a bare IPv6 address does not)."""
|
|
184
|
+
head, sep, tail = host.rpartition(":")
|
|
185
|
+
if not sep or not tail.isdigit():
|
|
186
|
+
return False
|
|
187
|
+
return head.endswith("]") or ":" not in head
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mcp-combiner"
|
|
3
|
-
version = "0.20.0-dev.
|
|
3
|
+
version = "0.20.0-dev.4"
|
|
4
4
|
description = "An MCP aggregator — fronts multiple MCP servers behind a single Streamable HTTP endpoint, shareable across clients."
|
|
5
5
|
requires-python = ">=3.12"
|
|
6
6
|
license = "MIT"
|
|
@@ -21,6 +21,8 @@ from mcp_combiner.ui_host.advertise import (
|
|
|
21
21
|
@pytest.fixture(autouse=True)
|
|
22
22
|
def _clean_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
23
23
|
monkeypatch.delenv("MCP_COMBINER_UI_ADVERTISE", raising=False)
|
|
24
|
+
# No MagicDNS name unless a test gives one (never the real machine's).
|
|
25
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: None)
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
def test_cgnat_range_shape() -> None:
|
|
@@ -79,3 +81,44 @@ def test_origin_composition() -> None:
|
|
|
79
81
|
advertised_origin("127.0.0.1", 9741, "combiner.example") == "http://combiner.example:9741"
|
|
80
82
|
)
|
|
81
83
|
assert advertised_origin("127.0.0.1", 9741, "loopback") == "http://127.0.0.1:9741"
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_auto_prefers_the_magicdns_name(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
87
|
+
monkeypatch.setattr(
|
|
88
|
+
"mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: "box.tailnet.ts.net"
|
|
89
|
+
)
|
|
90
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_ip", lambda: "100.64.5.5")
|
|
91
|
+
assert resolve_advertised_host("127.0.0.1") == "box.tailnet.ts.net"
|
|
92
|
+
assert advertised_origin("127.0.0.1", 9741, "AUTO") == "http://box.tailnet.ts.net:9741"
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_auto_placeholder_inside_an_explicit_origin(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
96
|
+
monkeypatch.setattr(
|
|
97
|
+
"mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: "box.tailnet.ts.net"
|
|
98
|
+
)
|
|
99
|
+
assert advertised_origin("127.0.0.1", 9741, "https://{auto}:443") == (
|
|
100
|
+
"http://box.tailnet.ts.net:443"
|
|
101
|
+
)
|
|
102
|
+
assert advertised_origin("127.0.0.1", 9741, "{auto}") == "http://box.tailnet.ts.net:9741"
|
|
103
|
+
# A host that happens to be called "auto" is just a host.
|
|
104
|
+
assert advertised_origin("127.0.0.1", 9741, "http://auto:8000") == "http://auto:8000"
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_auto_placeholder_without_a_tailnet_is_local(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
108
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_ip", lambda: None)
|
|
109
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._interface_scan_ip", lambda: None)
|
|
110
|
+
assert resolve_advertised_host("0.0.0.0", "https://{auto}") == "127.0.0.1"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@pytest.mark.parametrize(
|
|
114
|
+
("mode", "origin"),
|
|
115
|
+
[
|
|
116
|
+
("http://box.tailnet.ts.net", "http://box.tailnet.ts.net:9741"),
|
|
117
|
+
("http://box.tailnet.ts.net:443", "http://box.tailnet.ts.net:443"),
|
|
118
|
+
("box.tailnet.ts.net:8080/", "http://box.tailnet.ts.net:8080"),
|
|
119
|
+
("http://[fd7a::1]:9000", "http://[fd7a::1]:9000"),
|
|
120
|
+
("fd7a::1", "http://[fd7a::1]:9741"),
|
|
121
|
+
],
|
|
122
|
+
)
|
|
123
|
+
def test_an_explicit_origin_keeps_its_own_port(mode: str, origin: str) -> None:
|
|
124
|
+
assert advertised_origin("127.0.0.1", 9741, mode) == origin
|
|
@@ -29,25 +29,23 @@ def _has_ipv6_loopback() -> bool:
|
|
|
29
29
|
class TestParseAndResolve:
|
|
30
30
|
def test_parse_accepts_strings_lists_and_dedupes(self) -> None:
|
|
31
31
|
assert binding.parse_hosts("127.0.0.1, ::1,127.0.0.1") == ["127.0.0.1", "::1"]
|
|
32
|
-
assert binding.parse_hosts(["127.0.0.1", "
|
|
32
|
+
assert binding.parse_hosts(["127.0.0.1", " auto "]) == ["127.0.0.1", "auto"]
|
|
33
33
|
assert binding.parse_hosts("") == []
|
|
34
34
|
assert binding.parse_hosts(None) == []
|
|
35
35
|
|
|
36
|
-
def
|
|
37
|
-
self, monkeypatch: pytest.MonkeyPatch
|
|
38
|
-
) -> None:
|
|
36
|
+
def test_auto_resolves_to_the_tailnet_address(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
39
37
|
monkeypatch.setattr(binding, "tailnet_address", lambda: "100.101.102.103")
|
|
40
|
-
assert binding.resolve_hosts(["127.0.0.1", "
|
|
38
|
+
assert binding.resolve_hosts(["127.0.0.1", "auto"]) == [
|
|
41
39
|
"127.0.0.1",
|
|
42
40
|
"100.101.102.103",
|
|
43
41
|
]
|
|
44
42
|
|
|
45
|
-
def
|
|
43
|
+
def test_auto_without_a_tailnet_is_skipped_with_a_warning(
|
|
46
44
|
self, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture
|
|
47
45
|
) -> None:
|
|
48
46
|
monkeypatch.setattr(binding, "tailnet_address", lambda: None)
|
|
49
47
|
with caplog.at_level(logging.WARNING, logger="mcp-combiner"):
|
|
50
|
-
assert binding.resolve_hosts(["127.0.0.1", "
|
|
48
|
+
assert binding.resolve_hosts(["127.0.0.1", "Auto"]) == ["127.0.0.1"]
|
|
51
49
|
assert "no Tailscale address" in caplog.text
|
|
52
50
|
|
|
53
51
|
def test_a_wildcard_covers_the_rest(self) -> None:
|
|
@@ -140,3 +138,15 @@ async def test_a_busy_relay_port_does_not_stop_the_combiner(
|
|
|
140
138
|
async with httpx2.AsyncClient(timeout=5.0) as http:
|
|
141
139
|
assert (await http.get(f"http://127.0.0.1:{combiner.port}/health")).status_code == 200
|
|
142
140
|
assert "UI relay: can't listen" in (tmp_path / "combiner.log").read_text()
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_an_unresolvable_name_is_skipped(caplog: pytest.LogCaptureFixture) -> None:
|
|
144
|
+
port = free_port()
|
|
145
|
+
with caplog.at_level(logging.WARNING, logger="mcp-combiner"):
|
|
146
|
+
sockets = binding.bind_sockets(["127.0.0.1", "no-such-host.invalid"], port)
|
|
147
|
+
try:
|
|
148
|
+
assert len(sockets) == 1
|
|
149
|
+
assert "no-such-host.invalid" in caplog.text
|
|
150
|
+
finally:
|
|
151
|
+
for s in sockets:
|
|
152
|
+
s.close()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""``oauth.public_url``: the portable ``auto`` setting and the env override."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from mcp_combiner.config import PUBLIC_URL_ENV, OAuthConfig, resolve_public_url
|
|
8
|
+
from mcp_combiner.runtime import RUNTIME
|
|
9
|
+
|
|
10
|
+
NAME = "box.tailnet.ts.net"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.fixture(autouse=True)
|
|
14
|
+
def _tailnet(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
15
|
+
monkeypatch.delenv(PUBLIC_URL_ENV, raising=False)
|
|
16
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: NAME)
|
|
17
|
+
monkeypatch.setattr(RUNTIME, "serve_port", 9741)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@pytest.mark.parametrize(
|
|
21
|
+
("setting", "resolved"),
|
|
22
|
+
[
|
|
23
|
+
("auto", f"http://{NAME}:9741"),
|
|
24
|
+
("AUTO", f"http://{NAME}:9741"),
|
|
25
|
+
("{auto}", f"http://{NAME}:9741"),
|
|
26
|
+
("http://{auto}", f"http://{NAME}:9741"),
|
|
27
|
+
("https://{auto}", f"https://{NAME}"),
|
|
28
|
+
("https://{auto}:8443/", f"https://{NAME}:8443"),
|
|
29
|
+
("http://{auto}:80/prefix", f"http://{NAME}:80/prefix"),
|
|
30
|
+
("https://auto", "https://auto"), # a host named auto is just a host
|
|
31
|
+
("https://combiner.example.com/", "https://combiner.example.com"),
|
|
32
|
+
("combiner.example.com:9741", "http://combiner.example.com:9741"),
|
|
33
|
+
("combiner.example.com", "http://combiner.example.com:9741"),
|
|
34
|
+
("http://[fd7a::1]", "http://[fd7a::1]:9741"),
|
|
35
|
+
("http://[fd7a::1]:80", "http://[fd7a::1]:80"),
|
|
36
|
+
("", None),
|
|
37
|
+
(None, None),
|
|
38
|
+
],
|
|
39
|
+
)
|
|
40
|
+
def test_setting_forms(setting: str | None, resolved: str | None) -> None:
|
|
41
|
+
assert resolve_public_url(setting) == resolved
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_the_env_var_is_a_literal_url_and_wins(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
45
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "https://auth.example.com/")
|
|
46
|
+
assert resolve_public_url("auto") == "https://auth.example.com"
|
|
47
|
+
assert OAuthConfig.from_dict({}).public_url == "https://auth.example.com"
|
|
48
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "https://{auto}") # not special in the env
|
|
49
|
+
assert resolve_public_url(None) == "https://{auto}"
|
|
50
|
+
# A bare host (as easily typed into a shell profile) is completed.
|
|
51
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "box.example.ts.net")
|
|
52
|
+
assert resolve_public_url(None) == "http://box.example.ts.net:9741"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_auto_without_a_tailnet_means_loopback_links(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
56
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: None)
|
|
57
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_ip", lambda: None)
|
|
58
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._interface_scan_ip", lambda: None)
|
|
59
|
+
assert resolve_public_url("auto") is None
|
|
60
|
+
config = OAuthConfig.from_dict({"public_url": "auto"})
|
|
61
|
+
assert config.public_url is None and config.prompt is None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_the_config_stores_the_resolved_url() -> None:
|
|
65
|
+
assert OAuthConfig.from_dict({"public_url": "auto"}).public_url == f"http://{NAME}:9741"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mcp_combiner-0.20.0.dev2 → mcp_combiner-0.20.0.dev4}/tests/test_visibility_and_reset_e2e.py
RENAMED
|
File without changes
|