mcp-combiner 0.20.0.dev4__tar.gz → 0.20.0.dev5__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.dev4 → mcp_combiner-0.20.0.dev5}/CHANGELOG.md +7 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/PKG-INFO +1 -1
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/auth.py +3 -5
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/config.py +94 -4
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/pyproject.toml +1 -1
- mcp_combiner-0.20.0.dev5/tests/test_public_url.py +146 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/uv.lock +1 -1
- mcp_combiner-0.20.0.dev4/tests/test_public_url.py +0 -65
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/.gitignore +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/.python-version +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/LICENSE +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/README.md +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/__init__.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/__main__.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/asgi.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/authprompt.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/backing.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/binding.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/connections.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ctl.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/era.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/externalservers.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/fastvalidate.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/handover.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/heldcalls.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/inbound_auth.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/isolated.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/listen.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/meta_tools.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/middleware.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/mockserver.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/mounts.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/notifications.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/nvim_channel.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/nvim_proxy.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/permissions.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/proxyfactory.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/py.typed +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/resume_transport.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/routes.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/runtime.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/schema.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/schemafix.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/server.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/sharedserver.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/status.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/toolcache.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/__init__.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/advertise.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/holder.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/routes.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/sessions.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/static/app-bridge.bundle.js +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/ui_host/templates.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/upstream_era.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/upstream_listen.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/mcp_combiner/upstream_session.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/pyrightconfig.json +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/conftest.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/fakes.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/fixtures/servers.json +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_advertised_origin.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_app_meta.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_auth.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_authprompt.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_binding.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_combiner_reconnect.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_config.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_connections.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_ctl_lifecycle.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_elicit_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_era.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_externalservers.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_handover.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_inbound_auth.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_isolated.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_isolated_lifecycle_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_isolated_stdio.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_live_claude.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_mockserver.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_mounts.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_notifications.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_notifications_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_nvim_channel.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_nvim_e2e.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_oauth_mock.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_permissions.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_reload_config.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_resume_transport.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_route_matrix.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_schema_fixes.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_session_filter.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_session_independence.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_sharedserver.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_tool_fetch_wedge.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_ui_host.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_upstream_restart.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_upstream_session.py +0 -0
- {mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_visibility_and_reset_e2e.py +0 -0
|
@@ -36,6 +36,13 @@ tagged `vX.Y.Z`.
|
|
|
36
36
|
host: `http://` and, on plain http, the combiner's port are added. A bare
|
|
37
37
|
host used to become a redirect URI with no scheme, which broke the OAuth
|
|
38
38
|
connection outright.
|
|
39
|
+
- **`{oauth_redirect}` in server entries** expands to that server's callback,
|
|
40
|
+
`<public_url>/oauth/callback/<server>`, in `args`, `env`, `headers` and `url`
|
|
41
|
+
(and in a `sharedServers` / `externalServers` entry used by exactly one
|
|
42
|
+
server), so a server can be told its redirect URI without a machine name in
|
|
43
|
+
the config. Left as-is, with a warning, when there's no public URL.
|
|
44
|
+
- `MCP_COMBINER_OAUTH_PUBLIC_URL` now applies when servers.json has no `oauth`
|
|
45
|
+
block (it was ignored then).
|
|
39
46
|
- Mock server `--issuer` (`auto` = the tailnet name): the authorization server
|
|
40
47
|
URL it advertises, so a phone can complete the mock's OAuth flow.
|
|
41
48
|
- An explicit advertised origin keeps its own port
|
|
@@ -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.5
|
|
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
|
|
@@ -25,7 +25,7 @@ import time
|
|
|
25
25
|
import typing
|
|
26
26
|
from pathlib import Path
|
|
27
27
|
from typing import Any, ClassVar
|
|
28
|
-
from urllib.parse import parse_qs,
|
|
28
|
+
from urllib.parse import parse_qs, urlencode, urljoin, urlparse, urlunparse
|
|
29
29
|
|
|
30
30
|
import anyio
|
|
31
31
|
import httpx2
|
|
@@ -56,7 +56,7 @@ from mcp.shared.auth import AuthorizationCodeResult, OAuthToken
|
|
|
56
56
|
from pydantic import AnyHttpUrl
|
|
57
57
|
|
|
58
58
|
from mcp_combiner import authprompt
|
|
59
|
-
from mcp_combiner.config import AuthPrompt, resolve_auth_prompt
|
|
59
|
+
from mcp_combiner.config import AuthPrompt, oauth_redirect_uri, resolve_auth_prompt
|
|
60
60
|
|
|
61
61
|
logger = logging.getLogger("mcp-combiner")
|
|
62
62
|
|
|
@@ -289,9 +289,7 @@ class _RefreshTokenOAuth(OAuth):
|
|
|
289
289
|
return
|
|
290
290
|
# Redirect back to the combiner's own /oauth/callback/<server> route
|
|
291
291
|
# instead of the loopback callback server the parent configured.
|
|
292
|
-
redirect = AnyHttpUrl(
|
|
293
|
-
f"{self.public_url}/oauth/callback/{quote(self.server_name, safe='')}"
|
|
294
|
-
)
|
|
292
|
+
redirect = AnyHttpUrl(oauth_redirect_uri(self.public_url, self.server_name))
|
|
295
293
|
self.context.client_metadata.redirect_uris = [redirect]
|
|
296
294
|
if self._static_client_info is not None:
|
|
297
295
|
self._static_client_info.redirect_uris = [redirect]
|
|
@@ -787,6 +787,89 @@ def resolve_public_url(setting: str | None) -> str | None:
|
|
|
787
787
|
return f"{scheme}://{authority.replace(AUTO_HOST, name)}{slash}{path}"
|
|
788
788
|
|
|
789
789
|
|
|
790
|
+
OAUTH_REDIRECT = "{oauth_redirect}"
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
def oauth_redirect_uri(public_url: str, server: str) -> str:
|
|
794
|
+
"""Where the combiner receives *server*'s OAuth redirect (the
|
|
795
|
+
``/oauth/callback/<server>`` route) under *public_url*."""
|
|
796
|
+
from urllib.parse import quote
|
|
797
|
+
|
|
798
|
+
return f"{public_url}/oauth/callback/{quote(server, safe='')}"
|
|
799
|
+
|
|
800
|
+
|
|
801
|
+
def _replace_in(value: Any, text: str) -> Any:
|
|
802
|
+
"""*value* with ``{oauth_redirect}`` replaced by *text* in every string."""
|
|
803
|
+
if isinstance(value, str):
|
|
804
|
+
return value.replace(OAUTH_REDIRECT, text)
|
|
805
|
+
if isinstance(value, list):
|
|
806
|
+
return [_replace_in(v, text) for v in value]
|
|
807
|
+
if isinstance(value, dict):
|
|
808
|
+
return {k: _replace_in(v, text) for k, v in value.items()}
|
|
809
|
+
return value
|
|
810
|
+
|
|
811
|
+
|
|
812
|
+
def _mentions(value: Any) -> bool:
|
|
813
|
+
if isinstance(value, str):
|
|
814
|
+
return OAUTH_REDIRECT in value
|
|
815
|
+
if isinstance(value, list):
|
|
816
|
+
return any(_mentions(v) for v in value)
|
|
817
|
+
if isinstance(value, dict):
|
|
818
|
+
return any(_mentions(v) for v in value.values())
|
|
819
|
+
return False
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
def expand_oauth_redirects(
|
|
823
|
+
servers: dict[str, Any],
|
|
824
|
+
shared: dict[str, Any],
|
|
825
|
+
external: dict[str, Any],
|
|
826
|
+
public_url: str | None,
|
|
827
|
+
) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]:
|
|
828
|
+
"""Expand ``{oauth_redirect}`` in raw config entries: a server's own entry
|
|
829
|
+
gets its callback URL (:func:`oauth_redirect_uri`); a ``sharedServers`` /
|
|
830
|
+
``externalServers`` entry gets the callback of the one server that uses it.
|
|
831
|
+
For servers that must be told the combiner's redirect URI (an external
|
|
832
|
+
OAuth provider setup). Left as-is, with a warning, without a public URL or
|
|
833
|
+
when a backing entry serves several servers."""
|
|
834
|
+
if not any(_mentions(t) for t in (servers, shared, external)):
|
|
835
|
+
return servers, shared, external
|
|
836
|
+
if public_url is None:
|
|
837
|
+
logger.warning(
|
|
838
|
+
"{oauth_redirect} needs oauth.public_url (or %s): left unexpanded", PUBLIC_URL_ENV
|
|
839
|
+
)
|
|
840
|
+
return servers, shared, external
|
|
841
|
+
servers = {
|
|
842
|
+
name: _replace_in(entry, oauth_redirect_uri(public_url, name))
|
|
843
|
+
for name, entry in servers.items()
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
def backing(table: dict[str, Any], keys: tuple[str, ...]) -> dict[str, Any]:
|
|
847
|
+
out: dict[str, Any] = {}
|
|
848
|
+
for name, entry in table.items():
|
|
849
|
+
if not _mentions(entry):
|
|
850
|
+
out[name] = entry
|
|
851
|
+
continue
|
|
852
|
+
users = [
|
|
853
|
+
server
|
|
854
|
+
for server, srv in servers.items()
|
|
855
|
+
if isinstance(srv, dict) and any(srv.get(k) == name for k in keys)
|
|
856
|
+
]
|
|
857
|
+
if len(users) == 1:
|
|
858
|
+
out[name] = _replace_in(entry, oauth_redirect_uri(public_url, users[0]))
|
|
859
|
+
else:
|
|
860
|
+
logger.warning(
|
|
861
|
+
"{oauth_redirect} in '%s' is ambiguous: used by %s — left unexpanded",
|
|
862
|
+
name,
|
|
863
|
+
users or "no server",
|
|
864
|
+
)
|
|
865
|
+
out[name] = entry
|
|
866
|
+
return out
|
|
867
|
+
|
|
868
|
+
shared = backing(shared, ("sharedServer", "shared_server"))
|
|
869
|
+
external = backing(external, ("externalServer", "external_server"))
|
|
870
|
+
return servers, shared, external
|
|
871
|
+
|
|
872
|
+
|
|
790
873
|
class IsolationConfig(BaseModel):
|
|
791
874
|
"""Lifecycle knobs for token-keyed isolated upstream sessions.
|
|
792
875
|
|
|
@@ -901,17 +984,26 @@ class CombinerConfig(BaseModel):
|
|
|
901
984
|
except json.JSONDecodeError as exc:
|
|
902
985
|
raise ValueError(f"Config file {path} is not valid JSON: {exc}") from exc
|
|
903
986
|
|
|
987
|
+
# Resolved first: {oauth_redirect} in server entries names its result.
|
|
988
|
+
# Always parsed, so $MCP_COMBINER_OAUTH_PUBLIC_URL applies without an
|
|
989
|
+
# "oauth" block.
|
|
990
|
+
raw_oauth: dict[str, Any] = raw.get("oauth", {})
|
|
991
|
+
oauth = OAuthConfig.from_dict(raw_oauth)
|
|
992
|
+
|
|
904
993
|
raw_servers: dict[str, Any] = raw.get("servers", raw.get("mcpServers", {}))
|
|
994
|
+
raw_shared: dict[str, Any] = raw.get("sharedServers", {})
|
|
995
|
+
raw_external: dict[str, Any] = raw.get("externalServers", {})
|
|
996
|
+
raw_servers, raw_shared, raw_external = expand_oauth_redirects(
|
|
997
|
+
raw_servers, raw_shared, raw_external, oauth.public_url
|
|
998
|
+
)
|
|
905
999
|
servers = {
|
|
906
1000
|
name: ServerConfig.from_dict(name, srv_data) for name, srv_data in raw_servers.items()
|
|
907
1001
|
}
|
|
908
1002
|
|
|
909
|
-
raw_shared: dict[str, Any] = raw.get("sharedServers", {})
|
|
910
1003
|
shared_servers = {
|
|
911
1004
|
name: SharedServerConfig.from_dict(name, data) for name, data in raw_shared.items()
|
|
912
1005
|
}
|
|
913
1006
|
|
|
914
|
-
raw_external: dict[str, Any] = raw.get("externalServers", {})
|
|
915
1007
|
external_servers = {
|
|
916
1008
|
name: ExternalServerConfig.from_dict(name, data) for name, data in raw_external.items()
|
|
917
1009
|
}
|
|
@@ -941,8 +1033,6 @@ class CombinerConfig(BaseModel):
|
|
|
941
1033
|
field,
|
|
942
1034
|
)
|
|
943
1035
|
|
|
944
|
-
raw_oauth: dict[str, Any] = raw.get("oauth", {})
|
|
945
|
-
oauth = OAuthConfig.from_dict(raw_oauth) if raw_oauth else OAuthConfig()
|
|
946
1036
|
# Validates every server's prompt up front (a typo fails the load, not
|
|
947
1037
|
# the first re-auth) and flags elicitation that can't reach a remote device.
|
|
948
1038
|
for name, srv in servers.items():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mcp-combiner"
|
|
3
|
-
version = "0.20.0-dev.
|
|
3
|
+
version = "0.20.0-dev.5"
|
|
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"
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""``oauth.public_url``: the portable ``auto`` setting and the env override."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from mcp_combiner.config import (
|
|
12
|
+
PUBLIC_URL_ENV,
|
|
13
|
+
CombinerConfig,
|
|
14
|
+
OAuthConfig,
|
|
15
|
+
resolve_public_url,
|
|
16
|
+
)
|
|
17
|
+
from mcp_combiner.runtime import RUNTIME
|
|
18
|
+
|
|
19
|
+
NAME = "box.tailnet.ts.net"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture(autouse=True)
|
|
23
|
+
def _tailnet(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
24
|
+
monkeypatch.delenv(PUBLIC_URL_ENV, raising=False)
|
|
25
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: NAME)
|
|
26
|
+
monkeypatch.setattr(RUNTIME, "serve_port", 9741)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.mark.parametrize(
|
|
30
|
+
("setting", "resolved"),
|
|
31
|
+
[
|
|
32
|
+
("auto", f"http://{NAME}:9741"),
|
|
33
|
+
("AUTO", f"http://{NAME}:9741"),
|
|
34
|
+
("{auto}", f"http://{NAME}:9741"),
|
|
35
|
+
("http://{auto}", f"http://{NAME}:9741"),
|
|
36
|
+
("https://{auto}", f"https://{NAME}"),
|
|
37
|
+
("https://{auto}:8443/", f"https://{NAME}:8443"),
|
|
38
|
+
("http://{auto}:80/prefix", f"http://{NAME}:80/prefix"),
|
|
39
|
+
("https://auto", "https://auto"), # a host named auto is just a host
|
|
40
|
+
("https://combiner.example.com/", "https://combiner.example.com"),
|
|
41
|
+
("combiner.example.com:9741", "http://combiner.example.com:9741"),
|
|
42
|
+
("combiner.example.com", "http://combiner.example.com:9741"),
|
|
43
|
+
("http://[fd7a::1]", "http://[fd7a::1]:9741"),
|
|
44
|
+
("http://[fd7a::1]:80", "http://[fd7a::1]:80"),
|
|
45
|
+
("", None),
|
|
46
|
+
(None, None),
|
|
47
|
+
],
|
|
48
|
+
)
|
|
49
|
+
def test_setting_forms(setting: str | None, resolved: str | None) -> None:
|
|
50
|
+
assert resolve_public_url(setting) == resolved
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_the_env_var_is_a_literal_url_and_wins(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
54
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "https://auth.example.com/")
|
|
55
|
+
assert resolve_public_url("auto") == "https://auth.example.com"
|
|
56
|
+
assert OAuthConfig.from_dict({}).public_url == "https://auth.example.com"
|
|
57
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "https://{auto}") # not special in the env
|
|
58
|
+
assert resolve_public_url(None) == "https://{auto}"
|
|
59
|
+
# A bare host (as easily typed into a shell profile) is completed.
|
|
60
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "box.example.ts.net")
|
|
61
|
+
assert resolve_public_url(None) == "http://box.example.ts.net:9741"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_auto_without_a_tailnet_means_loopback_links(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
65
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_dns_name", lambda: None)
|
|
66
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._tailscale_ip", lambda: None)
|
|
67
|
+
monkeypatch.setattr("mcp_combiner.ui_host.advertise._interface_scan_ip", lambda: None)
|
|
68
|
+
assert resolve_public_url("auto") is None
|
|
69
|
+
config = OAuthConfig.from_dict({"public_url": "auto"})
|
|
70
|
+
assert config.public_url is None and config.prompt is None
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_the_config_stores_the_resolved_url() -> None:
|
|
74
|
+
assert OAuthConfig.from_dict({"public_url": "auto"}).public_url == f"http://{NAME}:9741"
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# ── {oauth_redirect} in server entries ─────────────────────────────
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _load(tmp_path: Path, doc: dict[str, object]) -> CombinerConfig:
|
|
81
|
+
path = tmp_path / "servers.json"
|
|
82
|
+
path.write_text(json.dumps(doc))
|
|
83
|
+
return CombinerConfig.load(str(path))
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_oauth_redirect_expands_per_server(tmp_path: Path) -> None:
|
|
87
|
+
config = _load(
|
|
88
|
+
tmp_path,
|
|
89
|
+
{
|
|
90
|
+
"oauth": {"public_url": "auto"},
|
|
91
|
+
"servers": {
|
|
92
|
+
"gws": {
|
|
93
|
+
"command": "gws-mcp",
|
|
94
|
+
"env": {"REDIRECT_URI": "{oauth_redirect}"},
|
|
95
|
+
"args": ["--redirect", "{oauth_redirect}"],
|
|
96
|
+
},
|
|
97
|
+
"other": {"url": "http://127.0.0.1:1/mcp?cb={oauth_redirect}"},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
)
|
|
101
|
+
gws = f"http://{NAME}:9741/oauth/callback/gws"
|
|
102
|
+
assert config.servers["gws"].env == {"REDIRECT_URI": gws}
|
|
103
|
+
assert config.servers["gws"].args == ["--redirect", gws]
|
|
104
|
+
assert config.servers["other"].url == (
|
|
105
|
+
f"http://127.0.0.1:1/mcp?cb=http://{NAME}:9741/oauth/callback/other"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_oauth_redirect_in_a_backing_entry_names_its_one_user(tmp_path: Path) -> None:
|
|
110
|
+
config = _load(
|
|
111
|
+
tmp_path,
|
|
112
|
+
{
|
|
113
|
+
"oauth": {"public_url": "https://auth.example.com"},
|
|
114
|
+
"sharedServers": {
|
|
115
|
+
"gws-proc": {"command": "gws", "env": {"CB": "{oauth_redirect}"}},
|
|
116
|
+
"shared-twice": {"command": "x", "env": {"CB": "{oauth_redirect}"}},
|
|
117
|
+
},
|
|
118
|
+
"servers": {
|
|
119
|
+
"gws": {"url": "http://127.0.0.1:1/mcp", "sharedServer": "gws-proc"},
|
|
120
|
+
"a": {"url": "http://127.0.0.1:2/mcp", "sharedServer": "shared-twice"},
|
|
121
|
+
"b": {"url": "http://127.0.0.1:3/mcp", "sharedServer": "shared-twice"},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
)
|
|
125
|
+
assert config.shared_servers["gws-proc"].env == {
|
|
126
|
+
"CB": "https://auth.example.com/oauth/callback/gws"
|
|
127
|
+
}
|
|
128
|
+
assert config.shared_servers["shared-twice"].env == {"CB": "{oauth_redirect}"}
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_oauth_redirect_needs_a_public_url(
|
|
132
|
+
tmp_path: Path, caplog: pytest.LogCaptureFixture
|
|
133
|
+
) -> None:
|
|
134
|
+
with caplog.at_level(logging.WARNING, logger="mcp-combiner"):
|
|
135
|
+
config = _load(tmp_path, {"servers": {"s": {"command": "x", "args": ["{oauth_redirect}"]}}})
|
|
136
|
+
assert config.servers["s"].args == ["{oauth_redirect}"]
|
|
137
|
+
assert "needs oauth.public_url" in caplog.text
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_the_env_url_applies_without_an_oauth_block(
|
|
141
|
+
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
|
142
|
+
) -> None:
|
|
143
|
+
monkeypatch.setenv(PUBLIC_URL_ENV, "https://auth.example.com")
|
|
144
|
+
config = _load(tmp_path, {"servers": {"s": {"command": "x", "args": ["{oauth_redirect}"]}}})
|
|
145
|
+
assert config.oauth.public_url == "https://auth.example.com"
|
|
146
|
+
assert config.servers["s"].args == ["https://auth.example.com/oauth/callback/s"]
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mcp_combiner-0.20.0.dev4 → mcp_combiner-0.20.0.dev5}/tests/test_visibility_and_reset_e2e.py
RENAMED
|
File without changes
|