@@ -196,12 +196,22 @@ class EmptyResult(Result):
196
196
"""A response that indicates success but carries no data."""
197
197
198
198
199
- class Implementation (BaseModel ):
200
- """Describes the name and version of an MCP implementation."""
201
-
199
+ # BaseMetadata provides common name and title fields for consistency with TypeScript SDK.
200
+ # I'm not sure of the value of extracting this to another class and add more inheritance,
201
+ # it feels like additional indirection but being consistent with typescript here.
202
+ class BaseMetadata (BaseModel ):
203
+ """Base class for entities with name and optional title fields."""
204
+
202
205
name : str
206
+ """The programmatic name of the entity."""
207
+
203
208
title : str | None = None
204
- """A human-readable title for the implementation."""
209
+ """An optional human-readable title for the entity."""
210
+
211
+
212
+ class Implementation (BaseMetadata ):
213
+ """Describes the name and version of an MCP implementation."""
214
+
205
215
version : str
206
216
model_config = ConfigDict (extra = "allow" )
207
217
@@ -384,15 +394,11 @@ class Annotations(BaseModel):
384
394
model_config = ConfigDict (extra = "allow" )
385
395
386
396
387
- class Resource (BaseModel ):
397
+ class Resource (BaseMetadata ):
388
398
"""A known resource that the server is capable of reading."""
389
399
390
400
uri : Annotated [AnyUrl , UrlConstraints (host_required = False )]
391
401
"""The URI of this resource."""
392
- name : str
393
- """A human-readable name for this resource."""
394
- title : str | None = None
395
- """A human-readable title for this resource."""
396
402
description : str | None = None
397
403
"""A description of what this resource represents."""
398
404
mimeType : str | None = None
@@ -413,18 +419,14 @@ class Resource(BaseModel):
413
419
model_config = ConfigDict (extra = "allow" )
414
420
415
421
416
- class ResourceTemplate (BaseModel ):
422
+ class ResourceTemplate (BaseMetadata ):
417
423
"""A template description for resources available on the server."""
418
424
419
425
uriTemplate : str
420
426
"""
421
427
A URI template (according to RFC 6570) that can be used to construct resource
422
428
URIs.
423
429
"""
424
- name : str
425
- """A human-readable name for the type of resource this template refers to."""
426
- title : str | None = None
427
- """A human-readable title for the type of resource this template refers to."""
428
430
description : str | None = None
429
431
"""A human-readable description of what this template is for."""
430
432
mimeType : str | None = None
@@ -607,13 +609,8 @@ class PromptArgument(BaseModel):
607
609
model_config = ConfigDict (extra = "allow" )
608
610
609
611
610
- class Prompt (BaseModel ):
612
+ class Prompt (BaseMetadata ):
611
613
"""A prompt or prompt template that the server offers."""
612
-
613
- name : str
614
- """The name of the prompt or prompt template."""
615
- title : str | None = None
616
- """A human-readable title for the prompt."""
617
614
description : str | None = None
618
615
"""An optional description of what this prompt provides."""
619
616
arguments : list [PromptArgument ] | None = None
@@ -816,13 +813,8 @@ class ToolAnnotations(BaseModel):
816
813
model_config = ConfigDict (extra = "allow" )
817
814
818
815
819
- class Tool (BaseModel ):
816
+ class Tool (BaseMetadata ):
820
817
"""Definition for a tool the client can call."""
821
-
822
- name : str
823
- """The name of the tool."""
824
- title : str | None = None
825
- """A human-readable title for the tool."""
826
818
description : str | None = None
827
819
"""A human-readable description of the tool."""
828
820
inputSchema : dict [str , Any ]
0 commit comments