tmcp 1.6.2 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmcp",
3
- "version": "1.6.2",
3
+ "version": "1.7.0",
4
4
  "description": "The main tmcp library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/index.d.ts CHANGED
@@ -44,14 +44,15 @@ export class McpServer<StandardSchema extends StandardSchemaV1> {
44
44
  on<TEvent extends keyof McpEvents>(event: TEvent, callback: McpEvents[TEvent], options?: AddEventListenerOptions): void;
45
45
  /**
46
46
  * @template {StandardSchema | undefined} [TSchema=undefined]
47
- * @param {{ name: string; description: string; title?: 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; annotations?: ToolAnnotations }} options
48
48
  * @param {TSchema extends undefined ? (()=>Promise<CallToolResult> | CallToolResult) : ((input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<CallToolResult> | CallToolResult)} execute
49
49
  */
50
- tool<TSchema extends StandardSchema | undefined = undefined>({ name, description, title, schema }: {
50
+ tool<TSchema extends StandardSchema | undefined = undefined>({ name, description, title, schema, annotations }: {
51
51
  name: string;
52
52
  description: string;
53
53
  title?: string;
54
54
  schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never;
55
+ annotations?: ToolAnnotations;
55
56
  }, execute: TSchema extends undefined ? (() => Promise<CallToolResult> | CallToolResult) : ((input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<CallToolResult> | CallToolResult)): void;
56
57
  /**
57
58
  * @template {StandardSchema | undefined} [TSchema=undefined]
@@ -129,6 +130,7 @@ export class McpServer<StandardSchema extends StandardSchemaV1> {
129
130
  export type ClientCapabilities = ClientCapabilitiesType;
130
131
  import type { StandardSchemaV1 } from "@standard-schema/spec";
131
132
  import type { McpEvents } from "./internal/internal.js";
133
+ import type { ToolAnnotations } from "./validation/index.js";
132
134
  import type { CallToolResult } from "./validation/index.js";
133
135
  import type { Completion } from "./internal/internal.js";
134
136
  import type { GetPromptResult } from "./validation/index.js";
package/src/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * @import SqidsType from "sqids";
4
4
  * @import { JSONRPCRequest, JSONRPCParams } from "json-rpc-2.0";
5
5
  * @import { ExtractURITemplateVariables } from "./internal/uri-template.js";
6
- * @import { CallToolResult, ReadResourceResult, GetPromptResult, ClientCapabilities as ClientCapabilitiesType, JSONRPCRequest as JSONRPCRequestType, JSONRPCResponse, CreateMessageRequestParams, CreateMessageResult, Resource, LoggingLevel } from "./validation/index.js";
6
+ * @import { CallToolResult, ReadResourceResult, GetPromptResult, ClientCapabilities as ClientCapabilitiesType, JSONRPCRequest as JSONRPCRequestType, JSONRPCResponse, CreateMessageRequestParams, CreateMessageResult, Resource, LoggingLevel, ToolAnnotations } from "./validation/index.js";
7
7
  * @import { Tool, Completion, Prompt, StoredResource, ServerOptions, ServerInfo, SubscriptionsKeys, McpEvents } from "./internal/internal.js";
8
8
  */
9
9
  import { JSONRPCClient, JSONRPCServer } from 'json-rpc-2.0';
@@ -300,6 +300,7 @@ export class McpServer {
300
300
  name,
301
301
  title: tool.title || tool.description,
302
302
  description: tool.description,
303
+ annotations: tool.annotations,
303
304
  inputSchema: tool.schema
304
305
  ? await this.#options.adapter.toJsonSchema(
305
306
  tool.schema,
@@ -519,7 +520,10 @@ export class McpServer {
519
520
  }
520
521
  if (resource.template) {
521
522
  if (!params)
522
- throw new McpError(-32602, 'Missing parameters for template resource');
523
+ throw new McpError(
524
+ -32602,
525
+ 'Missing parameters for template resource',
526
+ );
523
527
  return v.parse(
524
528
  ReadResourceResultSchema,
525
529
  await resource.execute(uri, params),
@@ -595,10 +599,10 @@ export class McpServer {
595
599
  }
596
600
  /**
597
601
  * @template {StandardSchema | undefined} [TSchema=undefined]
598
- * @param {{ name: string; description: string; title?: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never }} options
602
+ * @param {{ name: string; description: string; title?: string; schema?: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema> extends Record<string, unknown> ? TSchema : never; annotations?: ToolAnnotations }} options
599
603
  * @param {TSchema extends undefined ? (()=>Promise<CallToolResult> | CallToolResult) : ((input: StandardSchemaV1.InferInput<TSchema extends undefined ? never : TSchema>) => Promise<CallToolResult> | CallToolResult)} execute
600
604
  */
601
- tool({ name, description, title, schema }, execute) {
605
+ tool({ name, description, title, schema, annotations }, execute) {
602
606
  if (this.#options.capabilities?.tools?.listChanged) {
603
607
  this.#notify('notifications/tools/list_changed', {});
604
608
  }
@@ -607,6 +611,7 @@ export class McpServer {
607
611
  title,
608
612
  schema,
609
613
  execute,
614
+ annotations,
610
615
  });
611
616
  }
612
617
  /**
@@ -9,13 +9,15 @@ import {
9
9
  InitializeRequestParams,
10
10
  Resource,
11
11
  ServerCapabilities,
12
- LoggingLevel
12
+ LoggingLevel,
13
+ ToolAnnotations
13
14
  } from '../validation/index.js';
14
15
 
15
16
  export type Tool<TSchema extends StandardSchemaV1 = StandardSchemaV1<any>> = {
16
17
  description: string;
17
18
  schema: TSchema;
18
19
  title?: string;
20
+ annotations?: ToolAnnotations;
19
21
  execute: (
20
22
  input?: StandardSchemaV1.InferInput<TSchema>,
21
23
  ) => Promise<CallToolResult> | CallToolResult;
@@ -4315,4 +4315,5 @@ export type Resource = v.InferInput<typeof ResourceSchema>;
4315
4315
  export type JSONRPCRequest = v.InferInput<typeof JSONRPCRequestSchema>;
4316
4316
  export type JSONRPCResponse = v.InferInput<typeof JSONRPCResponseSchema>;
4317
4317
  export type LoggingLevel = v.InferInput<typeof LoggingLevelSchema>;
4318
+ export type ToolAnnotations = v.InferInput<typeof ToolAnnotationsSchema>;
4318
4319
  import * as v from 'valibot';
@@ -1530,3 +1530,6 @@ export const ServerResultSchema = v.union([
1530
1530
  /**
1531
1531
  * @typedef {v.InferInput<typeof LoggingLevelSchema>} LoggingLevel
1532
1532
  */
1533
+ /**
1534
+ * @typedef {v.InferInput<typeof ToolAnnotationsSchema>} ToolAnnotations
1535
+ */