@ai-sdk/mcp 0.0.5 → 0.0.7
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 +14 -0
- package/dist/index.d.mts +55 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -0
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +26 -0
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +26 -0
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -172,6 +172,32 @@ var ReadResourceResultSchema = ResultSchema.extend({
|
|
|
172
172
|
z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
173
173
|
)
|
|
174
174
|
});
|
|
175
|
+
var PromptArgumentSchema = z.object({
|
|
176
|
+
name: z.string(),
|
|
177
|
+
description: z.optional(z.string()),
|
|
178
|
+
required: z.optional(z.boolean())
|
|
179
|
+
}).loose();
|
|
180
|
+
var PromptSchema = z.object({
|
|
181
|
+
name: z.string(),
|
|
182
|
+
title: z.optional(z.string()),
|
|
183
|
+
description: z.optional(z.string()),
|
|
184
|
+
arguments: z.optional(z.array(PromptArgumentSchema))
|
|
185
|
+
}).loose();
|
|
186
|
+
var ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
187
|
+
prompts: z.array(PromptSchema)
|
|
188
|
+
});
|
|
189
|
+
var PromptMessageSchema = z.object({
|
|
190
|
+
role: z.union([z.literal("user"), z.literal("assistant")]),
|
|
191
|
+
content: z.union([
|
|
192
|
+
TextContentSchema,
|
|
193
|
+
ImageContentSchema,
|
|
194
|
+
EmbeddedResourceSchema
|
|
195
|
+
])
|
|
196
|
+
}).loose();
|
|
197
|
+
var GetPromptResultSchema = ResultSchema.extend({
|
|
198
|
+
description: z.optional(z.string()),
|
|
199
|
+
messages: z.array(PromptMessageSchema)
|
|
200
|
+
});
|
|
175
201
|
|
|
176
202
|
// src/tool/json-rpc-message.ts
|
|
177
203
|
var JSONRPC_VERSION = "2.0";
|
|
@@ -1586,6 +1612,14 @@ var DefaultMCPClient = class {
|
|
|
1586
1612
|
});
|
|
1587
1613
|
}
|
|
1588
1614
|
break;
|
|
1615
|
+
case "prompts/list":
|
|
1616
|
+
case "prompts/get":
|
|
1617
|
+
if (!this.serverCapabilities.prompts) {
|
|
1618
|
+
throw new MCPClientError({
|
|
1619
|
+
message: `Server does not support prompts`
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
break;
|
|
1589
1623
|
default:
|
|
1590
1624
|
throw new MCPClientError({
|
|
1591
1625
|
message: `Unsupported method: ${method}`
|
|
@@ -1718,6 +1752,35 @@ var DefaultMCPClient = class {
|
|
|
1718
1752
|
throw error;
|
|
1719
1753
|
}
|
|
1720
1754
|
}
|
|
1755
|
+
async listPromptsInternal({
|
|
1756
|
+
params,
|
|
1757
|
+
options
|
|
1758
|
+
} = {}) {
|
|
1759
|
+
try {
|
|
1760
|
+
return this.request({
|
|
1761
|
+
request: { method: "prompts/list", params },
|
|
1762
|
+
resultSchema: ListPromptsResultSchema,
|
|
1763
|
+
options
|
|
1764
|
+
});
|
|
1765
|
+
} catch (error) {
|
|
1766
|
+
throw error;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
async getPromptInternal({
|
|
1770
|
+
name: name3,
|
|
1771
|
+
args,
|
|
1772
|
+
options
|
|
1773
|
+
}) {
|
|
1774
|
+
try {
|
|
1775
|
+
return this.request({
|
|
1776
|
+
request: { method: "prompts/get", params: { name: name3, arguments: args } },
|
|
1777
|
+
resultSchema: GetPromptResultSchema,
|
|
1778
|
+
options
|
|
1779
|
+
});
|
|
1780
|
+
} catch (error) {
|
|
1781
|
+
throw error;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1721
1784
|
async notification(notification) {
|
|
1722
1785
|
const jsonrpcNotification = {
|
|
1723
1786
|
...notification,
|
|
@@ -1783,6 +1846,19 @@ var DefaultMCPClient = class {
|
|
|
1783
1846
|
} = {}) {
|
|
1784
1847
|
return this.listResourceTemplatesInternal({ options });
|
|
1785
1848
|
}
|
|
1849
|
+
listPrompts({
|
|
1850
|
+
params,
|
|
1851
|
+
options
|
|
1852
|
+
} = {}) {
|
|
1853
|
+
return this.listPromptsInternal({ params, options });
|
|
1854
|
+
}
|
|
1855
|
+
getPrompt({
|
|
1856
|
+
name: name3,
|
|
1857
|
+
arguments: args,
|
|
1858
|
+
options
|
|
1859
|
+
}) {
|
|
1860
|
+
return this.getPromptInternal({ name: name3, args, options });
|
|
1861
|
+
}
|
|
1786
1862
|
onClose() {
|
|
1787
1863
|
if (this.isClosed) return;
|
|
1788
1864
|
this.isClosed = true;
|