@ai-sdk/mcp 0.0.4 → 0.0.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 0.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 1cba565: feat(packages/mcp): add support for MCP server prompts exposed
8
+
9
+ ## 0.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [f2da310]
14
+ - @ai-sdk/provider-utils@3.0.15
15
+
3
16
  ## 0.0.4
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -347,6 +347,52 @@ declare const ReadResourceResultSchema: z.ZodObject<{
347
347
  }, z.core.$loose>]>>;
348
348
  }, z.core.$loose>;
349
349
  type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
350
+ declare const ListPromptsResultSchema: z.ZodObject<{
351
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
352
+ nextCursor: z.ZodOptional<z.ZodString>;
353
+ prompts: z.ZodArray<z.ZodObject<{
354
+ name: z.ZodString;
355
+ title: z.ZodOptional<z.ZodString>;
356
+ description: z.ZodOptional<z.ZodString>;
357
+ arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
358
+ name: z.ZodString;
359
+ description: z.ZodOptional<z.ZodString>;
360
+ required: z.ZodOptional<z.ZodBoolean>;
361
+ }, z.core.$loose>>>;
362
+ }, z.core.$loose>>;
363
+ }, z.core.$loose>;
364
+ type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
365
+ declare const GetPromptResultSchema: z.ZodObject<{
366
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
367
+ description: z.ZodOptional<z.ZodString>;
368
+ messages: z.ZodArray<z.ZodObject<{
369
+ role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
370
+ content: z.ZodUnion<readonly [z.ZodObject<{
371
+ type: z.ZodLiteral<"text">;
372
+ text: z.ZodString;
373
+ }, z.core.$loose>, z.ZodObject<{
374
+ type: z.ZodLiteral<"image">;
375
+ data: z.ZodBase64;
376
+ mimeType: z.ZodString;
377
+ }, z.core.$loose>, z.ZodObject<{
378
+ type: z.ZodLiteral<"resource">;
379
+ resource: z.ZodUnion<readonly [z.ZodObject<{
380
+ uri: z.ZodString;
381
+ name: z.ZodOptional<z.ZodString>;
382
+ title: z.ZodOptional<z.ZodString>;
383
+ mimeType: z.ZodOptional<z.ZodString>;
384
+ text: z.ZodString;
385
+ }, z.core.$loose>, z.ZodObject<{
386
+ uri: z.ZodString;
387
+ name: z.ZodOptional<z.ZodString>;
388
+ title: z.ZodOptional<z.ZodString>;
389
+ mimeType: z.ZodOptional<z.ZodString>;
390
+ blob: z.ZodBase64;
391
+ }, z.core.$loose>]>;
392
+ }, z.core.$loose>]>;
393
+ }, z.core.$loose>>;
394
+ }, z.core.$loose>;
395
+ type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
350
396
 
351
397
  interface MCPClientConfig {
352
398
  /** Transport configuration for connecting to the MCP server */
@@ -372,6 +418,15 @@ interface MCPClient {
372
418
  listResourceTemplates(options?: {
373
419
  options?: RequestOptions;
374
420
  }): Promise<ListResourceTemplatesResult>;
421
+ listPrompts(options?: {
422
+ params?: PaginatedRequest['params'];
423
+ options?: RequestOptions;
424
+ }): Promise<ListPromptsResult>;
425
+ getPrompt(args: {
426
+ name: string;
427
+ arguments?: Record<string, unknown>;
428
+ options?: RequestOptions;
429
+ }): Promise<GetPromptResult>;
375
430
  close: () => Promise<void>;
376
431
  }
377
432
 
package/dist/index.d.ts CHANGED
@@ -347,6 +347,52 @@ declare const ReadResourceResultSchema: z.ZodObject<{
347
347
  }, z.core.$loose>]>>;
348
348
  }, z.core.$loose>;
349
349
  type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
350
+ declare const ListPromptsResultSchema: z.ZodObject<{
351
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
352
+ nextCursor: z.ZodOptional<z.ZodString>;
353
+ prompts: z.ZodArray<z.ZodObject<{
354
+ name: z.ZodString;
355
+ title: z.ZodOptional<z.ZodString>;
356
+ description: z.ZodOptional<z.ZodString>;
357
+ arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
358
+ name: z.ZodString;
359
+ description: z.ZodOptional<z.ZodString>;
360
+ required: z.ZodOptional<z.ZodBoolean>;
361
+ }, z.core.$loose>>>;
362
+ }, z.core.$loose>>;
363
+ }, z.core.$loose>;
364
+ type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
365
+ declare const GetPromptResultSchema: z.ZodObject<{
366
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
367
+ description: z.ZodOptional<z.ZodString>;
368
+ messages: z.ZodArray<z.ZodObject<{
369
+ role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
370
+ content: z.ZodUnion<readonly [z.ZodObject<{
371
+ type: z.ZodLiteral<"text">;
372
+ text: z.ZodString;
373
+ }, z.core.$loose>, z.ZodObject<{
374
+ type: z.ZodLiteral<"image">;
375
+ data: z.ZodBase64;
376
+ mimeType: z.ZodString;
377
+ }, z.core.$loose>, z.ZodObject<{
378
+ type: z.ZodLiteral<"resource">;
379
+ resource: z.ZodUnion<readonly [z.ZodObject<{
380
+ uri: z.ZodString;
381
+ name: z.ZodOptional<z.ZodString>;
382
+ title: z.ZodOptional<z.ZodString>;
383
+ mimeType: z.ZodOptional<z.ZodString>;
384
+ text: z.ZodString;
385
+ }, z.core.$loose>, z.ZodObject<{
386
+ uri: z.ZodString;
387
+ name: z.ZodOptional<z.ZodString>;
388
+ title: z.ZodOptional<z.ZodString>;
389
+ mimeType: z.ZodOptional<z.ZodString>;
390
+ blob: z.ZodBase64;
391
+ }, z.core.$loose>]>;
392
+ }, z.core.$loose>]>;
393
+ }, z.core.$loose>>;
394
+ }, z.core.$loose>;
395
+ type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
350
396
 
