@@ -53,56 +53,6 @@ export type ServerOptions = ProtocolOptions & {
53
53
capabilities ?: ServerCapabilities ;
54
54
} ;
55
55
56
- /**
57
- * Callback for a tool handler registered with Server.tool().
58
- *
59
- * Parameters will include tool arguments, if applicable, as well as other request handler context.
60
- */
61
- export type ToolCallback < Args extends undefined | ZodRawShape = undefined > =
62
- Args extends ZodRawShape
63
- ? (
64
- args : z . objectOutputType < Args , ZodTypeAny > ,
65
- extra : RequestHandlerExtra ,
66
- ) => CallToolResult | Promise < CallToolResult >
67
- : ( extra : RequestHandlerExtra ) => CallToolResult | Promise < CallToolResult > ;
68
-
69
- type RegisteredTool = {
70
- description ?: string ;
71
- inputSchema ?: AnyZodObject ;
72
- callback : ToolCallback < undefined | ZodRawShape > ;
73
- } ;
74
-
75
- const EMPTY_OBJECT_JSON_SCHEMA = {
76
- type : "object" as const ,
77
- } ;
78
-
79
- export type ResourceMetadata = Omit < Resource , "uri" | "name" > ;
80
-
81
- export type ListResourcesCallback = ( ) =>
82
- | ListResourcesResult
83
- | Promise < ListResourcesResult > ;
84
-
85
- export type ReadResourceCallback = (
86
- uri : URL ,
87
- ) => ReadResourceResult | Promise < ReadResourceResult > ;
88
-
89
- type RegisteredResource = {
90
- name : string ;
91
- metadata ?: ResourceMetadata ;
92
- readCallback : ReadResourceCallback ;
93
- } ;
94
-
95
- export type ReadResourceTemplateCallback = (
96
- uri : URL ,
97
- variables : Variables ,
98
- ) => ReadResourceResult | Promise < ReadResourceResult > ;
99
-
100
- type RegisteredResourceTemplate = {
101
- resourceTemplate : ResourceTemplate ;
102
- metadata ?: ResourceMetadata ;
103
- readCallback : ReadResourceTemplateCallback ;
104
- } ;
105
-
106
56
/**
107
57
* An MCP server on top of a pluggable transport.
108
58
*
@@ -753,3 +703,65 @@ export class ResourceTemplate {
753
703
return this . _listCallback ;
754
704
}
755
705
}
706
+
707
+ /**
708
+ * Callback for a tool handler registered with Server.tool().
709
+ *
710
+ * Parameters will include tool arguments, if applicable, as well as other request handler context.
711
+ */
712
+ export type ToolCallback < Args extends undefined | ZodRawShape = undefined > =
713
+ Args extends ZodRawShape
714
+ ? (
715
+ args : z . objectOutputType < Args , ZodTypeAny > ,
716
+ extra : RequestHandlerExtra ,
717
+ ) => CallToolResult | Promise < CallToolResult >
718
+ : ( extra : RequestHandlerExtra ) => CallToolResult | Promise < CallToolResult > ;
719
+
720
+ type RegisteredTool = {
721
+ description ?: string ;
722
+ inputSchema ?: AnyZodObject ;
723
+ callback : ToolCallback < undefined | ZodRawShape > ;
724
+ } ;
725
+
726
+ const EMPTY_OBJECT_JSON_SCHEMA = {
727
+ type : "object" as const ,
728
+ } ;
729
+
730
+ /**
731
+ * Additional, optional information for annotating a resource.
732
+ */
733
+ export type ResourceMetadata = Omit < Resource , "uri" | "name" > ;
734
+
735
+ /**
736
+ * Callback to list all resources matching a given template.
737
+ */
738
+ export type ListResourcesCallback = ( ) =>
739
+ | ListResourcesResult
740
+ | Promise < ListResourcesResult > ;
741
+
742
+ /**
743
+ * Callback to read a resource at a given URI.
744
+ */
745
+ export type ReadResourceCallback = (
746
+ uri : URL ,
747
+ ) => ReadResourceResult | Promise < ReadResourceResult > ;
748
+
749
+ type RegisteredResource = {
750
+ name : string ;
751
+ metadata ?: ResourceMetadata ;
752
+ readCallback : ReadResourceCallback ;
753
+ } ;
754
+
755
+ /**
756
+ * Callback to read a resource at a given URI, following a filled-in URI template.
757
+ */
758
+ export type ReadResourceTemplateCallback = (
759
+ uri : URL ,
760
+ variables : Variables ,
761
+ ) => ReadResourceResult | Promise < ReadResourceResult > ;
762
+
763
+ type RegisteredResourceTemplate = {
764
+ resourceTemplate : ResourceTemplate ;
765
+ metadata ?: ResourceMetadata ;
766
+ readCallback : ReadResourceTemplateCallback ;
767
+ } ;
0 commit comments