tmcp 1.15.5 → 1.16.1

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/README.md CHANGED
@@ -57,6 +57,10 @@ const server = new McpServer(
57
57
  },
58
58
  );
59
59
 
60
+ // While the adapter is optional (you can opt out by explicitly passing `adapter: undefined`)
61
+ // without an adapter the server cannot accept inputs, produce structured outputs, or request
62
+ // elicitations at all only do this for very simple servers.
63
+
60
64
  // Define a tool with type-safe schema
61
65
  server.tool(
62
66
  {
@@ -107,7 +111,10 @@ new McpServer(serverInfo, options);
107
111
  ```
108
112
 
109
113
  - `serverInfo`: Server metadata (name, version, description)
110
- - `options`: Configuration object with adapter and capabilities
114
+ - `options`: Configuration object with optional adapter (for schema conversion) and capabilities
115
+
116
+ > [!IMPORTANT]
117
+ > While the adapter is optional (you can opt out by explicitly passing `adapter: undefined`) without an adapter the server cannot accept inputs, produce structured outputs, or request elicitations at all only do this for very simple servers.
111
118
 
112
119
  #### Methods
113
120
 
@@ -129,6 +136,8 @@ server.tool(
129
136
  );
130
137
  ```
131
138
 
139
+ `sessionInfo` contains the latest `clientCapabilities`, `clientInfo`, and `logLevel` reported by the connected client. Built-in transports populate it automatically, so every handler can branch on client features without additional bookkeeping.
140
+
132
141
  ##### `prompt(definition, handler)`
133
142
 
134
143
  Register a prompt template with optional schema validation.
@@ -232,30 +241,34 @@ server.tool(
232
241
 
233
242
  ##### `ctx`
234
243
 
235
- Access the current request context, including session ID, auth info, and custom context.
244
+ Access the current request context, including session ID, auth info, client metadata, and custom context.
236
245
 
237
246
  ```javascript
238
247
  server.tool(
239
- {
240
- name: 'context-aware-tool',
241
- description: 'Tool that uses request context',
242
- },
243
- async () => {
244
- const { sessionId, auth, custom } = server.ctx;
245
-
246
- if (!custom?.userId) {
247
- throw new Error('User authentication required');
248
- }
249
-
250
- return {
251
- content: [
252
- {
253
- type: 'text',
254
- text: `Hello user ${custom.userId} in session ${sessionId}`,
255
- },
256
- ],
257
- };
258
- },
248
+ {
249
+ name: 'context-aware-tool',
250
+ description: 'Tool that uses request context',
251
+ },
252
+ async () => {
253
+ const { sessionId, auth, sessionInfo, custom } = server.ctx;
254
+
255
+ if (!custom?.userId) {
256
+ throw new Error('User authentication required');
257
+ }
258
+
259
+ if (sessionInfo?.clientInfo) {
260
+ console.log(`Serving ${sessionInfo.clientInfo.name}`);
261
+ }
262
+
263
+ return {
264
+ content: [
265
+ {
266
+ type: 'text',
267
+ text: `Hello user ${custom.userId} in session ${sessionId}`,
268
+ },
269
+ ],
270
+ };
271
+ },
259
272
  );
260
273
  ```
261
274
 
@@ -269,9 +282,14 @@ const response = server.receive(jsonRpcRequest);
269
282
 
270
283
  // With custom context (typically used by transports)
271
284
  const response = server.receive(jsonRpcRequest, {
272
- sessionId: 'session-123',
273
- auth: authInfo,
274
- custom: customContextData,
285
+ sessionId: 'session-123',
286
+ auth: authInfo,
287
+ sessionInfo: {
288
+ clientCapabilities,
289
+ clientInfo,
290
+ logLevel,
291
+ },
292
+ custom: customContextData,
275
293
  });
276
294
  ```
277
295
 
@@ -309,7 +327,7 @@ console.log(server.roots); // Access current roots
309
327
 
310
328
  ##### `changed(type, id)`
311
329
 
312
- Send notifications for subscriptions.
330
+ Send notifications for subscriptions. When you call `changed('resource', uri)` the server now emits a broadcast notification, and the built-in transports look up which sessions subscribed to that URI before delivering it.
313
331
 
314
332
  ```javascript
315
333
  server.changed('resource', 'file://path/to/resource');
@@ -380,13 +398,25 @@ server.log('error', 'Failed to connect to database', 'database-logger');
380
398
 
381
399
  Listen to server events.
382
400
 
401
+ Available events:
402
+
403
+ - `initialize` – fired after the client handshake with the parsed initialize payload
404
+ - `send` – emitted for point-to-point responses/notifications destined for the active session
405
+ - `broadcast` – emitted for fan-out notifications (for example `notifications/resources/updated`)
406
+ - `subscription` – raised when the client subscribes to a resource URI
407
+ - `loglevelchange` – fired when the client requests a different log level
408
+
383
409
  ```javascript
384
- server.on('initialize', (data) => {
385
- console.log('Client initialized:', data);
410
+ server.on('initialize', ({ clientInfo }) => {
411
+ console.log('Client initialized:', clientInfo?.name);
386
412
  });
387
413
 
388
- server.on('send', ({ request, context }) => {
389
- console.log('Sending request:', request);
414
+ server.on('send', ({ request }) => {
415
+ console.log('Sending message:', request);
416
+ });
417
+
418
+ server.on('broadcast', ({ request }) => {
419
+ console.log('Broadcasting:', request.method);
390
420
  });
391
421
  ```
392
422
 
@@ -516,9 +546,15 @@ server.on('initialize', (data) => {
516
546
  console.log('Client capabilities:', data.capabilities);
517
547
  });
518
548
 
519
- server.on('send', ({ request, context }) => {
549
+ server.on('send', ({ request }) => {
520
550
  console.log('Outgoing request:', request.method);
521
551
  });
552
+
553
+ server.on('broadcast', ({ request }) => {
554
+ if (request.method === 'notifications/resources/updated') {
555
+ console.log('Resource updated:', request.params.uri);
556
+ }
557
+ });
522
558
  ```
523
559
 
524
560
  ### Resource Subscriptions
@@ -923,7 +959,7 @@ server.prompt(
923
959
  );
924
960
  ```
925
961
 
926
- or enable a something based on client capabilities or info
962
+ or enable something based on client capabilities or info
927
963
 
928
964
  ```javascript
929
965
  server.prompt(
@@ -932,8 +968,8 @@ server.prompt(
932
968
  description: 'Claude Code prompt',
933
969
  enabled: () => {
934
970
  // Access session information
935
- const clientInfo = server.currentClientInfo();
936
- return clientInfo.name === 'Claude Code';
971
+ const clientInfo = server.ctx.sessionInfo?.clientInfo;
972
+ return clientInfo?.name === 'Claude Code';
937
973
  },
938
974
  },
939
975
  async (input) => {
@@ -958,8 +994,9 @@ server.prompt(
958
994
  description: 'fetch the repositories of the user',
959
995
  enabled: () => {
960
996
  // Access session information
961
- const clientInfo = server.currentClientCapabilities();
962
- return clientInfo.elicitation != null;
997
+ const clientCapabilities =
998
+ server.ctx.sessionInfo?.clientCapabilities;
999
+ return clientCapabilities?.elicitation != null;
963
1000
  },
964
1001
  },
965
1002
  async (input) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmcp",
3
- "version": "1.15.5",
3
+ "version": "1.16.1",
4
4
  "description": "The main tmcp library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * @import SqidsType from "sqids";
5
5
  * @import { JSONRPCRequest, JSONRPCParams } from "json-rpc-2.0";
6
6
  * @import { ExtractURITemplateVariables } from "./internal/uri-template.js";
7
- * @import { CallToolResult as CallToolResultType, ReadResourceResult as ReadResourceResultType, GetPromptResult as GetPromptResultType, ServerInfo as ServerInfoType, ClientCapabilities as ClientCapabilitiesType, JSONRPCRequest as JSONRPCRequestType, JSONRPCResponse, CreateMessageRequestParams as CreateMessageRequestParamsType, CreateMessageResult as CreateMessageResultType, Resource as ResourceType, LoggingLevel as LoggingLevelType, ToolAnnotations, ClientInfo as ClientInfoType, ElicitResult as ElicitResultType, Icons as IconsType } from "./validation/index.js";
7
+ * @import { CallToolResult as CallToolResultType, ReadResourceResult as ReadResourceResultType, GetPromptResult as GetPromptResultType, ServerInfo as ServerInfoType, ClientCapabilities as ClientCapabilitiesType, JSONRPCRequest as JSONRPCRequestType, JSONRPCResponse, CreateMessageRequestParams as CreateMessageRequestParamsType, CreateMessageResult as CreateMessageResultType, Resource as ResourceType, LoggingLevel as LoggingLevelType, ToolAnnotations, ClientInfo as ClientInfoType, ElicitResult as ElicitResultType, Icons as IconsType, JSONRPCMessage } from "./validation/index.js";
8
8
  * @import { Tool, Completion, Prompt, StoredResource, ServerOptions, SubscriptionsKeys, ChangedArgs, McpEvents } from "./internal/internal.js";
9
9
  */
10
10
  import { JSONRPCClient, JSONRPCServer } from 'json-rpc-2.0';
@@ -49,6 +49,7 @@ import { should_version_negotiation_fail } from './validation/version.js';
49
49
  * @template {Record<string, unknown> | undefined} [TCustom=undefined]
50
50
  * @typedef {Object} Context
51
51
  * @property {string} [sessionId]
52
+ * @property {{ clientCapabilities?: ClientCapabilitiesType, clientInfo?: ClientInfoType, logLevel?: LoggingLevel }} [sessionInfo]
52
53
  * @property {AuthInfo} [auth]
53
54
  * @property {TCustom} [custom]
54
55
  */
@@ -57,6 +58,10 @@ import { should_version_negotiation_fail } from './validation/version.js';
57
58
  * @typedef {IconsType} Icons
58
59
  */
59
60
 
61
+ /**
62
+ * @typedef {Record<SubscriptionsKeys, string[]>} Subscriptions
63
+ */
64
+
60
65
  /**
61
66
  * @template {Record<string, unknown> | undefined} TStructuredContent
62
67
  * @typedef {CallToolResultType<TStructuredContent>} CallToolResult
@@ -149,7 +154,7 @@ async function safe_enabled(enabled) {
149
154
  export class McpServer {
150
155
  #server = new JSONRPCServer();
151
156
  /**
152
- * @type {JSONRPCClient<Record<string, any> | undefined> | undefined}
157
+ * @type {JSONRPCClient<"broadcast" | "standalone"> | undefined}
153
158
  */
154
159
  #client;
155
160
  #options;
@@ -180,36 +185,11 @@ export class McpServer {
180
185
 
181
186
  #event_target = new EventTarget();
182
187
 
183
- /**
184
- * @type {Record<SubscriptionsKeys, Map<string, Set<string | undefined>>>}
185
- */
186
- #subscriptions = {
187
- /**
188
- * @type {Map<string, Set<string>>}
189
- */
190
- resource: new Map(),
191
- };
192
-
193
188
  /**
194
189
  * @type {AsyncLocalStorage<Context<CustomContext> & { progress_token?: string }>}
195
190
  */
196
191
  #ctx_storage = new AsyncLocalStorage();
197
192
 
198
- /**
199
- * @type {Map<string|undefined, ClientCapabilities>}
200
- */
201
- #client_capabilities_map = new Map();
202
-
203
- /**
204
- * @type {Map<string|undefined, ClientInfo>}
205
- */
206
- #client_info_map = new Map();
207
-
208
- /**
209
- * @type {Map<string|undefined, LoggingLevel>}
210
- */
211
- #session_log_levels = new Map();
212
-
213
193
  /**
214
194
  * @param {ServerInfo} server_info
215
195
  * @param {ServerOptions<StandardSchema>} options
@@ -224,8 +204,6 @@ export class McpServer {
224
204
  initialize_request,
225
205
  );
226
206
 
227
- const session_id = this.#session_id;
228
-
229
207
  // Validate protocol version format
230
208
  if (
231
209
  should_version_negotiation_fail(
@@ -245,18 +223,6 @@ export class McpServer {
245
223
  validated_initialize.protocolVersion,
246
224
  );
247
225
 
248
- // Store client capabilities
249
- this.#client_capabilities_map.set(
250
- session_id,
251
- validated_initialize.capabilities,
252
- );
253
-
254
- // Store client info
255
- this.#client_info_map.set(
256
- session_id,
257
- validated_initialize.clientInfo,
258
- );
259
-
260
226
  // Dispatch initialization event
261
227
  this.#event_target.dispatchEvent(
262
228
  new CustomEvent('initialize', {
@@ -324,10 +290,6 @@ export class McpServer {
324
290
  );
325
291
  }
326
292
 
327
- get #session_id() {
328
- return this.#ctx_storage.getStore()?.sessionId;
329
- }
330
-
331
293
  get #progress_token() {
332
294
  return this.#ctx_storage.getStore()?.progress_token;
333
295
  }
@@ -343,18 +305,20 @@ export class McpServer {
343
305
  }
344
306
 
345
307
  get #client_capabilities() {
346
- return this.#client_capabilities_map.get(this.#session_id);
308
+ return this.#ctx_storage.getStore()?.sessionInfo?.clientCapabilities;
347
309
  }
348
310
 
349
311
  /**
350
312
  * Get the client information (name, version, etc.) of the client that initiated the current request...useful if you want to do something different based on the client.
313
+ * @deprecated Use `server.ctx.sessionInfo.clientInfo` instead.
351
314
  */
352
315
  currentClientInfo() {
353
- return this.#client_info_map.get(this.#session_id);
316
+ return this.#ctx_storage.getStore()?.sessionInfo?.clientInfo;
354
317
  }
355
318
 
356
319
  /**
357
320
  * Get the client capabilities of the client that initiated the current request, you can use this to verify the client support something before invoking the respective method.
321
+ * @deprecated Use `server.ctx.sessionInfo.clientCapabilities` instead.
358
322
  */
359
323
  currentClientCapabilities() {
360
324
  return this.#client_capabilities;
@@ -362,10 +326,18 @@ export class McpServer {
362
326
 
363
327
  #lazyily_create_client() {
364
328
  if (!this.#client) {
365
- this.#client = new JSONRPCClient((payload, context = {}) => {
329
+ this.#client = new JSONRPCClient((payload, kind) => {
330
+ if (kind === 'broadcast') {
331
+ this.#event_target.dispatchEvent(
332
+ new CustomEvent('broadcast', {
333
+ detail: { request: payload },
334
+ }),
335
+ );
336
+ return;
337
+ }
366
338
  this.#event_target.dispatchEvent(
367
339
  new CustomEvent('send', {
368
- detail: { request: payload, context },
340
+ detail: { request: payload },
369
341
  }),
370
342
  );
371
343
  });
@@ -379,7 +351,7 @@ export class McpServer {
379
351
  * @param {AddEventListenerOptions} [options]
380
352
  */
381
353
  on(event, callback, options) {
382
- if (event === 'send') {
354
+ if (event === 'send' || event === 'broadcast') {
383
355
  this.#lazyily_create_client();
384
356
  }
385
357
 
@@ -400,10 +372,10 @@ export class McpServer {
400
372
  /**
401
373
  * @param {string} method
402
374
  * @param {JSONRPCParams} [params]
403
- * @param {Record<string, any>} [extra]
375
+ * @param {"broadcast" | "standalone"} [kind]
404
376
  */
405
- #notify(method, params, extra) {
406
- this.#client?.notify(method, params, extra);
377
+ #notify(method, params, kind = 'standalone') {
378
+ this.#client?.notify(method, params, kind);
407
379
  }
408
380
 
409
381
  /**
@@ -425,12 +397,14 @@ export class McpServer {
425
397
  title: tool.title || tool.description,
426
398
  description: tool.description,
427
399
  icons: tool.icons,
428
- inputSchema: tool.schema
429
- ? await this.#options.adapter.toJsonSchema(
430
- tool.schema,
431
- )
432
- : { type: 'object', properties: {} },
433
- ...(tool.outputSchema
400
+ _meta: tool._meta,
401
+ inputSchema:
402
+ tool.schema && this.#options.adapter
403
+ ? await this.#options.adapter.toJsonSchema(
404
+ tool.schema,
405
+ )
406
+ : { type: 'object', properties: {} },
407
+ ...(tool.outputSchema && this.#options.adapter
434
408
  ? {
435
409
  outputSchema:
436
410
  await this.#options.adapter.toJsonSchema(
@@ -542,16 +516,17 @@ export class McpServer {
542
516
  (await safe_enabled(prompt.enabled)) === false
543
517
  )
544
518
  return null;
545
- const arguments_schema = prompt.schema
546
- ? await this.#options.adapter.toJsonSchema(
547
- prompt.schema,
548
- )
549
- : {
550
- type: 'object',
551
- properties:
552
- /** @type {Record<string, {description: string}>} */ ({}),
553
- required: [],
554
- };
519
+ const arguments_schema =
520
+ prompt.schema && this.#options.adapter
521
+ ? await this.#options.adapter.toJsonSchema(
522
+ prompt.schema,
523
+ )
524
+ : {
525
+ type: 'object',
526
+ properties:
527
+ /** @type {Record<string, {description: string}>} */ ({}),
528
+ required: [],
529
+ };
555
530
  const keys = Object.keys(
556
531
  arguments_schema.properties ?? {},
557
532
  );
@@ -637,12 +612,11 @@ export class McpServer {
637
612
 
638
613
  if (this.#options.capabilities?.resources?.subscribe) {
639
614
  this.#server.addMethod('resources/subscribe', async ({ uri }) => {
640
- let subscriptions = this.#subscriptions.resource.get(uri);
641
- if (!subscriptions) {
642
- subscriptions = new Set();
643
- this.#subscriptions.resource.set(uri, subscriptions);
644
- }
645
- subscriptions.add(this.#session_id);
615
+ this.#event_target.dispatchEvent(
616
+ new CustomEvent('subscription', {
617
+ detail: { uri },
618
+ }),
619
+ );
646
620
  return {};
647
621
  });
648
622
  }
@@ -786,9 +760,7 @@ export class McpServer {
786
760
  const response = await this.#client?.request(
787
761
  'roots/list',
788
762
  undefined,
789
- {
790
- sessions: [this.#session_id],
791
- },
763
+ 'standalone',
792
764
  );
793
765
  this.roots = response?.roots || [];
794
766
  } catch {
@@ -819,26 +791,34 @@ export class McpServer {
819
791
  if (!this.#options.capabilities?.logging) return;
820
792
 
821
793
  this.#server.addMethod('logging/setLevel', ({ level }) => {
822
- this.#session_log_levels.set(this.#session_id, level);
794
+ this.#event_target.dispatchEvent(
795
+ new CustomEvent('loglevelchange', {
796
+ detail: { level },
797
+ }),
798
+ );
823
799
  return {};
824
800
  });
825
801
  }
826
802
 
827
803
  #notify_tools_list_changed() {
828
804
  if (this.#options.capabilities?.tools?.listChanged) {
829
- this.#notify('notifications/tools/list_changed', {});
805
+ this.#notify('notifications/tools/list_changed', {}, 'broadcast');
830
806
  }
831
807
  }
832
808
 
833
809
  #notify_prompts_list_changed() {
834
810
  if (this.#options.capabilities?.prompts?.listChanged) {
835
- this.#notify('notifications/prompts/list_changed', {});
811
+ this.#notify('notifications/prompts/list_changed', {}, 'broadcast');
836
812
  }
837
813
  }
838
814
 
839
815
  #notify_resources_list_changed() {
840
816
  if (this.#options.capabilities?.resources?.listChanged) {
841
- this.#notify('notifications/resources/list_changed', {});
817
+ this.#notify(
818
+ 'notifications/resources/list_changed',
819
+ {},
820
+ 'broadcast',
821
+ );
842
822
  }
843
823
  }
844
824
 
@@ -849,7 +829,7 @@ export class McpServer {
849
829
  * Tools will be invoked by the LLM when it thinks it needs to use them, you can use the annotations to provide additional information about the tool, like what it does, how to use it, etc.
850
830
  * @template {StandardSchema | undefined} [TSchema=undefined]
851
831
  * @template {StandardSchema | undefined} [TOutputSchema=undefined]
852
- * @param {{ name: string; description: string; title?: string; enabled?: ()=>boolean | Promise<boolean>; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never; outputSchema?: StandardSchemaV1.InferOutput<TOutputSchema extends undefined ? never : TOutputSchema> extends Record<string, unknown> ? TOutputSchema : never; annotations?: ToolAnnotations } & Icons} options
832
+ * @param {{ name: string; _meta?: Record<string, any>; description: string; title?: string; enabled?: ()=>boolean | Promise<boolean>; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never; outputSchema?: StandardSchemaV1.InferOutput<TOutputSchema extends undefined ? never : TOutputSchema> extends Record<string, unknown> ? TOutputSchema : never; annotations?: ToolAnnotations } & Icons} options
853
833
  * @param {TSchema extends undefined ? (()=>Promise<CallToolResult<TOutputSchema extends undefined ? undefined : StandardSchemaV1.InferInput<TOutputSchema extends undefined ? never : TOutputSchema>>> | CallToolResult<TOutputSchema extends undefined ? undefined : StandardSchemaV1.InferInput<TOutputSchema extends undefined ? never : TOutputSchema>>) : ((input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<CallToolResult<TOutputSchema extends undefined ? undefined : StandardSchemaV1.InferInput<TOutputSchema extends undefined ? never : TOutputSchema>>> | CallToolResult<TOutputSchema extends undefined ? undefined : StandardSchemaV1.InferInput<TOutputSchema extends undefined ? never : TOutputSchema>>)} execute
854
834
  */
855
835
  tool(
@@ -862,6 +842,7 @@ export class McpServer {
862
842
  annotations,
863
843
  enabled,
864
844
  icons,
845
+ _meta,
865
846
  },
866
847
  execute,
867
848
  ) {
@@ -875,6 +856,7 @@ export class McpServer {
875
856
  execute,
876
857
  annotations,
877
858
  icons,
859
+ _meta,
878
860
  });
879
861
  }
880
862
  /**
@@ -976,7 +958,7 @@ export class McpServer {
976
958
  /**
977
959
  * The main function that receive a JSONRpc message and either dispatch a `send` event or process the request.
978
960
  *
979
- * @param {JSONRPCResponse | JSONRPCRequest} message
961
+ * @param {JSONRPCMessage} message
980
962
  * @param {Context<CustomContext>} [ctx]
981
963
  * @returns {ReturnType<JSONRPCServer['receive']> | ReturnType<JSONRPCClient['receive'] | undefined>}
982
964
  */
@@ -989,18 +971,6 @@ export class McpServer {
989
971
 
990
972
  // Check if it's a request or response
991
973
  if (validated_message.success) {
992
- // we want to set a default log level for each session
993
- // so that if the user calls `log` it can send a notification
994
- // to each client that didn't explicitly set a log level too
995
- if (
996
- !!this.#options.capabilities?.logging &&
997
- !this.#session_log_levels.has(ctx?.sessionId)
998
- ) {
999
- this.#session_log_levels.set(
1000
- ctx?.sessionId,
1001
- this.#options.logging?.default ?? 'info',
1002
- );
1003
- }
1004
974
  const progress_token = /** @type {string | undefined} */ (
1005
975
  validated_message.output.params?._meta?.progressToken
1006
976
  );
@@ -1035,28 +1005,16 @@ export class McpServer {
1035
1005
  } else if (what === 'resources') {
1036
1006
  this.#notify_resources_list_changed();
1037
1007
  } else {
1038
- if (
1039
- this.#subscriptions[
1040
- /** @type {SubscriptionsKeys} */ (what)
1041
- ].has(id)
1042
- ) {
1043
- const resource = this.#resources.get(id);
1044
- if (!resource) return;
1045
- const sessions =
1046
- this.#subscriptions[
1047
- /** @type {SubscriptionsKeys} */ (what)
1048
- ].get(id);
1049
- this.#notify(
1050
- `notifications/resources/updated`,
1051
- {
1052
- uri: id,
1053
- title: resource.name,
1054
- },
1055
- {
1056
- sessions: sessions ? [...sessions] : undefined,
1057
- },
1058
- );
1059
- }
1008
+ const resource = this.#resources.get(id);
1009
+ if (!resource) return;
1010
+ this.#notify(
1011
+ `notifications/resources/updated`,
1012
+ {
1013
+ uri: id,
1014
+ title: resource.name,
1015
+ },
1016
+ 'broadcast',
1017
+ );
1060
1018
  }
1061
1019
  }
1062
1020
 
@@ -1089,11 +1047,9 @@ export class McpServer {
1089
1047
  {
1090
1048
  message,
1091
1049
  requestedSchema:
1092
- await this.#options.adapter.toJsonSchema(schema),
1093
- },
1094
- {
1095
- sessions: [this.#session_id],
1050
+ await this.#options.adapter?.toJsonSchema(schema),
1096
1051
  },
1052
+ 'standalone',
1097
1053
  );
1098
1054
  const elicit_result = v.parse(ElicitResultSchema, result);
1099
1055
  let validated_result = schema['~standard'].validate(
@@ -1131,9 +1087,7 @@ export class McpServer {
1131
1087
  const response = await this.#client?.request(
1132
1088
  'sampling/createMessage',
1133
1089
  validated_request,
1134
- {
1135
- sessions: [this.#session_id],
1136
- },
1090
+ 'standalone',
1137
1091
  );
1138
1092
 
1139
1093
  // Validate and return the response
@@ -1149,18 +1103,12 @@ export class McpServer {
1149
1103
  */
1150
1104
  progress(progress, total = 1, message = undefined) {
1151
1105
  if (this.#progress_token != null) {
1152
- this.#notify(
1153
- 'notifications/progress',
1154
- {
1155
- progress,
1156
- total,
1157
- message,
1158
- progressToken: this.#progress_token,
1159
- },
1160
- {
1161
- sessions: this.#session_id ? [this.#session_id] : undefined,
1162
- },
1163
- );
1106
+ this.#notify('notifications/progress', {
1107
+ progress,
1108
+ total,
1109
+ message,
1110
+ progressToken: this.#progress_token,
1111
+ });
1164
1112
  }
1165
1113
  }
1166
1114
 
@@ -1179,33 +1127,21 @@ export class McpServer {
1179
1127
  );
1180
1128
  }
1181
1129
 
1182
- const sessions = [];
1183
-
1184
- const current_session_level = this.#session_log_levels.get(
1185
- this.#session_id,
1186
- );
1130
+ const current_session_level =
1131
+ this.#ctx_storage.getStore()?.sessionInfo?.logLevel ??
1132
+ this.#options.logging?.default ??
1133
+ 'info';
1187
1134
 
1188
1135
  if (
1189
1136
  current_session_level &&
1190
1137
  this.#should_log(level, current_session_level)
1191
1138
  ) {
1192
- sessions.push(this.#session_id);
1193
- }
1194
-
1195
- if (sessions.length === 0) return;
1196
-
1197
- // Send the log notification to the client
1198
- this.#notify(
1199
- 'notifications/message',
1200
- {
1139
+ this.#notify('notifications/message', {
1201
1140
  level,
1202
1141
  data,
1203
1142
  logger,
1204
- },
1205
- {
1206
- sessions,
1207
- },
1208
- );
1143
+ });
1144
+ }
1209
1145
  }
1210
1146
 
1211
1147
  /**
@@ -20,6 +20,7 @@ export type Tool<TSchema extends StandardSchemaV1 = StandardSchemaV1<any>, TOutp
20
20
  outputSchema?: TOutputSchema;
21
21
  title?: string;
22
22
  annotations?: ToolAnnotations;
23
+ _meta?: Record<string, unknown>;
23
24
  enabled?: () => boolean | Promise<boolean>;
24
25
  execute: (
25
26
  input?: StandardSchemaV1.InferInput<TSchema>,
@@ -70,7 +71,7 @@ export type StoredResource =
70
71
  export type ServerOptions<TSchema extends StandardSchemaV1 | undefined> = {
71
72
  capabilities?: ServerCapabilities;
72
73
  instructions?: string;
73
- adapter: JsonSchemaAdapter<TSchema>;
74
+ adapter: JsonSchemaAdapter<TSchema> | undefined;
74
75
  pagination?: {
75
76
  resources?: { size?: number };
76
77
  prompts?: { size?: number };
@@ -96,9 +97,11 @@ export type SubscriptionsKeys = SubscriptionsKeysObj["with_args"];
96
97
  export type McpEvents = {
97
98
  send: (message: {
98
99
  request: JSONRPCRequest;
99
- context: {
100
- sessions?: string[] | undefined;
101
- };
100
+ }) => void;
101
+ broadcast: (message: {
102
+ request: JSONRPCRequest;
102
103
  }) => void;
103
104
  initialize: (initialize_request: InitializeRequestParams) => void;
105
+ subscription: (subscriptions_request: { uri: string }) => void;
106
+ loglevelchange: (change: { level: LoggingLevel }) => void;
104
107
  };
@@ -1,6 +1,6 @@
1
1
  declare module 'tmcp' {
2
2
  import type { StandardSchemaV1 } from '@standard-schema/spec';
3
- import type { JSONRPCRequest, JSONRPCServer, JSONRPCClient } from 'json-rpc-2.0';
3
+ import type { JSONRPCServer, JSONRPCClient, JSONRPCRequest } from 'json-rpc-2.0';
4
4
  import type { JSONSchema7 } from 'json-schema';
5
5
  import * as v from 'valibot';
6
6
  export class McpServer<StandardSchema extends StandardSchemaV1 | undefined = undefined, CustomContext extends Record<string, unknown> | undefined = undefined> {
@@ -23,6 +23,7 @@ declare module 'tmcp' {
23
23
  get ctx(): Context<CustomContext>;
24
24
  /**
25
25
  * Get the client information (name, version, etc.) of the client that initiated the current request...useful if you want to do something different based on the client.
26
+ * @deprecated Use `server.ctx.sessionInfo.clientInfo` instead.
26
27
  */
27
28
  currentClientInfo(): {
28
29
  icons?: {
@@ -37,6 +38,7 @@ declare module 'tmcp' {
37
38
  } | undefined;
38
39
  /**
39
40
  * Get the client capabilities of the client that initiated the current request, you can use this to verify the client support something before invoking the respective method.
41
+ * @deprecated Use `server.ctx.sessionInfo.clientCapabilities` instead.
40
42
  */
41
43
  currentClientCapabilities(): {
42
44
  experimental?: {} | undefined;
@@ -54,8 +56,9 @@ declare module 'tmcp' {
54
56
  *
55
57
  * Tools will be invoked by the LLM when it thinks it needs to use them, you can use the annotations to provide additional information about the tool, like what it does, how to use it, etc.
56
58
  * */
57
- tool<TSchema extends StandardSchema | undefined = undefined, TOutputSchema extends StandardSchema | undefined = undefined>({ name, description, title, schema, outputSchema, annotations, enabled, icons, }: {
59
+ tool<TSchema extends StandardSchema | undefined = undefined, TOutputSchema extends StandardSchema | undefined = undefined>({ name, description, title, schema, outputSchema, annotations, enabled, icons, _meta, }: {
58
60
  name: string;
61
+ _meta?: Record<string, any>;
59
62
  description: string;
60
63
  title?: string;
61
64
  enabled?: () => boolean | Promise<boolean>;
@@ -109,7 +112,7 @@ declare module 'tmcp' {
109
112
  * The main function that receive a JSONRpc message and either dispatch a `send` event or process the request.
110
113
  *
111
114
  * */
112
- receive(message: JSONRPCResponse | JSONRPCRequest, ctx?: Context<CustomContext>): ReturnType<JSONRPCServer["receive"]> | ReturnType<JSONRPCClient["receive"] | undefined>;
115
+ receive(message: JSONRPCMessage, ctx?: Context<CustomContext>): ReturnType<JSONRPCServer["receive"]> | ReturnType<JSONRPCClient["receive"] | undefined>;
113
116
  /**
114
117
  * Send a notification for subscriptions
115
118
  * */
@@ -182,10 +185,16 @@ declare module 'tmcp' {
182
185
  };
183
186
  export type Context<TCustom extends Record<string, unknown> | undefined = undefined> = {
184
187
  sessionId?: string | undefined;
188
+ sessionInfo?: {
189
+ clientCapabilities?: ClientCapabilities_1;
190
+ clientInfo?: ClientInfo_1;
191
+ logLevel?: LoggingLevel;
192
+ } | undefined;
185
193
  auth?: AuthInfo | undefined;
186
194
  custom?: TCustom | undefined;
187
195
  };
188
196
  export type Icons = Icons_1;
197
+ export type Subscriptions = Record<SubscriptionsKeys, string[]>;
189
198
  export type CallToolResult<TStructuredContent extends Record<string, unknown> | undefined> = CallToolResult_1<TStructuredContent>;
190
199
  export type ReadResourceResult = ReadResourceResult_1;
191
200
  export type GetPromptResult = GetPromptResult_1;
@@ -205,7 +214,7 @@ declare module 'tmcp' {
205
214
  type ServerOptions<TSchema extends StandardSchemaV1 | undefined> = {
206
215
  capabilities?: ServerCapabilities;
207
216
  instructions?: string;
208
- adapter: JsonSchemaAdapter<TSchema>;
217
+ adapter: JsonSchemaAdapter<TSchema> | undefined;
209
218
  pagination?: {
210
219
  resources?: { size?: number };
211
220
  prompts?: { size?: number };
@@ -222,29 +231,73 @@ declare module 'tmcp' {
222
231
  'resources': [];
223
232
  }
224
233
 
234
+ type SubscriptionsKeysObj = {
235
+ [K in keyof ChangedArgs as ChangedArgs[K]["length"] extends 0 ? "without_args" : "with_args"]: K
236
+ };
237
+
238
+ type SubscriptionsKeys = SubscriptionsKeysObj["with_args"];
239
+
225
240
  type McpEvents = {
226
241
  send: (message: {
227
242
  request: JSONRPCRequest;
228
- context: {
229
- sessions?: string[] | undefined;
230
- };
243
+ }) => void;
244
+ broadcast: (message: {
245
+ request: JSONRPCRequest;
231
246
  }) => void;
232
247
  initialize: (initialize_request: InitializeRequestParams) => void;
248
+ subscription: (subscriptions_request: { uri: string }) => void;
249
+ loglevelchange: (change: { level: LoggingLevel_1 }) => void;
233
250
  };
234
- /**
235
- * A successful (non-error) response to a request.
236
- */
237
- const JSONRPCResponseSchema: v.StrictObjectSchema<{
251
+ const JSONRPCMessageSchema: v.UnionSchema<[v.ObjectSchema<{
252
+ readonly method: v.StringSchema<undefined>;
253
+ readonly params: v.OptionalSchema<v.LooseObjectSchema<{
254
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{
255
+ /**
256
+ * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
257
+ */
258
+ readonly progressToken: v.OptionalSchema<v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>], undefined>, undefined>;
259
+ }, undefined>, undefined>;
260
+ }, undefined>, undefined>;
238
261
  readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
239
262
  readonly id: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>], undefined>;
240
- readonly result: v.ObjectSchema<{
263
+ }, undefined>, v.ObjectSchema<{
264
+ readonly method: v.StringSchema<undefined>;
265
+ readonly params: v.OptionalSchema<v.LooseObjectSchema<{
266
+ /**
267
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
268
+ * for notes on _meta usage.
269
+ */
270
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
271
+ }, undefined>, undefined>;
272
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
273
+ }, undefined>, v.StrictObjectSchema<{
274
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
275
+ readonly id: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>], undefined>;
276
+ readonly result: v.LooseObjectSchema<{
241
277
  /**
242
278
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
243
279
  * for notes on _meta usage.
244
280
  */
245
281
  readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
246
282
  }, undefined>;
247
- }, undefined>;
283
+ }, undefined>, v.StrictObjectSchema<{
284
+ readonly jsonrpc: v.LiteralSchema<"2.0", undefined>;
285
+ readonly id: v.UnionSchema<[v.StringSchema<undefined>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>], undefined>;
286
+ readonly error: v.ObjectSchema<{
287
+ /**
288
+ * The error type that occurred.
289
+ */
290
+ readonly code: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>;
291
+ /**
292
+ * A short description of the error. The message SHOULD be limited to a concise single sentence.
293
+ */
294
+ readonly message: v.StringSchema<undefined>;
295
+ /**
296
+ * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
297
+ */
298
+ readonly data: v.OptionalSchema<v.UnknownSchema, undefined>;
299
+ }, undefined>;
300
+ }, undefined>], undefined>;
248
301
  const IconsSchema: v.ObjectSchema<{
249
302
  /**
250
303
  * Optional set of sized icons that the client can display in a user interface.
@@ -1206,7 +1259,7 @@ declare module 'tmcp' {
1206
1259
  type CreateMessageRequestParams_1 = v.InferInput<typeof CreateMessageRequestParamsSchema>;
1207
1260
  type CreateMessageResult_1 = v.InferInput<typeof CreateMessageResultSchema>;
1208
1261
  type Resource_1 = v.InferInput<typeof ResourceSchema>;
1209
- type JSONRPCResponse = v.InferInput<typeof JSONRPCResponseSchema>;
1262
+ type JSONRPCMessage = v.InferInput<typeof JSONRPCMessageSchema>;
1210
1263
  type LoggingLevel_1 = v.InferInput<typeof LoggingLevelSchema>;
1211
1264
  type ToolAnnotations = v.InferInput<typeof ToolAnnotationsSchema>;
1212
1265
  type ElicitResult_1 = v.InferInput<typeof ElicitResultSchema>;
@@ -4,6 +4,7 @@
4
4
  "names": [
5
5
  "McpServer",
6
6
  "Icons",
7
+ "Subscriptions",
7
8
  "ReadResourceResult",
8
9
  "GetPromptResult",
9
10
  "ClientCapabilities",
@@ -17,8 +18,10 @@
17
18
  "Completion",
18
19
  "ServerOptions",
19
20
  "ChangedArgs",
21
+ "SubscriptionsKeysObj",
22
+ "SubscriptionsKeys",
20
23
  "McpEvents",
21
- "JSONRPCResponseSchema",
24
+ "JSONRPCMessageSchema",
22
25
  "IconsSchema",
23
26
  "ImplementationSchema",
24
27
  "ClientCapabilitiesSchema",
@@ -37,7 +40,7 @@
37
40
  "ServerCapabilities",
38
41
  "InitializeRequestParams",
39
42
  "CompleteResult",
40
- "JSONRPCResponse",
43
+ "JSONRPCMessage",
41
44
  "ToolAnnotations",
42
45
  "Trim",
43
46
  "ExtractVarName",
@@ -61,6 +64,6 @@
61
64
  null,
62
65
  null
63
66
  ],
64
- "mappings": ";;;;;cAoJaA,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aC81CyBC,KAAKA;;aAuBQC,kBAAkBA;aAGrBC,eAAeA;aAvBZC,kBAAkBA;aAUKC,UAAUA;aAmBzBC,0BAA0BA;aAGjCC,mBAAmBA;aAY9BC,QAAQA;aASJC,YAAYA;aA/CVC,UAAU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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8ChCC,yBAAyBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6GzBC,kBAAkBA;;;;;;;;;;;;;;;;;;OAkFlBC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;MAiI2BC,kBAAkBA;;;;;MAUbC,uBAAuBA;;;;;;;;;;;;;MAahCC,cAAcA;;;;MAwBdC,cAAcA;;MASbC,eAAeA;;;ME9iDnEC,IAAIA;;;;;;;MAOJC,cAAcA;;;;;;;MAOdC,cAAcA;;;;;MAKdC,qBAAqBA;;;;;;;;;;;;;;;;;MAiBrBC,4BAA4BA;;;;;;MAMrBC,2BAA2BA;;;;;;;OCjC1BC,iBAAiBA;;;;;;;;;;;;;;;;cAAjBA,iBAAiBA",
65
68
  "ignoreList": []
66
69
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable jsdoc/no-undefined-types */
2
1
  import * as v from 'valibot';
3
2
  export const LATEST_PROTOCOL_VERSION = '2025-06-18';
4
3
  export const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
@@ -62,7 +61,7 @@ export const NotificationSchema = v.object({
62
61
  method: v.string(),
63
62
  params: v.optional(BaseNotificationParamsSchema),
64
63
  });
65
- export const ResultSchema = v.object({
64
+ export const ResultSchema = v.looseObject({
66
65
  /**
67
66
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
68
67
  * for notes on _meta usage.
@@ -1572,6 +1571,9 @@ export const ServerResultSchema = v.union([
1572
1571
  /**
1573
1572
  * @typedef {v.InferInput<typeof JSONRPCRequestSchema>} JSONRPCRequest
1574
1573
  */
1574
+ /**
1575
+ * @typedef {v.InferInput<typeof JSONRPCMessageSchema>} JSONRPCMessage
1576
+ */
1575
1577
  /**
1576
1578
  * @typedef {v.InferInput<typeof JSONRPCResponseSchema>} JSONRPCResponse
1577
1579
  */