tmcp 1.7.0 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmcp",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "The main tmcp library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -36,10 +36,11 @@
36
36
  "@standard-schema/spec": "^1.0.0",
37
37
  "@types/json-schema": "^7.0.15",
38
38
  "@types/node": "^24.0.13",
39
- "publint": "^0.3.12"
39
+ "publint": "^0.3.12",
40
+ "vitest": "^3.2.4"
40
41
  },
41
42
  "scripts": {
42
- "test": "echo \"Error: no test specified\" && exit 1",
43
+ "test": "vitest",
43
44
  "typecheck": "tsc --noEmit",
44
45
  "generate:types": "find ./src -name \"*.d.ts\" -not -path \"./src/internal/*\" -delete && tsc ./src/*.js --declaration --emitDeclarationOnly --target esnext --allowJs --moduleresolution nodenext --module nodenext && publint",
45
46
  "prepublish": "pnpm generate:types"
package/src/index.d.ts CHANGED
@@ -41,7 +41,7 @@ export class McpServer<StandardSchema extends StandardSchemaV1> {
41
41
  * @param {McpEvents[TEvent]} callback
42
42
  * @param {AddEventListenerOptions} [options]
43
43
  */
44
- on<TEvent extends keyof McpEvents>(event: TEvent, callback: McpEvents[TEvent], options?: AddEventListenerOptions): void;
44
+ on<TEvent extends keyof McpEvents>(event: TEvent, callback: McpEvents[TEvent], options?: AddEventListenerOptions): () => void;
45
45
  /**
46
46
  * @template {StandardSchema | undefined} [TSchema=undefined]
47
47
  * @param {{ name: string; description: string; title?: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never; annotations?: ToolAnnotations }} options
package/src/index.js CHANGED
@@ -270,13 +270,18 @@ export class McpServer {
270
270
  this.#lazyily_create_client();
271
271
  }
272
272
 
273
- this.#event_target.addEventListener(
274
- event,
275
- (e) => {
276
- callback(/** @type {CustomEvent} */ (e).detail);
277
- },
278
- options,
279
- );
273
+ /**
274
+ * @param {Event} e
275
+ */
276
+ const listener = (e) => {
277
+ callback(/** @type {CustomEvent} */ (e).detail);
278
+ };
279
+
280
+ this.#event_target.addEventListener(event, listener, options);
281
+
282
+ return () => {
283
+ this.#event_target.removeEventListener(event, listener, options);
284
+ };
280
285
  }
281
286
 
282
287
  /**