351
397
  interface MCPClientConfig {
352
398
  /** Transport configuration for connecting to the MCP server */
@@ -372,6 +418,15 @@ interface MCPClient {
372
418
  listResourceTemplates(options?: {
373
419
  options?: RequestOptions;
374
420
  }): Promise<ListResourceTemplatesResult>;
421
+ listPrompts(options?: {
422
+ params?: PaginatedRequest['params'];
423
+ options?: RequestOptions;
424
+ }): Promise<ListPromptsResult>;
425
+ getPrompt(args: {
426
+ name: string;
427
+ arguments?: Record<string, unknown>;
428
+ options?: RequestOptions;
429
+ }): Promise<GetPromptResult>;
375
430
  close: () => Promise<void>;
376
431
  }
377
432
 
package/dist/index.js CHANGED
@@ -202,6 +202,32 @@ var ReadResourceResultSchema = ResultSchema.extend({
202
202
  import_v4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
203
203
  )
204
204
  });
205
+ var PromptArgumentSchema = import_v4.z.object({
206
+ name: import_v4.z.string(),
207
+ description: import_v4.z.optional(import_v4.z.string()),
208
+ required: import_v4.z.optional(import_v4.z.boolean())
209
+ }).loose();
210
+ var PromptSchema = import_v4.z.object({
211
+ name: import_v4.z.string(),
212
+ title: import_v4.z.optional(import_v4.z.string()),
213
+ description: import_v4.z.optional(import_v4.z.string()),
214
+ arguments: import_v4.z.optional(import_v4.z.array(PromptArgumentSchema))
215
+ }).loose();
216
+ var ListPromptsResultSchema = PaginatedResultSchema.extend({
217
+ prompts: import_v4.z.array(PromptSchema)
218
+ });
219
+ var PromptMessageSchema = import_v4.z.object({
220
+ role: import_v4.z.union([import_v4.z.literal("user"), import_v4.z.literal("assistant")]),
221
+ content: import_v4.z.union([
222
+ TextContentSchema,
223
+ ImageContentSchema,
224
+ EmbeddedResourceSchema
225
+ ])
226
+ }).loose();
227
+ var GetPromptResultSchema = ResultSchema.extend({
228
+ description: import_v4.z.optional(import_v4.z.string()),
229
+ messages: import_v4.z.array(PromptMessageSchema)
230
+ });
205
231
 
206
232
  // src/tool/json-rpc-message.ts
207
233
  var JSONRPC_VERSION = "2.0";
@@ -1612,6 +1638,14 @@ var DefaultMCPClient = class {
1612
1638
  });
1613
1639
  }
1614
1640
  break;
1641
+ case "prompts/list":
1642
+ case "prompts/get":
1643
+ if (!this.serverCapabilities.prompts) {
1644
+ throw new MCPClientError({
1645
+ message: `Server does not support prompts`
1646
+ });
1647
+ }
1648
+ break;
1615
1649
  default:
1616
1650
  throw new MCPClientError({
1617
1651
  message: `Unsupported method: ${method}`
@@ -1744,6 +1778,35 @@ var DefaultMCPClient = class {
1744
1778
  throw error;
1745
1779
  }
1746
1780
  }
1781
+ async listPromptsInternal({
1782
+ params,
1783
+ options
1784
+ } = {}) {
1785
+ try {
1786
+ return this.request({
1787
+ request: { method: "prompts/list", params },
1788
+ resultSchema: ListPromptsResultSchema,
1789
+ options
1790
+ });
1791
+ } catch (error) {
1792
+ throw error;
1793
+ }
1794
+ }
1795
+ async getPromptInternal({
1796
+ name: name3,
1797
+ args,
1798
+ options
1799
+ }) {
1800
+ try {
1801
+ return this.request({
1802
+ request: { method: "prompts/get", params: { name: name3, arguments: args } },
1803
+ resultSchema: GetPromptResultSchema,
1804
+ options
1805
+ });
1806
+ } catch (error) {
1807
+ throw error;
1808
+ }
1809
+ }
1747
1810
  async notification(notification) {
1748
1811
  const jsonrpcNotification = {
1749
1812
  ...notification,
@@ -1809,6 +1872,19 @@ var DefaultMCPClient = class {
1809
1872
  } = {}) {
1810
1873
  return this.listResourceTemplatesInternal({ options });
1811
1874
  }
1875
+ listPrompts({
1876
+ params,
1877
+ options
1878
+ } = {}) {
1879
+ return this.listPromptsInternal({ params, options });
1880
+ }
1881
+ getPrompt({
1882
+ name: name3,
1883
+ arguments: args,
1884
+ options
1885
+ }) {
1886
+ return this.getPromptInternal({ name: name3, args, options });
1887
+ }
1812
1888
  onClose() {
1813
1889
  if (this.isClosed) return;
1814
1890
  this.isClosed = true;