acp-sdk 0.0.6__py3-none-any.whl → 1.0.0rc1__py3-none-any.whl

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.
Files changed (69) hide show
  1. acp_sdk/client/__init__.py +1 -0
  2. acp_sdk/client/client.py +135 -0
  3. acp_sdk/models.py +219 -0
  4. acp_sdk/server/__init__.py +2 -0
  5. acp_sdk/server/agent.py +32 -0
  6. acp_sdk/server/bundle.py +133 -0
  7. acp_sdk/server/context.py +6 -0
  8. acp_sdk/server/server.py +137 -0
  9. acp_sdk/server/telemetry.py +45 -0
  10. acp_sdk/server/utils.py +12 -0
  11. acp_sdk-1.0.0rc1.dist-info/METADATA +53 -0
  12. acp_sdk-1.0.0rc1.dist-info/RECORD +15 -0
  13. acp/__init__.py +0 -138
  14. acp/cli/__init__.py +0 -6
  15. acp/cli/claude.py +0 -139
  16. acp/cli/cli.py +0 -471
  17. acp/client/__main__.py +0 -79
  18. acp/client/session.py +0 -372
  19. acp/client/sse.py +0 -145
  20. acp/client/stdio.py +0 -153
  21. acp/server/__init__.py +0 -3
  22. acp/server/__main__.py +0 -50
  23. acp/server/highlevel/__init__.py +0 -9
  24. acp/server/highlevel/agents/__init__.py +0 -5
  25. acp/server/highlevel/agents/agent_manager.py +0 -110
  26. acp/server/highlevel/agents/base.py +0 -20
  27. acp/server/highlevel/agents/templates.py +0 -21
  28. acp/server/highlevel/context.py +0 -185
  29. acp/server/highlevel/exceptions.py +0 -25
  30. acp/server/highlevel/prompts/__init__.py +0 -4
  31. acp/server/highlevel/prompts/base.py +0 -167
  32. acp/server/highlevel/prompts/manager.py +0 -50
  33. acp/server/highlevel/prompts/prompt_manager.py +0 -33
  34. acp/server/highlevel/resources/__init__.py +0 -23
  35. acp/server/highlevel/resources/base.py +0 -48
  36. acp/server/highlevel/resources/resource_manager.py +0 -94
  37. acp/server/highlevel/resources/templates.py +0 -80
  38. acp/server/highlevel/resources/types.py +0 -185
  39. acp/server/highlevel/server.py +0 -705
  40. acp/server/highlevel/tools/__init__.py +0 -4
  41. acp/server/highlevel/tools/base.py +0 -83
  42. acp/server/highlevel/tools/tool_manager.py +0 -53
  43. acp/server/highlevel/utilities/__init__.py +0 -1
  44. acp/server/highlevel/utilities/func_metadata.py +0 -210
  45. acp/server/highlevel/utilities/logging.py +0 -43
  46. acp/server/highlevel/utilities/types.py +0 -54
  47. acp/server/lowlevel/__init__.py +0 -3
  48. acp/server/lowlevel/helper_types.py +0 -9
  49. acp/server/lowlevel/server.py +0 -643
  50. acp/server/models.py +0 -17
  51. acp/server/session.py +0 -315
  52. acp/server/sse.py +0 -175
  53. acp/server/stdio.py +0 -83
  54. acp/server/websocket.py +0 -61
  55. acp/shared/__init__.py +0 -0
  56. acp/shared/context.py +0 -14
  57. acp/shared/exceptions.py +0 -14
  58. acp/shared/memory.py +0 -87
  59. acp/shared/progress.py +0 -40
  60. acp/shared/session.py +0 -413
  61. acp/shared/version.py +0 -3
  62. acp/types.py +0 -1258
  63. acp_sdk-0.0.6.dist-info/METADATA +0 -46
  64. acp_sdk-0.0.6.dist-info/RECORD +0 -57
  65. acp_sdk-0.0.6.dist-info/entry_points.txt +0 -2
  66. acp_sdk-0.0.6.dist-info/licenses/LICENSE +0 -22
  67. {acp/client → acp_sdk}/__init__.py +0 -0
  68. {acp → acp_sdk}/py.typed +0 -0
  69. {acp_sdk-0.0.6.dist-info → acp_sdk-1.0.0rc1.dist-info}/WHEEL +0 -0
acp/types.py DELETED
@@ -1,1258 +0,0 @@
1
- from typing import Annotated, Any, Callable, Generic, Literal, TypeAlias, TypeVar
2
-
3
- from pydantic import BaseModel, ConfigDict, Field, FileUrl, RootModel
4
- from pydantic.networks import AnyUrl
5
-
6
- """
7
- Model Context Protocol bindings for Python
8
-
9
- These bindings were generated from https://github.com/modelcontextprotocol/specification,
10
- using Claude, with a prompt something like the following:
11
-
12
- Generate idiomatic Python bindings for this schema for MCP, or the "Model Context
13
- Protocol." The schema is defined in TypeScript, but there's also a JSON Schema version
14
- for reference.
15
-
16
- * For the bindings, let's use Pydantic V2 models.
17
- * Each model should allow extra fields everywhere, by specifying `model_config =
18
- ConfigDict(extra='allow')`. Do this in every case, instead of a custom base class.
19
- * Union types should be represented with a Pydantic `RootModel`.
20
- * Define additional model classes instead of using dictionaries. Do this even if they're
21
- not separate types in the schema.
22
- """
23
-
24
- LATEST_PROTOCOL_VERSION = "2024-11-05"
25
-
26
- ProgressToken = str | int
27
- Cursor = str
28
- Role = Literal["user", "assistant"]
29
- RequestId = str | int
30
- AnyFunction: TypeAlias = Callable[..., Any]
31
-
32
-
33
- class RequestParams(BaseModel):
34
- class Meta(BaseModel):
35
- progressToken: ProgressToken | None = None
36
- """
37
- If specified, the caller is requesting out-of-band progress notifications for
38
- this request (as represented by notifications/progress). The value of this
39
- parameter is an opaque token that will be attached to any subsequent
40
- notifications. The receiver is not obligated to provide these notifications.
41
- """
42
-
43
- model_config = ConfigDict(extra="allow")
44
-
45
- meta: Meta | None = Field(alias="_meta", default=None)
46
-
47
-
48
- class NotificationParams(BaseModel):
49
- class Meta(BaseModel):
50
- model_config = ConfigDict(extra="allow")
51
-
52
- meta: Meta | None = Field(alias="_meta", default=None)
53
- """
54
- This parameter name is reserved by MCP to allow clients and servers to attach
55
- additional metadata to their notifications.
56
- """
57
-
58
-
59
- RequestParamsT = TypeVar("RequestParamsT", bound=RequestParams)
60
- NotificationParamsT = TypeVar("NotificationParamsT", bound=NotificationParams)
61
- MethodT = TypeVar("MethodT", bound=str)
62
-
63
-
64
- class Request(BaseModel, Generic[RequestParamsT, MethodT]):
65
- """Base class for JSON-RPC requests."""
66
-
67
- method: MethodT
68
- params: RequestParamsT
69
- model_config = ConfigDict(extra="allow")
70
-
71
-
72
- class PaginatedRequest(Request[RequestParamsT, MethodT]):
73
- cursor: Cursor | None = None
74
- """
75
- An opaque token representing the current pagination position.
76
- If provided, the server should return results starting after this cursor.
77
- """
78
-
79
-
80
- class Notification(BaseModel, Generic[NotificationParamsT, MethodT]):
81
- """Base class for JSON-RPC notifications."""
82
-
83
- method: MethodT
84
- model_config = ConfigDict(extra="allow")
85
-
86
-
87
- class Result(BaseModel):
88
- """Base class for JSON-RPC results."""
89
-
90
- model_config = ConfigDict(extra="allow")
91
-
92
- meta: dict[str, Any] | None = Field(alias="_meta", default=None)
93
- """
94
- This result property is reserved by the protocol to allow clients and servers to
95
- attach additional metadata to their responses.
96
- """
97
-
98
-
99
- class PaginatedResult(Result):
100
- nextCursor: Cursor | None = None
101
- """
102
- An opaque token representing the pagination position after the last returned result.
103
- If present, there may be more results available.
104
- """
105
-
106
-
107
- class JSONRPCRequest(Request):
108
- """A request that expects a response."""
109
-
110
- jsonrpc: Literal["2.0"]
111
- id: RequestId
112
- params: dict[str, Any] | None = None
113
-
114
-
115
- class JSONRPCNotification(Notification):
116
- """A notification which does not expect a response."""
117
-
118
- jsonrpc: Literal["2.0"]
119
- params: dict[str, Any] | None = None
120
-
121
-
122
- class JSONRPCResponse(BaseModel):
123
- """A successful (non-error) response to a request."""
124
-
125
- jsonrpc: Literal["2.0"]
126
- id: RequestId
127
- result: dict[str, Any]
128
- model_config = ConfigDict(extra="allow")
129
-
130
-
131
- # Standard JSON-RPC error codes
132
- PARSE_ERROR = -32700
133
- INVALID_REQUEST = -32600
134
- METHOD_NOT_FOUND = -32601
135
- INVALID_PARAMS = -32602
136
- INTERNAL_ERROR = -32603
137
-
138
-
139
- class ErrorData(BaseModel):
140
- """Error information for JSON-RPC error responses."""
141
-
142
- code: int
143
- """The error type that occurred."""
144
-
145
- message: str
146
- """
147
- A short description of the error. The message SHOULD be limited to a concise single
148
- sentence.
149
- """
150
-
151
- data: Any | None = None
152
- """
153
- Additional information about the error. The value of this member is defined by the
154
- sender (e.g. detailed error information, nested errors etc.).
155
- """
156
-
157
- model_config = ConfigDict(extra="allow")
158
-
159
-
160
- class JSONRPCError(BaseModel):
161
- """A response to a request that indicates an error occurred."""
162
-
163
- jsonrpc: Literal["2.0"]
164
- id: str | int
165
- error: ErrorData
166
- model_config = ConfigDict(extra="allow")
167
-
168
-
169
- class JSONRPCMessage(
170
- RootModel[JSONRPCRequest | JSONRPCNotification | JSONRPCResponse | JSONRPCError]
171
- ):
172
- pass
173
-
174
-
175
- class EmptyResult(Result):
176
- """A response that indicates success but carries no data."""
177
-
178
-
179
- class Implementation(BaseModel):
180
- """Describes the name and version of an MCP implementation."""
181
-
182
- name: str
183
- version: str
184
- model_config = ConfigDict(extra="allow")
185
-
186
-
187
- class RootsCapability(BaseModel):
188
- """Capability for root operations."""
189
-
190
- listChanged: bool | None = None
191
- """Whether the client supports notifications for changes to the roots list."""
192
- model_config = ConfigDict(extra="allow")
193
-
194
-
195
- class SamplingCapability(BaseModel):
196
- """Capability for logging operations."""
197
-
198
- model_config = ConfigDict(extra="allow")
199
-
200
-
201
- class ClientCapabilities(BaseModel):
202
- """Capabilities a client may support."""
203
-
204
- experimental: dict[str, dict[str, Any]] | None = None
205
- """Experimental, non-standard capabilities that the client supports."""
206
- sampling: SamplingCapability | None = None
207
- """Present if the client supports sampling from an LLM."""
208
- roots: RootsCapability | None = None
209
- """Present if the client supports listing roots."""
210
- model_config = ConfigDict(extra="allow")
211
-
212
-
213
- class PromptsCapability(BaseModel):
214
- """Capability for prompts operations."""
215
-
216
- listChanged: bool | None = None
217
- """Whether this server supports notifications for changes to the prompt list."""
218
- model_config = ConfigDict(extra="allow")
219
-
220
-
221
- class ResourcesCapability(BaseModel):
222
- """Capability for resources operations."""
223
-
224
- subscribe: bool | None = None
225
- """Whether this server supports subscribing to resource updates."""
226
- listChanged: bool | None = None
227
- """Whether this server supports notifications for changes to the resource list."""
228
- model_config = ConfigDict(extra="allow")
229
-
230
-
231
- class ToolsCapability(BaseModel):
232
- """Capability for tools operations."""
233
-
234
- listChanged: bool | None = None
235
- """Whether this server supports notifications for changes to the tool list."""
236
- model_config = ConfigDict(extra="allow")
237
-
238
-
239
- class AgentsCapability(BaseModel):
240
- """Capability for agents operations."""
241
-
242
- """Whether this server supports agent templates."""
243
- templates: bool | None = None
244
- """Whether this server supports notifications for changes to the agent list."""
245
- listChanged: bool | None = None
246
-
247
- model_config = ConfigDict(extra="allow")
248
-
249
-
250
- class LoggingCapability(BaseModel):
251
- """Capability for logging operations."""
252
-
253
- model_config = ConfigDict(extra="allow")
254
-
255
-
256
- class ServerCapabilities(BaseModel):
257
- """Capabilities that a server may support."""
258
-
259
- experimental: dict[str, dict[str, Any]] | None = None
260
- """Experimental, non-standard capabilities that the server supports."""
261
- logging: LoggingCapability | None = None
262
- """Present if the server supports sending log messages to the client."""
263
- prompts: PromptsCapability | None = None
264
- """Present if the server offers any prompt templates."""
265
- resources: ResourcesCapability | None = None
266
- """Present if the server offers any resources to read."""
267
- tools: ToolsCapability | None = None
268
- """Present if the server offers any tools to call."""
269
- agents: AgentsCapability | None = None
270
- """Present if the server offers any agents to run."""
271
- model_config = ConfigDict(extra="allow")
272
-
273
-
274
- class InitializeRequestParams(RequestParams):
275
- """Parameters for the initialize request."""
276
-
277
- protocolVersion: str | int
278
- """The latest version of the Model Context Protocol that the client supports."""
279
- capabilities: ClientCapabilities
280
- clientInfo: Implementation
281
- model_config = ConfigDict(extra="allow")
282
-
283
-
284
- class InitializeRequest(Request):
285
- """
286
- This request is sent from the client to the server when it first connects, asking it
287
- to begin initialization.
288
- """
289
-
290
- method: Literal["initialize"]
291
- params: InitializeRequestParams
292
-
293
-
294
- class InitializeResult(Result):
295
- """After receiving an initialize request from the client, the server sends this."""
296
-
297
- protocolVersion: str | int
298
- """The version of the Model Context Protocol that the server wants to use."""
299
- capabilities: ServerCapabilities
300
- serverInfo: Implementation
301
- instructions: str | None = None
302
- """Instructions describing how to use the server and its features."""
303
-
304
-
305
- class InitializedNotification(Notification):
306
- """
307
- This notification is sent from the client to the server after initialization has
308
- finished.
309
- """
310
-
311
- method: Literal["notifications/initialized"]
312
- params: NotificationParams | None = None
313
-
314
-
315
- class PingRequest(Request):
316
- """
317
- A ping, issued by either the server or the client, to check that the other party is
318
- still alive.
319
- """
320
-
321
- method: Literal["ping"]
322
- params: RequestParams | None = None
323
-
324
-
325
- class ProgressNotificationParams(NotificationParams):
326
- """Parameters for progress notifications."""
327
-
328
- progressToken: ProgressToken
329
- """
330
- The progress token which was given in the initial request, used to associate this
331
- notification with the request that is proceeding.
332
- """
333
- progress: float
334
- """
335
- The progress thus far. This should increase every time progress is made, even if the
336
- total is unknown.
337
- """
338
- total: float | None = None
339
- """Total number of items to process (or total progress required), if known."""
340
- model_config = ConfigDict(extra="allow")
341
-
342
-
343
- class ProgressNotification(Notification):
344
- """
345
- An out-of-band notification used to inform the receiver of a progress update for a
346
- long-running request.
347
- """
348
-
349
- method: Literal["notifications/progress"]
350
- params: ProgressNotificationParams
351
-
352
-
353
- class ListResourcesRequest(PaginatedRequest):
354
- """Sent from the client to request a list of resources the server has."""
355
-
356
- method: Literal["resources/list"]
357
- params: RequestParams | None = None
358
-
359
-
360
- class Annotations(BaseModel):
361
- audience: list[Role] | None = None
362
- priority: Annotated[float, Field(ge=0.0, le=1.0)] | None = None
363
- model_config = ConfigDict(extra="allow")
364
-
365
-
366
- class Resource(BaseModel):
367
- """A known resource that the server is capable of reading."""
368
-
369
- uri: AnyUrl
370
- """The URI of this resource."""
371
- name: str
372
- """A human-readable name for this resource."""
373
- description: str | None = None
374
- """A description of what this resource represents."""
375
- mimeType: str | None = None
376
- """The MIME type of this resource, if known."""
377
- size: int | None = None
378
- """
379
- The size of the raw resource content, in bytes (i.e., before base64 encoding
380
- or any tokenization), if known.
381
-
382
- This can be used by Hosts to display file sizes and estimate context window usage.
383
- """
384
- annotations: Annotations | None = None
385
- model_config = ConfigDict(extra="allow")
386
-
387
-
388
- class ResourceTemplate(BaseModel):
389
- """A template description for resources available on the server."""
390
-
391
- uriTemplate: str
392
- """
393
- A URI template (according to RFC 6570) that can be used to construct resource
394
- URIs.
395
- """
396
- name: str
397
- """A human-readable name for the type of resource this template refers to."""
398
- description: str | None = None
399
- """A human-readable description of what this template is for."""
400
- mimeType: str | None = None
401
- """
402
- The MIME type for all resources that match this template. This should only be
403
- included if all resources matching this template have the same type.
404
- """
405
- annotations: Annotations | None = None
406
- model_config = ConfigDict(extra="allow")
407
-
408
-
409
- class ListResourcesResult(PaginatedResult):
410
- """The server's response to a resources/list request from the client."""
411
-
412
- resources: list[Resource]
413
-
414
-
415
- class ListResourceTemplatesRequest(PaginatedRequest):
416
- """Sent from the client to request a list of resource templates the server has."""
417
-
418
- method: Literal["resources/templates/list"]
419
- params: RequestParams | None = None
420
-
421
-
422
- class ListResourceTemplatesResult(PaginatedResult):
423
- """The server's response to a resources/templates/list request from the client."""
424
-
425
- resourceTemplates: list[ResourceTemplate]
426
-
427
-
428
- class ReadResourceRequestParams(RequestParams):
429
- """Parameters for reading a resource."""
430
-
431
- uri: AnyUrl
432
- """
433
- The URI of the resource to read. The URI can use any protocol; it is up to the
434
- server how to interpret it.
435
- """
436
- model_config = ConfigDict(extra="allow")
437
-
438
-
439
- class ReadResourceRequest(Request):
440
- """Sent from the client to the server, to read a specific resource URI."""
441
-
442
- method: Literal["resources/read"]
443
- params: ReadResourceRequestParams
444
-
445
-
446
- class ResourceContents(BaseModel):
447
- """The contents of a specific resource or sub-resource."""
448
-
449
- uri: AnyUrl
450
- """The URI of this resource."""
451
- mimeType: str | None = None
452
- """The MIME type of this resource, if known."""
453
- model_config = ConfigDict(extra="allow")
454
-
455
-
456
- class TextResourceContents(ResourceContents):
457
- """Text contents of a resource."""
458
-
459
- text: str
460
- """
461
- The text of the item. This must only be set if the item can actually be represented
462
- as text (not binary data).
463
- """
464
-
465
-
466
- class BlobResourceContents(ResourceContents):
467
- """Binary contents of a resource."""
468
-
469
- blob: str
470
- """A base64-encoded string representing the binary data of the item."""
471
-
472
-
473
- class ReadResourceResult(Result):
474
- """The server's response to a resources/read request from the client."""
475
-
476
- contents: list[TextResourceContents | BlobResourceContents]
477
-
478
-
479
- class ResourceListChangedNotification(Notification):
480
- """
481
- An optional notification from the server to the client, informing it that the list
482
- of resources it can read from has changed.
483
- """
484
-
485
- method: Literal["notifications/resources/list_changed"]
486
- params: NotificationParams | None = None
487
-
488
-
489
- class SubscribeRequestParams(RequestParams):
490
- """Parameters for subscribing to a resource."""
491
-
492
- uri: AnyUrl
493
- """
494
- The URI of the resource to subscribe to. The URI can use any protocol; it is up to
495
- the server how to interpret it.
496
- """
497
- model_config = ConfigDict(extra="allow")
498
-
499
-
500
- class SubscribeRequest(Request):
501
- """
502
- Sent from the client to request resources/updated notifications from the server
503
- whenever a particular resource changes.
504
- """
505
-
506
- method: Literal["resources/subscribe"]
507
- params: SubscribeRequestParams
508
-
509
-
510
- class UnsubscribeRequestParams(RequestParams):
511
- """Parameters for unsubscribing from a resource."""
512
-
513
- uri: AnyUrl
514
- """The URI of the resource to unsubscribe from."""
515
- model_config = ConfigDict(extra="allow")
516
-
517
-
518
- class UnsubscribeRequest(Request):
519
- """
520
- Sent from the client to request cancellation of resources/updated notifications from
521
- the server.
522
- """
523
-
524
- method: Literal["resources/unsubscribe"]
525
- params: UnsubscribeRequestParams
526
-
527
-
528
- class ResourceUpdatedNotificationParams(NotificationParams):
529
- """Parameters for resource update notifications."""
530
-
531
- uri: AnyUrl
532
- """
533
- The URI of the resource that has been updated. This might be a sub-resource of the
534
- one that the client actually subscribed to.
535
- """
536
- model_config = ConfigDict(extra="allow")
537
-
538
-
539
- class ResourceUpdatedNotification(Notification):
540
- """
541
- A notification from the server to the client, informing it that a resource has
542
- changed and may need to be read again.
543
- """
544
-
545
- method: Literal["notifications/resources/updated"]
546
- params: ResourceUpdatedNotificationParams
547
-
548
-
549
- class ListPromptsRequest(PaginatedRequest):
550
- """Sent from the client to request a list of prompts and prompt templates."""
551
-
552
- method: Literal["prompts/list"]
553
- params: RequestParams | None = None
554
-
555
-
556
- class PromptArgument(BaseModel):
557
- """An argument for a prompt template."""
558
-
559
- name: str
560
- """The name of the argument."""
561
- description: str | None = None
562
- """A human-readable description of the argument."""
563
- required: bool | None = None
564
- """Whether this argument must be provided."""
565
- model_config = ConfigDict(extra="allow")
566
-
567
-
568
- class Prompt(BaseModel):
569
- """A prompt or prompt template that the server offers."""
570
-
571
- name: str
572
- """The name of the prompt or prompt template."""
573
- description: str | None = None
574
- """An optional description of what this prompt provides."""
575
- arguments: list[PromptArgument] | None = None
576
- """A list of arguments to use for templating the prompt."""
577
- model_config = ConfigDict(extra="allow")
578
-
579
-
580
- class ListPromptsResult(PaginatedResult):
581
- """The server's response to a prompts/list request from the client."""
582
-
583
- prompts: list[Prompt]
584
-
585
-
586
- class GetPromptRequestParams(RequestParams):
587
- """Parameters for getting a prompt."""
588
-
589
- name: str
590
- """The name of the prompt or prompt template."""
591
- arguments: dict[str, str] | None = None
592
- """Arguments to use for templating the prompt."""
593
- model_config = ConfigDict(extra="allow")
594
-
595
-
596
- class GetPromptRequest(Request):
597
- """Used by the client to get a prompt provided by the server."""
598
-
599
- method: Literal["prompts/get"]
600
- params: GetPromptRequestParams
601
-
602
-
603
- class TextContent(BaseModel):
604
- """Text content for a message."""
605
-
606
- type: Literal["text"]
607
- text: str
608
- """The text content of the message."""
609
- annotations: Annotations | None = None
610
- model_config = ConfigDict(extra="allow")
611
-
612
-
613
- class ImageContent(BaseModel):
614
- """Image content for a message."""
615
-
616
- type: Literal["image"]
617
- data: str
618
- """The base64-encoded image data."""
619
- mimeType: str
620
- """
621
- The MIME type of the image. Different providers may support different
622
- image types.
623
- """
624
- annotations: Annotations | None = None
625
- model_config = ConfigDict(extra="allow")
626
-
627
-
628
- class SamplingMessage(BaseModel):
629
- """Describes a message issued to or received from an LLM API."""
630
-
631
- role: Role
632
- content: TextContent | ImageContent
633
- model_config = ConfigDict(extra="allow")
634
-
635
-
636
- class EmbeddedResource(BaseModel):
637
- """
638
- The contents of a resource, embedded into a prompt or tool call result.
639
-
640
- It is up to the client how best to render embedded resources for the benefit
641
- of the LLM and/or the user.
642
- """
643
-
644
- type: Literal["resource"]
645
- resource: TextResourceContents | BlobResourceContents
646
- annotations: Annotations | None = None
647
- model_config = ConfigDict(extra="allow")
648
-
649
-
650
- class PromptMessage(BaseModel):
651
- """Describes a message returned as part of a prompt."""
652
-
653
- role: Role
654
- content: TextContent | ImageContent | EmbeddedResource
655
- model_config = ConfigDict(extra="allow")
656
-
657
-
658
- class GetPromptResult(Result):
659
- """The server's response to a prompts/get request from the client."""
660
-
661
- description: str | None = None
662
- """An optional description for the prompt."""
663
- messages: list[PromptMessage]
664
-
665
-
666
- class PromptListChangedNotification(Notification):
667
- """
668
- An optional notification from the server to the client, informing it that the list
669
- of prompts it offers has changed.
670
- """
671
-
672
- method: Literal["notifications/prompts/list_changed"]
673
- params: NotificationParams | None = None
674
-
675
-
676
- class ListToolsRequest(PaginatedRequest):
677
- """Sent from the client to request a list of tools the server has."""
678
-
679
- method: Literal["tools/list"]
680
- params: RequestParams | None = None
681
-
682
-
683
- class Tool(BaseModel):
684
- """Definition for a tool the client can call."""
685
-
686
- name: str
687
- """The name of the tool."""
688
- description: str | None = None
689
- """A human-readable description of the tool."""
690
- inputSchema: dict[str, Any]
691
- """A JSON Schema object defining the expected parameters for the tool."""
692
- model_config = ConfigDict(extra="allow")
693
-
694
-
695
- class ListToolsResult(PaginatedResult):
696
- """The server's response to a tools/list request from the client."""
697
-
698
- tools: list[Tool]
699
-
700
-
701
- class CallToolRequestParams(RequestParams):
702
- """Parameters for calling a tool."""
703
-
704
- name: str
705
- arguments: dict[str, Any] | None = None
706
- model_config = ConfigDict(extra="allow")
707
-
708
-
709
- class CallToolRequest(Request):
710
- """Used by the client to invoke a tool provided by the server."""
711
-
712
- method: Literal["tools/call"]
713
- params: CallToolRequestParams
714
-
715
-
716
- class CallToolResult(Result):
717
- """The server's response to a tool call."""
718
-
719
- content: list[TextContent | ImageContent | EmbeddedResource]
720
- isError: bool = False
721
-
722
-
723
- class ToolListChangedNotification(Notification):
724
- """
725
- An optional notification from the server to the client, informing it that the list
726
- of tools it offers has changed.
727
- """
728
-
729
- method: Literal["notifications/tools/list_changed"]
730
- params: NotificationParams | None = None
731
-
732
-
733
- class AgentTemplate(BaseModel):
734
- """Definition for an agent template."""
735
-
736
- """The name of the agent template."""
737
- name: str
738
- """The description of the agent template."""
739
- description: str | None = None
740
- """A JSON Schema object defining the expected agent config."""
741
- configSchema: dict[str, Any]
742
- """A JSON Schema object defining the expected agent run input."""
743
- inputSchema: dict[str, Any]
744
- """A JSON Schema object defining the expected agent run output."""
745
- outputSchema: dict[str, Any]
746
-
747
- model_config = ConfigDict(extra="allow")
748
-
749
-
750
- class ListAgentTemplatesRequest(PaginatedRequest):
751
- """Sent from the client to request a list of agent templates the server has."""
752
-
753
- method: Literal["agents/templates/list"]
754
- params: RequestParams | None = None
755
-
756
-
757
- class ListAgentTemplatesResult(PaginatedResult):
758
- """The server's response to a agents/templates/list request from the client."""
759
-
760
- agentTemplates: list[AgentTemplate]
761
-
762
-
763
- class Agent(BaseModel):
764
- """Definition for an agent."""
765
-
766
- """The name of the agent."""
767
- name: str
768
- """The description of the agent."""
769
- description: str | None = None
770
- """A JSON Schema object defining the expected agent run input."""
771
- inputSchema: dict[str, Any]
772
- """A JSON Schema object defining the expected agent run output."""
773
- outputSchema: dict[str, Any]
774
-
775
- model_config = ConfigDict(extra="allow")
776
-
777
-
778
- class ListAgentsRequest(PaginatedRequest):
779
- """Sent from the client to request a list of agents the server has."""
780
-
781
- method: Literal["agents/list"]
782
- params: RequestParams | None = None
783
-
784
-
785
- class ListAgentsResult(PaginatedResult):
786
- """The server's response to a agents/list request from the client."""
787
-
788
- agents: list[Agent]
789
-
790
-
791
- class CreateAgentRequestParams(RequestParams):
792
- """Parameters for creating an agent."""
793
-
794
- """The name of the agent template."""
795
- templateName: str
796
- """The configuration of the agent."""
797
- config: dict[str, Any]
798
-
799
-
800
- class CreateAgentRequest(Request):
801
- """Used by the client to create an agent."""
802
-
803
- method: Literal["agents/create"]
804
- params: CreateAgentRequestParams
805
-
806
-
807
- class CreateAgentResult(Result):
808
- """The server's response to an agent creation."""
809
-
810
- agent: Agent
811
-
812
-
813
- class DestroyAgentRequestParams(RequestParams):
814
- """Parameters for destroying an agent."""
815
-
816
- """The name of the agent."""
817
- name: str
818
-
819
-
820
- class DestroyAgentRequest(Request):
821
- """Used by the client to destroy an agent."""
822
-
823
- method: Literal["agents/destroy"]
824
- params: DestroyAgentRequestParams
825
-
826
-
827
- class DestroyAgentResult(Result):
828
- """The server's response to an agent destruction."""
829
-
830
- pass
831
-
832
-
833
- class RunAgentRequestParams(RequestParams):
834
- """Parameters for running an agent."""
835
-
836
- """The name of the agent."""
837
- name: str
838
- """The input for the agent."""
839
- input: dict[str, Any]
840
-
841
-
842
- class RunAgentRequest(Request):
843
- """Used by the client to invoke an agent provided by the server."""
844
-
845
- method: Literal["agents/run"]
846
- params: RunAgentRequestParams
847
-
848
-
849
- class RunAgentResult(Result):
850
- """The server's response to an agent run."""
851
-
852
- """The output for the agent."""
853
- output: dict[str, Any]
854
-
855
-
856
- class AgentRunProgressNotificationParams(NotificationParams):
857
- """Parameters for agent run progress notifications."""
858
-
859
- """
860
- The progress token which was given in the initial request, used to associate this
861
- notification with the request that is proceeding.
862
- """
863
- progressToken: ProgressToken
864
-
865
- """The output delta for the agent."""
866
- delta: dict[str, Any]
867
-
868
-
869
- class AgentRunProgressNotification(Notification):
870
- method: Literal["notifications/agents/run/progress"]
871
- params: AgentRunProgressNotificationParams
872
-
873
-
874
- class AgentListChangedNotification(Notification):
875
- """
876
- An optional notification from the server to the client, informing it that the list
877
- of agents it offers has changed.
878
- """
879
-
880
- method: Literal["notifications/agents/list_changed"]
881
- params: NotificationParams | None = None
882
-
883
-
884
- LoggingLevel = Literal[
885
- "debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"
886
- ]
887
-
888
-
889
- class SetLevelRequestParams(RequestParams):
890
- """Parameters for setting the logging level."""
891
-
892
- level: LoggingLevel
893
- """The level of logging that the client wants to receive from the server."""
894
- model_config = ConfigDict(extra="allow")
895
-
896
-
897
- class SetLevelRequest(Request):
898
- """A request from the client to the server, to enable or adjust logging."""
899
-
900
- method: Literal["logging/setLevel"]
901
- params: SetLevelRequestParams
902
-
903
-
904
- class LoggingMessageNotificationParams(NotificationParams):
905
- """Parameters for logging message notifications."""
906
-
907
- level: LoggingLevel
908
- """The severity of this log message."""
909
- logger: str | None = None
910
- """An optional name of the logger issuing this message."""
911
- data: Any
912
- """
913
- The data to be logged, such as a string message or an object. Any JSON serializable
914
- type is allowed here.
915
- """
916
- model_config = ConfigDict(extra="allow")
917
-
918
-
919
- class LoggingMessageNotification(Notification):
920
- """Notification of a log message passed from server to client."""
921
-
922
- method: Literal["notifications/message"]
923
- params: LoggingMessageNotificationParams
924
-
925
-
926
- IncludeContext = Literal["none", "thisServer", "allServers"]
927
-
928
-
929
- class ModelHint(BaseModel):
930
- """Hints to use for model selection."""
931
-
932
- name: str | None = None
933
- """A hint for a model name."""
934
-
935
- model_config = ConfigDict(extra="allow")
936
-
937
-
938
- class ModelPreferences(BaseModel):
939
- """
940
- The server's preferences for model selection, requested of the client during
941
- sampling.
942
-
943
- Because LLMs can vary along multiple dimensions, choosing the "best" model is
944
- rarely straightforward. Different models excel in different areas—some are
945
- faster but less capable, others are more capable but more expensive, and so
946
- on. This interface allows servers to express their priorities across multiple
947
- dimensions to help clients make an appropriate selection for their use case.
948
-
949
- These preferences are always advisory. The client MAY ignore them. It is also
950
- up to the client to decide how to interpret these preferences and how to
951
- balance them against other considerations.
952
- """
953
-
954
- hints: list[ModelHint] | None = None
955
- """
956
- Optional hints to use for model selection.
957
-
958
- If multiple hints are specified, the client MUST evaluate them in order
959
- (such that the first match is taken).
960
-
961
- The client SHOULD prioritize these hints over the numeric priorities, but
962
- MAY still use the priorities to select from ambiguous matches.
963
- """
964
-
965
- costPriority: float | None = None
966
- """
967
- How much to prioritize cost when selecting a model. A value of 0 means cost
968
- is not important, while a value of 1 means cost is the most important
969
- factor.
970
- """
971
-
972
- speedPriority: float | None = None
973
- """
974
- How much to prioritize sampling speed (latency) when selecting a model. A
975
- value of 0 means speed is not important, while a value of 1 means speed is
976
- the most important factor.
977
- """
978
-
979
- intelligencePriority: float | None = None
980
- """
981
- How much to prioritize intelligence and capabilities when selecting a
982
- model. A value of 0 means intelligence is not important, while a value of 1
983
- means intelligence is the most important factor.
984
- """
985
-
986
- model_config = ConfigDict(extra="allow")
987
-
988
-
989
- class CreateMessageRequestParams(RequestParams):
990
- """Parameters for creating a message."""
991
-
992
- messages: list[SamplingMessage]
993
- modelPreferences: ModelPreferences | None = None
994
- """
995
- The server's preferences for which model to select. The client MAY ignore
996
- these preferences.
997
- """
998
- systemPrompt: str | None = None
999
- """An optional system prompt the server wants to use for sampling."""
1000
- includeContext: IncludeContext | None = None
1001
- """
1002
- A request to include context from one or more MCP servers (including the caller), to
1003
- be attached to the prompt.
1004
- """
1005
- temperature: float | None = None
1006
- maxTokens: int
1007
- """The maximum number of tokens to sample, as requested by the server."""
1008
- stopSequences: list[str] | None = None
1009
- metadata: dict[str, Any] | None = None
1010
- """Optional metadata to pass through to the LLM provider."""
1011
- model_config = ConfigDict(extra="allow")
1012
-
1013
-
1014
- class CreateMessageRequest(Request):
1015
- """A request from the server to sample an LLM via the client."""
1016
-
1017
- method: Literal["sampling/createMessage"]
1018
- params: CreateMessageRequestParams
1019
-
1020
-
1021
- StopReason = Literal["endTurn", "stopSequence", "maxTokens"] | str
1022
-
1023
-
1024
- class CreateMessageResult(Result):
1025
- """The client's response to a sampling/create_message request from the server."""
1026
-
1027
- role: Role
1028
- content: TextContent | ImageContent
1029
- model: str
1030
- """The name of the model that generated the message."""
1031
- stopReason: StopReason | None = None
1032
- """The reason why sampling stopped, if known."""
1033
-
1034
-
1035
- class ResourceReference(BaseModel):
1036
- """A reference to a resource or resource template definition."""
1037
-
1038
- type: Literal["ref/resource"]
1039
- uri: str
1040
- """The URI or URI template of the resource."""
1041
- model_config = ConfigDict(extra="allow")
1042
-
1043
-
1044
- class PromptReference(BaseModel):
1045
- """Identifies a prompt."""
1046
-
1047
- type: Literal["ref/prompt"]
1048
- name: str
1049
- """The name of the prompt or prompt template"""
1050
- model_config = ConfigDict(extra="allow")
1051
-
1052
-
1053
- class CompletionArgument(BaseModel):
1054
- """The argument's information for completion requests."""
1055
-
1056
- name: str
1057
- """The name of the argument"""
1058
- value: str
1059
- """The value of the argument to use for completion matching."""
1060
- model_config = ConfigDict(extra="allow")
1061
-
1062
-
1063
- class CompleteRequestParams(RequestParams):
1064
- """Parameters for completion requests."""
1065
-
1066
- ref: ResourceReference | PromptReference
1067
- argument: CompletionArgument
1068
- model_config = ConfigDict(extra="allow")
1069
-
1070
-
1071
- class CompleteRequest(Request):
1072
- """A request from the client to the server, to ask for completion options."""
1073
-
1074
- method: Literal["completion/complete"]
1075
- params: CompleteRequestParams
1076
-
1077
-
1078
- class Completion(BaseModel):
1079
- """Completion information."""
1080
-
1081
- values: list[str]
1082
- """An array of completion values. Must not exceed 100 items."""
1083
- total: int | None = None
1084
- """
1085
- The total number of completion options available. This can exceed the number of
1086
- values actually sent in the response.
1087
- """
1088
- hasMore: bool | None = None
1089
- """
1090
- Indicates whether there are additional completion options beyond those provided in
1091
- the current response, even if the exact total is unknown.
1092
- """
1093
- model_config = ConfigDict(extra="allow")
1094
-
1095
-
1096
- class CompleteResult(Result):
1097
- """The server's response to a completion/complete request"""
1098
-
1099
- completion: Completion
1100
-
1101
-
1102
- class ListRootsRequest(Request):
1103
- """
1104
- Sent from the server to request a list of root URIs from the client. Roots allow
1105
- servers to ask for specific directories or files to operate on. A common example
1106
- for roots is providing a set of repositories or directories a server should operate
1107
- on.
1108
-
1109
- This request is typically used when the server needs to understand the file system
1110
- structure or access specific locations that the client has permission to read from.
1111
- """
1112
-
1113
- method: Literal["roots/list"]
1114
- params: RequestParams | None = None
1115
-
1116
-
1117
- class Root(BaseModel):
1118
- """Represents a root directory or file that the server can operate on."""
1119
-
1120
- uri: FileUrl
1121
- """
1122
- The URI identifying the root. This *must* start with file:// for now.
1123
- This restriction may be relaxed in future versions of the protocol to allow
1124
- other URI schemes.
1125
- """
1126
- name: str | None = None
1127
- """
1128
- An optional name for the root. This can be used to provide a human-readable
1129
- identifier for the root, which may be useful for display purposes or for
1130
- referencing the root in other parts of the application.
1131
- """
1132
- model_config = ConfigDict(extra="allow")
1133
-
1134
-
1135
- class ListRootsResult(Result):
1136
- """
1137
- The client's response to a roots/list request from the server.
1138
- This result contains an array of Root objects, each representing a root directory
1139
- or file that the server can operate on.
1140
- """
1141
-
1142
- roots: list[Root]
1143
-
1144
-
1145
- class RootsListChangedNotification(Notification):
1146
- """
1147
- A notification from the client to the server, informing it that the list of
1148
- roots has changed.
1149
-
1150
- This notification should be sent whenever the client adds, removes, or
1151
- modifies any root. The server should then request an updated list of roots
1152
- using the ListRootsRequest.
1153
- """
1154
-
1155
- method: Literal["notifications/roots/list_changed"]
1156
- params: NotificationParams | None = None
1157
-
1158
-
1159
- class CancelledNotificationParams(NotificationParams):
1160
- """Parameters for cancellation notifications."""
1161
-
1162
- requestId: RequestId
1163
- """The ID of the request to cancel."""
1164
- reason: str | None = None
1165
- """An optional string describing the reason for the cancellation."""
1166
- model_config = ConfigDict(extra="allow")
1167
-
1168
-
1169
- class CancelledNotification(Notification):
1170
- """
1171
- This notification can be sent by either side to indicate that it is cancelling a
1172
- previously-issued request.
1173
- """
1174
-
1175
- method: Literal["notifications/cancelled"]
1176
- params: CancelledNotificationParams
1177
-
1178
-
1179
- class ClientRequest(
1180
- RootModel[
1181
- PingRequest
1182
- | InitializeRequest
1183
- | CompleteRequest
1184
- | SetLevelRequest
1185
- | GetPromptRequest
1186
- | ListPromptsRequest
1187
- | ListResourcesRequest
1188
- | ListResourceTemplatesRequest
1189
- | ReadResourceRequest
1190
- | SubscribeRequest
1191
- | UnsubscribeRequest
1192
- | CallToolRequest
1193
- | ListToolsRequest
1194
- | ListAgentTemplatesRequest
1195
- | ListAgentsRequest
1196
- | CreateAgentRequest
1197
- | DestroyAgentRequest
1198
- | RunAgentRequest
1199
- ]
1200
- ):
1201
- pass
1202
-
1203
-
1204
- class ClientNotification(
1205
- RootModel[
1206
- CancelledNotification
1207
- | ProgressNotification
1208
- | InitializedNotification
1209
- | RootsListChangedNotification
1210
- ]
1211
- ):
1212
- pass
1213
-
1214
-
1215
- class ClientResult(RootModel[EmptyResult | CreateMessageResult | ListRootsResult]):
1216
- pass
1217
-
1218
-
1219
- class ServerRequest(RootModel[PingRequest | CreateMessageRequest | ListRootsRequest]):
1220
- pass
1221
-
1222
-
1223
- class ServerNotification(
1224
- RootModel[
1225
- CancelledNotification
1226
- | ProgressNotification
1227
- | LoggingMessageNotification
1228
- | ResourceUpdatedNotification
1229
- | ResourceListChangedNotification
1230
- | ToolListChangedNotification
1231
- | PromptListChangedNotification
1232
- | AgentListChangedNotification
1233
- | AgentRunProgressNotification
1234
- ]
1235
- ):
1236
- pass
1237
-
1238
-
1239
- class ServerResult(
1240
- RootModel[
1241
- EmptyResult
1242
- | InitializeResult
1243
- | CompleteResult
1244
- | GetPromptResult
1245
- | ListPromptsResult
1246
- | ListResourcesResult
1247
- | ListResourceTemplatesResult
1248
- | ReadResourceResult
1249
- | CallToolResult
1250
- | ListToolsResult
1251
- | ListAgentTemplatesResult
1252
- | ListAgentsResult
1253
- | CreateAgentResult
1254
- | DestroyAgentResult
1255
- | RunAgentResult
1256
- ]
1257
- ):
1258
- pass