feat: add structured capability types
Replace generic capability dictionaries with structured types for prompts, resources, tools, and roots. This improves type safety and makes capability features like listChanged and subscribe more explicit in the protocol.
This commit is contained in:
parent
14addfb872
commit
5497da0afd
2 changed files with 151 additions and 30 deletions
|
|
@ -26,6 +26,7 @@ from mcp_python.types import (
|
|||
PromptReference,
|
||||
ReadResourceResult,
|
||||
ResourceReference,
|
||||
RootsCapability,
|
||||
ServerNotification,
|
||||
ServerRequest,
|
||||
)
|
||||
|
|
@ -69,12 +70,12 @@ class ClientSession(
|
|||
capabilities=ClientCapabilities(
|
||||
sampling=None,
|
||||
experimental=None,
|
||||
roots={
|
||||
roots=RootsCapability(
|
||||
# TODO: Should this be based on whether we
|
||||
# _will_ send notifications, or only whether
|
||||
# they're supported?
|
||||
"listChanged": True
|
||||
},
|
||||
listChanged=True
|
||||
),
|
||||
),
|
||||
clientInfo=Implementation(name="mcp_python", version="0.1.0"),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -12,9 +12,19 @@ from mcp_python.types import JSONRPCMessage
|
|||
|
||||
# Environment variables to inherit by default
|
||||
DEFAULT_INHERITED_ENV_VARS = (
|
||||
["APPDATA", "HOMEDRIVE", "HOMEPATH", "LOCALAPPDATA", "PATH",
|
||||
"PROCESSOR_ARCHITECTURE", "SYSTEMDRIVE", "SYSTEMROOT", "TEMP",
|
||||
"USERNAME", "USERPROFILE"]
|
||||
[
|
||||
"APPDATA",
|
||||
"HOMEDRIVE",
|
||||
"HOMEPATH",
|
||||
"LOCALAPPDATA",
|
||||
"PATH",
|
||||
"PROCESSOR_ARCHITECTURE",
|
||||
"SYSTEMDRIVE",
|
||||
"SYSTEMROOT",
|
||||
"TEMP",
|
||||
"USERNAME",
|
||||
"USERPROFILE",
|
||||
]
|
||||
if sys.platform == "win32"
|
||||
else ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"]
|
||||
)
|
||||
|
|
@ -74,7 +84,7 @@ async def stdio_client(server: StdioServerParameters):
|
|||
process = await anyio.open_process(
|
||||
[server.command, *server.args],
|
||||
env=server.env if server.env is not None else get_default_environment(),
|
||||
stderr=sys.stderr
|
||||
stderr=sys.stderr,
|
||||
)
|
||||
|
||||
async def stdout_reader():
|
||||
|
|
|
|||
Loading…
Reference in a new issue