tmcp 1.4.0 → 1.6.0

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.
package/src/index.d.ts CHANGED
@@ -10,10 +10,15 @@ export class McpServer<StandardSchema extends StandardSchemaV1> {
10
10
  * @param {ServerOptions<StandardSchema>} options
11
11
  */
12
12
  constructor(server_info: ServerInfo, options: ServerOptions<StandardSchema>);
13
+ /**
14
+ * @type {Array<{uri: string, name?: string}>}
15
+ */
16
+ roots: Array<{
17
+ uri: string;
18
+ name?: string;
19
+ }>;
13
20
  currentClientCapabilities(): {
14
- roots?: {
15
- listChanged?: boolean;
16
- } & {
21
+ experimental?: {} & {
17
22
  [key: string]: unknown;
18
23
  };
19
24
  sampling?: {} & {
@@ -22,6 +27,11 @@ export class McpServer<StandardSchema extends StandardSchemaV1> {
22
27
  elicitation?: {} & {
23
28
  [key: string]: unknown;
24
29
  };
30
+ roots?: {
31
+ listChanged?: boolean;
32
+ } & {
33
+ [key: string]: unknown;
34
+ };
25
35
  } & {
26
36
  [key: string]: unknown;
27
37
  };
@@ -34,64 +44,86 @@ export class McpServer<StandardSchema extends StandardSchemaV1> {
34
44
  on<TEvent extends keyof McpEvents>(event: TEvent, callback: McpEvents[TEvent], options?: AddEventListenerOptions): void;
35
45
  /**
36
46
  * @template {StandardSchema | undefined} [TSchema=undefined]
37
- * @param {{ name: string; description: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never }} options
47
+ * @param {{ name: string; description: string; title?: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never }} options
38
48
  * @param {TSchema extends undefined ? (()=>Promise<CallToolResult> | CallToolResult) : ((input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<CallToolResult> | CallToolResult)} execute
39
49
  */
40
- tool<TSchema extends StandardSchema | undefined = undefined>({ name, description, schema }: {
50
+ tool<TSchema extends StandardSchema | undefined = undefined>({ name, description, title, schema }: {
41
51
  name: string;
42
52
  description: string;
53
+ title?: string;
43
54
  schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never;
44
55
  }, execute: TSchema extends undefined ? (() => Promise<CallToolResult> | CallToolResult) : ((input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<CallToolResult> | CallToolResult)): void;
45
56
  /**
46
57
  * @template {StandardSchema | undefined} [TSchema=undefined]
47
- * @param {{ name: string; description: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never; complete?: NoInfer<TSchema extends undefined ? never : Partial<Record<keyof (StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>), Completion>>> }} options
58
+ * @param {{ name: string; description: string; title?: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never; complete?: NoInfer<TSchema extends undefined ? never : Partial<Record<keyof (StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>), Completion>>> }} options
48
59
  * @param {TSchema extends undefined ? (()=>Promise<GetPromptResult> | GetPromptResult) : (input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<GetPromptResult> | GetPromptResult} execute
49
60
  */
50
- prompt<TSchema extends StandardSchema | undefined = undefined>({ name, description, schema, complete }: {
61
+ prompt<TSchema extends StandardSchema | undefined = undefined>({ name, description, title, schema, complete }: {
51
62
  name: string;
52
63
  description: string;
64
+ title?: string;
53
65
  schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never;
54
66
  complete?: NoInfer<TSchema extends undefined ? never : Partial<Record<keyof StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>, Completion>>>;
55
67
  }, execute: TSchema extends undefined ? (() => Promise<GetPromptResult> | GetPromptResult) : (input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<GetPromptResult> | GetPromptResult): void;
56
68
  /**
57
- * @param {{ name: string; description: string; uri: string }} options
69
+ * @param {{ name: string; description: string; title?: string; uri: string }} options
58
70
  * @param {(uri: string) => Promise<ReadResourceResult> | ReadResourceResult} execute
59
71
  */
60
- resource({ name, description, uri }: {
72
+ resource({ name, description, title, uri }: {
61
73
  name: string;
62
74
  description: string;
75
+ title?: string;
63
76
  uri: string;
64
77
  }, execute: (uri: string) => Promise<ReadResourceResult> | ReadResourceResult): void;
65
78
  /**
66
79
  * @template {string} TUri
67
80
  * @template {ExtractURITemplateVariables<TUri>} TVariables
68
- * @param {{ name: string; description: string; uri: TUri; complete?: NoInfer<TVariables extends never ? never : Partial<Record<TVariables, Completion>>> }} options
81
+ * @param {{ name: string; description: string; title?: string; uri: TUri; complete?: NoInfer<TVariables extends never ? never : Partial<Record<TVariables, Completion>>>; list?: () => Promise<Array<Resource>> | Array<Resource> }} options
69
82
  * @param {(uri: string, params: Record<TVariables, string | string[]>) => Promise<ReadResourceResult> | ReadResourceResult} execute
70
83
  */
71
- template<TUri extends string, TVariables extends ExtractURITemplateVariables<TUri>>({ name, description, uri, complete }: {
84
+ template<TUri extends string, TVariables extends ExtractURITemplateVariables<TUri>>({ name, description, title, uri, complete, list: list_resources }: {
72
85
  name: string;
73
86
  description: string;
87
+ title?: string;
74
88
  uri: TUri;
75
89
  complete?: NoInfer<TVariables extends never ? never : Partial<Record<TVariables, Completion>>>;
90
+ list?: () => Promise<Array<Resource>> | Array<Resource>;
76
91
  }, execute: (uri: string, params: Record<TVariables, string | string[]>) => Promise<ReadResourceResult> | ReadResourceResult): void;
77
92
  /**
78
- * @param {JSONRPCRequest} request
93
+ * @param {JSONRPCResponse | JSONRPCRequest} message
79
94
  * @param {string} [session_id]
80
- * @returns {ReturnType<JSONRPCServer['receive']>}
95
+ * @returns {ReturnType<JSONRPCServer['receive']> | ReturnType<JSONRPCClient['receive'] | undefined>}
81
96
  */
82
- receive(request: JSONRPCRequest, session_id?: string): ReturnType<JSONRPCServer["receive"]>;
97
+ receive(message: JSONRPCResponse | JSONRPCRequest, session_id?: string): ReturnType<JSONRPCServer["receive"]> | ReturnType<JSONRPCClient["receive"] | undefined>;
83
98
  /**
84
99
  * Send a notification for subscriptions
85
100
  * @param {SubscriptionsKeys} what
86
101
  * @param {string} id
87
102
  */
88
103
  changed(what: SubscriptionsKeys, id: string): void;
104
+ /**
105
+ * Refresh roots list from client
106
+ */
107
+ refreshRoots(): Promise<void>;
89
108
  /**
90
109
  * @template {StandardSchema} TSchema
91
110
  * @param {TSchema} schema
92
111
  * @returns {Promise<StandardSchemaV1.InferOutput<TSchema>>}
93
112
  */
94
113
  elicitation<TSchema extends StandardSchema>(schema: TSchema): Promise<StandardSchemaV1.InferOutput<TSchema>>;
114
+ /**
115
+ * Request language model sampling from the client
116
+ * @param {CreateMessageRequestParams} request
117
+ * @returns {Promise<CreateMessageResult>}
118
+ */
119
+ message(request: CreateMessageRequestParams): Promise<CreateMessageResult>;
120
+ /**
121
+ * Log a message to the client if logging is enabled and the level is appropriate
122
+ * @param {LoggingLevel} level
123
+ * @param {unknown} data
124
+ * @param {string} [logger]
125
+ */
126
+ log(level: LoggingLevel, data: unknown, logger?: string): void;
95
127
  #private;
96
128
  }
97
129
  export type ClientCapabilities = ClientCapabilitiesType;
@@ -102,9 +134,15 @@ import type { Completion } from "./internal/internal.js";
102
134
  import type { GetPromptResult } from "./validation/index.js";
103
135
  import type { ReadResourceResult } from "./validation/index.js";
104
136
  import type { ExtractURITemplateVariables } from "./internal/uri-template.js";
137
+ import type { Resource } from "./validation/index.js";
138
+ import type { JSONRPCResponse } from "./validation/index.js";
105
139
  import type { JSONRPCRequest } from "json-rpc-2.0";
106
140
  import { JSONRPCServer } from 'json-rpc-2.0';
141
+ import { JSONRPCClient } from 'json-rpc-2.0';
107
142
  import type { SubscriptionsKeys } from "./internal/internal.js";
143
+ import type { CreateMessageRequestParams } from "./validation/index.js";
144
+ import type { CreateMessageResult } from "./validation/index.js";
145
+ import type { LoggingLevel } from "./validation/index.js";
108
146
  import type { ServerInfo } from "./internal/internal.js";
109
147
  import type { ServerOptions } from "./internal/internal.js";
110
148
  import type { ClientCapabilities as ClientCapabilitiesType } from "./validation/index.js";