-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapabilities.py
More file actions
94 lines (74 loc) · 2.81 KB
/
Copy pathcapabilities.py
File metadata and controls
94 lines (74 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from __future__ import annotations
from dataclasses import asdict, dataclass, field, is_dataclass
from typing import Any
PROTOCOL_VERSION = "2025-11-25"
def dataclass_to_dict(value: Any) -> Any:
if is_dataclass(value):
return {key: dataclass_to_dict(item) for key, item in asdict(value).items() if item is not None}
if isinstance(value, dict):
return {key: dataclass_to_dict(item) for key, item in value.items() if item is not None}
if isinstance(value, list):
return [dataclass_to_dict(item) for item in value]
if isinstance(value, tuple):
return [dataclass_to_dict(item) for item in value]
return value
@dataclass
class AuthProfile:
issuer: str
authorization_url: str | None = None
token_url: str | None = None
scopes: list[str] = field(default_factory=list)
pkce_required: bool = True
resource_indicators: bool = True
step_up_scopes: bool = True
@dataclass
class AuthContext:
subject: str | None = None
scopes: list[str] = field(default_factory=list)
session_id: str | None = None
metadata: dict[str, Any] = field(default_factory=dict)
@dataclass
class Capabilities:
tools: dict[str, Any] | None = None
resources: dict[str, Any] | None = None
prompts: dict[str, Any] | None = None
completions: dict[str, Any] | None = None
logging: dict[str, Any] | None = None
roots: dict[str, Any] | None = None
sampling: dict[str, Any] | None = None
elicitation: dict[str, Any] | None = None
tasks: dict[str, Any] | None = None
auth: dict[str, Any] | None = None
experimental: dict[str, Any] = field(default_factory=dict)
def to_dict(self) -> dict[str, Any]:
return dataclass_to_dict(self)
@dataclass
class InitializeParams:
protocol_version: str = PROTOCOL_VERSION
client_info: dict[str, Any] = field(default_factory=dict)
capabilities: dict[str, Any] = field(default_factory=dict)
@dataclass
class InitializeResult:
protocol_version: str
server_info: dict[str, Any]
capabilities: dict[str, Any]
auth: dict[str, Any] | None = None
def to_dict(self) -> dict[str, Any]:
return dataclass_to_dict(self)
@dataclass
class ProgressToken:
token: str
total: float | None = None
def default_capabilities() -> Capabilities:
return Capabilities(
tools={"listChanged": True},
resources={"listChanged": True, "subscribe": True},
prompts={"listChanged": True},
completions={"argumentCompletion": True},
logging={"structured": True},
roots={"listChanged": True},
sampling={"createMessage": True, "toolsInSampling": True},
elicitation={"forms": True, "url": True, "basic": True},
tasks={"experimental": True},
auth={"oauth2_1": True, "pkce": True, "resourceIndicators": True, "stepUpScopes": True},
)