tmcp 1.16.2 → 1.16.3
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/package.json +1 -1
- package/src/index.js +12 -15
- package/src/internal/internal.d.ts +1 -1
- package/src/internal/utils.js +12 -0
- package/src/types/index.d.ts +1 -1
- package/src/types/index.d.ts.map +1 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
negotiate_protocol_version,
|
|
32
32
|
} from './validation/version.js';
|
|
33
33
|
import { should_version_negotiation_fail } from './validation/version.js';
|
|
34
|
+
import { event } from './internal/utils.js';
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Information about a validated access token, provided to request handlers.
|
|
@@ -248,9 +249,7 @@ export class McpServer {
|
|
|
248
249
|
|
|
249
250
|
// Dispatch initialization event
|
|
250
251
|
this.#event_target.dispatchEvent(
|
|
251
|
-
|
|
252
|
-
detail: validated_initialize,
|
|
253
|
-
}),
|
|
252
|
+
event('initialize', validated_initialize),
|
|
254
253
|
);
|
|
255
254
|
|
|
256
255
|
// Return server response with negotiated version and capabilities
|
|
@@ -352,16 +351,12 @@ export class McpServer {
|
|
|
352
351
|
this.#client = new JSONRPCClient((payload, kind) => {
|
|
353
352
|
if (kind === 'broadcast') {
|
|
354
353
|
this.#event_target.dispatchEvent(
|
|
355
|
-
|
|
356
|
-
detail: { request: payload },
|
|
357
|
-
}),
|
|
354
|
+
event('broadcast', { request: payload }),
|
|
358
355
|
);
|
|
359
356
|
return;
|
|
360
357
|
}
|
|
361
358
|
this.#event_target.dispatchEvent(
|
|
362
|
-
|
|
363
|
-
detail: { request: payload },
|
|
364
|
-
}),
|
|
359
|
+
event('send', { request: payload }),
|
|
365
360
|
);
|
|
366
361
|
});
|
|
367
362
|
}
|
|
@@ -636,9 +631,13 @@ export class McpServer {
|
|
|
636
631
|
if (this.#options.capabilities?.resources?.subscribe) {
|
|
637
632
|
this.#server.addMethod('resources/subscribe', async ({ uri }) => {
|
|
638
633
|
this.#event_target.dispatchEvent(
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
634
|
+
event('subscription', { uri, action: 'add' }),
|
|
635
|
+
);
|
|
636
|
+
return {};
|
|
637
|
+
});
|
|
638
|
+
this.#server.addMethod('resources/unsubscribe', async ({ uri }) => {
|
|
639
|
+
this.#event_target.dispatchEvent(
|
|
640
|
+
event('subscription', { uri, action: 'remove' }),
|
|
642
641
|
);
|
|
643
642
|
return {};
|
|
644
643
|
});
|
|
@@ -815,9 +814,7 @@ export class McpServer {
|
|
|
815
814
|
|
|
816
815
|
this.#server.addMethod('logging/setLevel', ({ level }) => {
|
|
817
816
|
this.#event_target.dispatchEvent(
|
|
818
|
-
|
|
819
|
-
detail: { level },
|
|
820
|
-
}),
|
|
817
|
+
event('loglevelchange', { level }),
|
|
821
818
|
);
|
|
822
819
|
return {};
|
|
823
820
|
});
|
|
@@ -102,6 +102,6 @@ export type McpEvents = {
|
|
|
102
102
|
request: JSONRPCRequest;
|
|
103
103
|
}) => void;
|
|
104
104
|
initialize: (initialize_request: InitializeRequestParams) => void;
|
|
105
|
-
subscription: (subscriptions_request: { uri: string }) => void;
|
|
105
|
+
subscription: (subscriptions_request: { uri: string, action?: "add" | "remove" }) => void;
|
|
106
106
|
loglevelchange: (change: { level: LoggingLevel }) => void;
|
|
107
107
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import {McpEvents} from "./internal.js"
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @template {keyof McpEvents} Key
|
|
6
|
+
* @param {Key} type
|
|
7
|
+
* @param {Parameters<McpEvents[Key]>[0]} detail
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export function event(type, detail) {
|
|
11
|
+
return new CustomEvent(type, { detail });
|
|
12
|
+
}
|
package/src/types/index.d.ts
CHANGED
|
@@ -251,7 +251,7 @@ declare module 'tmcp' {
|
|
|
251
251
|
request: JSONRPCRequest;
|
|
252
252
|
}) => void;
|
|
253
253
|
initialize: (initialize_request: InitializeRequestParams) => void;
|
|
254
|
-
subscription: (subscriptions_request: { uri: string }) => void;
|
|
254
|
+
subscription: (subscriptions_request: { uri: string, action?: "add" | "remove" }) => void;
|
|
255
255
|
loglevelchange: (change: { level: LoggingLevel_1 }) => void;
|
|
256
256
|
};
|
|
257
257
|
const JSONRPCMessageSchema: v.UnionSchema<[v.ObjectSchema<{
|
package/src/types/index.d.ts.map
CHANGED
|
@@ -74,6 +74,6 @@
|
|
|
74
74
|
null,
|
|
75
75
|
null
|
|
76
76
|
],
|
|
77
|
-
"mappings": ";;;;;
|
|
77
|
+
"mappings": ";;;;;cAiLaA,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aCg0CyBC,KAAKA;aDn7CFC,aAAaA;;aC08CHC,kBAAkBA;aAGrBC,eAAeA;aAvBZC,kBAAkBA;aAUKC,UAAUA;aAmBzBC,0BAA0BA;aAGjCC,mBAAmBA;aAY9BC,QAAQA;aAYJC,YAAYA;aAlDVC,UAAUA;aAwDZC,YAAYA;aAGRC,gBAAgBA;aAGjBC,eAAeA;aAGbC,iBAAiBA;aAMPC,2BAA2BA;aAHnCC,mBAAmBA;aAhDxBC,cAAcA;MCj/C1DC,UAAUA;;;;;MAyCVC,aAAaA;;;;;;;;;;;;;MAabC,WAAWA;;;;;;;MAOlBC,oBAAoBA;;;;MAIbC,iBAAiBA;;MAEjBC,SAASA;;;;;;;;;;;ODgCRC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmFpBC,W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