Let Client take StdioServerParameters directly (#3321)
This commit is contained in:
parent
fb443cc4b2
commit
e473cca6a1
1 changed files with 51 additions and 27 deletions
|
|
@ -20,7 +20,7 @@ from urllib.parse import urlsplit
|
|||
import anyio
|
||||
import httpx2
|
||||
|
||||
from mcp import StdioServerParameters, stdio_client
|
||||
from mcp import StdioServerParameters
|
||||
from mcp.client import Transport
|
||||
from mcp.client.streamable_http import streamable_http_client
|
||||
from mcp.server import Server
|
||||
|
|
@ -32,8 +32,8 @@ if sys.version_info >= (3, 11):
|
|||
else:
|
||||
import tomli as tomllib
|
||||
|
||||
Target: TypeAlias = "Server[Any] | MCPServer | Transport | str"
|
||||
"""Anything ``Client(...)`` accepts: an in-process server, a ``Transport``, or an HTTP URL."""
|
||||
Target: TypeAlias = "Server[Any] | MCPServer | Transport | StdioServerParameters | str"
|
||||
"""Anything ``Client(...)`` accepts: an HTTP URL, stdio launch parameters, a ``Transport``, or an in-process server."""
|
||||
|
||||
TargetFactory = Callable[[], Target]
|
||||
"""Yields a FRESH target against the same server/app on every call (``multi_connection`` stories)."""
|
||||
|
|
@ -63,7 +63,7 @@ def target_from_args(file: str, url: str | None) -> TargetFactory:
|
|||
# stdio is legacy-only until serve_stdio() lands; the modern arm is --http only for now.
|
||||
server = Path(file).parent / f"{argv_after('--server', default='server')}.py"
|
||||
params = StdioServerParameters(command=sys.executable, args=[str(server)])
|
||||
return lambda: stdio_client(params) # becomes Client(params) once that overload lands
|
||||
return lambda: params
|
||||
|
||||
|
||||
def _explicit_http_url() -> str | None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue