transparent mode uses new, builtin technology
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Test package for local helper imports."""
|
||||
@@ -13,7 +13,11 @@ from wf_mcp import (
|
||||
load_broker_config,
|
||||
)
|
||||
|
||||
from test_wf_mcp_support import FailingDiscoveryAdapter, FakeAdapter, local_temp_root
|
||||
from tests.test_wf_mcp_support import (
|
||||
FailingDiscoveryAdapter,
|
||||
FakeAdapter,
|
||||
local_temp_root,
|
||||
)
|
||||
|
||||
|
||||
def test_load_broker_config_resolves_relative_store_root() -> None:
|
||||
|
||||
@@ -5,7 +5,7 @@ from pathlib import Path
|
||||
|
||||
from wf_mcp.cli import build_parser, main
|
||||
|
||||
from test_wf_mcp_support import local_temp_root
|
||||
from tests.test_wf_mcp_support import local_temp_root
|
||||
|
||||
|
||||
def _write_config(path: Path) -> None:
|
||||
@@ -34,6 +34,27 @@ def test_build_parser_accepts_serve_transport() -> None:
|
||||
|
||||
assert args.command == "serve"
|
||||
assert args.transport == "streamable_http"
|
||||
assert args.mode == "proxy"
|
||||
assert args.resources_as_tools is False
|
||||
assert args.prompts_as_tools is False
|
||||
|
||||
|
||||
def test_build_parser_accepts_proxy_compatibility_flags() -> None:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(
|
||||
[
|
||||
"--config",
|
||||
"wf_mcp.config.json",
|
||||
"serve",
|
||||
"--resources-as-tools",
|
||||
"--prompts-as-tools",
|
||||
]
|
||||
)
|
||||
|
||||
assert args.command == "serve"
|
||||
assert args.mode == "proxy"
|
||||
assert args.resources_as_tools is True
|
||||
assert args.prompts_as_tools is True
|
||||
|
||||
|
||||
def test_cli_connections_prints_configured_connections(capsys) -> None:
|
||||
|
||||
@@ -6,7 +6,7 @@ import pytest
|
||||
|
||||
from wf_mcp import ConnectionConfig, FileStore, McpSdkAdapter, WfMcpService
|
||||
|
||||
from test_wf_mcp_support import (
|
||||
from tests.test_wf_mcp_support import (
|
||||
everything_server_connection,
|
||||
fixture_server_path,
|
||||
local_temp_root,
|
||||
|
||||
@@ -13,7 +13,7 @@ from wf_mcp import (
|
||||
)
|
||||
from wf_mcp.error_info import error_payload
|
||||
|
||||
from test_wf_mcp_support import (
|
||||
from tests.test_wf_mcp_support import (
|
||||
FailingDiscoveryAdapter,
|
||||
FakeAdapter,
|
||||
echo_tool,
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from wf_mcp import AuthRecord, FileStore
|
||||
|
||||
from test_wf_mcp_support import local_temp_root
|
||||
from tests.test_wf_mcp_support import local_temp_root
|
||||
|
||||
|
||||
def test_file_store_round_trips_auth() -> None:
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import sys
|
||||
|
||||
from wf_mcp import BrokerConfig, ConnectionConfig, create_transparent_proxy_client
|
||||
|
||||
from tests.test_wf_mcp_support import fixture_server_path, local_temp_root
|
||||
|
||||
|
||||
def test_transparent_proxy_lists_and_calls_upstream_tools() -> None:
|
||||
config = BrokerConfig(
|
||||
store_root=local_temp_root() / "transparent_proxy_store",
|
||||
connections=[
|
||||
ConnectionConfig(
|
||||
id="fixture.personal",
|
||||
server="fixture",
|
||||
account="personal",
|
||||
metadata={
|
||||
"transport": "stdio",
|
||||
"command": sys.executable,
|
||||
"args": [fixture_server_path()],
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
async def run_proxy() -> None:
|
||||
client = create_transparent_proxy_client(config)
|
||||
async with client:
|
||||
tools = await client.list_tools()
|
||||
names = [tool.name for tool in tools]
|
||||
assert "fixture.personal_echo_tool" in names
|
||||
|
||||
result = await client.call_tool(
|
||||
"fixture.personal_echo_tool",
|
||||
{"text": "hello"},
|
||||
)
|
||||
assert result.structured_content == {"echoed": "hello"}
|
||||
|
||||
asyncio.run(run_proxy())
|
||||
|
||||
|
||||
def test_transparent_proxy_can_expose_resources_and_prompts_as_tools() -> None:
|
||||
config = BrokerConfig(
|
||||
store_root=local_temp_root() / "transparent_proxy_helper_store",
|
||||
connections=[
|
||||
ConnectionConfig(
|
||||
id="fixture.personal",
|
||||
server="fixture",
|
||||
account="personal",
|
||||
metadata={
|
||||
"transport": "stdio",
|
||||
"command": sys.executable,
|
||||
"args": [fixture_server_path()],
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
async def run_proxy() -> None:
|
||||
client = create_transparent_proxy_client(
|
||||
config,
|
||||
resources_as_tools=True,
|
||||
prompts_as_tools=True,
|
||||
)
|
||||
async with client:
|
||||
tools = await client.list_tools()
|
||||
names = [tool.name for tool in tools]
|
||||
assert "list_resources" in names
|
||||
assert "read_resource" in names
|
||||
assert "list_prompts" in names
|
||||
assert "get_prompt" in names
|
||||
|
||||
asyncio.run(run_proxy())
|
||||
Reference in New Issue
Block a user