@ai-sdk/mcp 1.0.0-beta.1 → 1.0.0-beta.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/CHANGELOG.md +13 -0
- package/dist/index.d.mts +77 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +101 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -0
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-stdio/index.js +34 -0
- package/dist/mcp-stdio/index.js.map +1 -1
- package/dist/mcp-stdio/index.mjs +34 -0
- package/dist/mcp-stdio/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -113,11 +113,30 @@ var ImageContentSchema = z.object({
|
|
|
113
113
|
data: z.base64(),
|
|
114
114
|
mimeType: z.string()
|
|
115
115
|
}).loose();
|
|
116
|
+
var ResourceSchema = z.object({
|
|
117
|
+
uri: z.string(),
|
|
118
|
+
name: z.string(),
|
|
119
|
+
title: z.optional(z.string()),
|
|
120
|
+
description: z.optional(z.string()),
|
|
121
|
+
mimeType: z.optional(z.string()),
|
|
122
|
+
size: z.optional(z.number())
|
|
123
|
+
}).loose();
|
|
124
|
+
var ListResourcesResultSchema = PaginatedResultSchema.extend({
|
|
125
|
+
resources: z.array(ResourceSchema)
|
|
126
|
+
});
|
|
116
127
|
var ResourceContentsSchema = z.object({
|
|
117
128
|
/**
|
|
118
129
|
* The URI of this resource.
|
|
119
130
|
*/
|
|
120
131
|
uri: z.string(),
|
|
132
|
+
/**
|
|
133
|
+
* Optional display name of the resource content.
|
|
134
|
+
*/
|
|
135
|
+
name: z.optional(z.string()),
|
|
136
|
+
/**
|
|
137
|
+
* Optional human readable title.
|
|
138
|
+
*/
|
|
139
|
+
title: z.optional(z.string()),
|
|
121
140
|
/**
|
|
122
141
|
* The MIME type of this resource, if known.
|
|
123
142
|
*/
|
|
@@ -143,6 +162,21 @@ var CallToolResultSchema = ResultSchema.extend({
|
|
|
143
162
|
toolResult: z.unknown()
|
|
144
163
|
})
|
|
145
164
|
);
|
|
165
|
+
var ResourceTemplateSchema = z.object({
|
|
166
|
+
uriTemplate: z.string(),
|
|
167
|
+
name: z.string(),
|
|
168
|
+
title: z.optional(z.string()),
|
|
169
|
+
description: z.optional(z.string()),
|
|
170
|
+
mimeType: z.optional(z.string())
|
|
171
|
+
}).loose();
|
|
172
|
+
var ListResourceTemplatesResultSchema = ResultSchema.extend({
|
|
173
|
+
resourceTemplates: z.array(ResourceTemplateSchema)
|
|
174
|
+
});
|
|
175
|
+
var ReadResourceResultSchema = ResultSchema.extend({
|
|
176
|
+
contents: z.array(
|
|
177
|
+
z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
178
|
+
)
|
|
179
|
+
});
|
|
146
180
|
|
|
147
181
|
// src/tool/json-rpc-message.ts
|
|
148
182
|
var JSONRPC_VERSION = "2.0";
|
|
@@ -1548,6 +1582,15 @@ var DefaultMCPClient = class {
|
|
|
1548
1582
|
});
|
|
1549
1583
|
}
|
|
1550
1584
|
break;
|
|
1585
|
+
case "resources/list":
|
|
1586
|
+
case "resources/read":
|
|
1587
|
+
case "resources/templates/list":
|
|
1588
|
+
if (!this.serverCapabilities.resources) {
|
|
1589
|
+
throw new MCPClientError({
|
|
1590
|
+
message: `Server does not support resources`
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
break;
|
|
1551
1594
|
default:
|
|
1552
1595
|
throw new MCPClientError({
|
|
1553
1596
|
message: `Unsupported method: ${method}`
|
|
@@ -1639,6 +1682,47 @@ var DefaultMCPClient = class {
|
|
|
1639
1682
|
throw error;
|
|
1640
1683
|
}
|
|
1641
1684
|
}
|
|
1685
|
+
async listResourcesInternal({
|
|
1686
|
+
params,
|
|
1687
|
+
options
|
|
1688
|
+
} = {}) {
|
|
1689
|
+
try {
|
|
1690
|
+
return this.request({
|
|
1691
|
+
request: { method: "resources/list", params },
|
|
1692
|
+
resultSchema: ListResourcesResultSchema,
|
|
1693
|
+
options
|
|
1694
|
+
});
|
|
1695
|
+
} catch (error) {
|
|
1696
|
+
throw error;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
async readResourceInternal({
|
|
1700
|
+
uri,
|
|
1701
|
+
options
|
|
1702
|
+
}) {
|
|
1703
|
+
try {
|
|
1704
|
+
return this.request({
|
|
1705
|
+
request: { method: "resources/read", params: { uri } },
|
|
1706
|
+
resultSchema: ReadResourceResultSchema,
|
|
1707
|
+
options
|
|
1708
|
+
});
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
throw error;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
async listResourceTemplatesInternal({
|
|
1714
|
+
options
|
|
1715
|
+
} = {}) {
|
|
1716
|
+
try {
|
|
1717
|
+
return this.request({
|
|
1718
|
+
request: { method: "resources/templates/list" },
|
|
1719
|
+
resultSchema: ListResourceTemplatesResultSchema,
|
|
1720
|
+
options
|
|
1721
|
+
});
|
|
1722
|
+
} catch (error) {
|
|
1723
|
+
throw error;
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1642
1726
|
async notification(notification) {
|
|
1643
1727
|
const jsonrpcNotification = {
|
|
1644
1728
|
...notification,
|
|
@@ -1695,6 +1779,23 @@ var DefaultMCPClient = class {
|
|
|
1695
1779
|
throw error;
|
|
1696
1780
|
}
|
|
1697
1781
|
}
|
|
1782
|
+
listResources({
|
|
1783
|
+
params,
|
|
1784
|
+
options
|
|
1785
|
+
} = {}) {
|
|
1786
|
+
return this.listResourcesInternal({ params, options });
|
|
1787
|
+
}
|
|
1788
|
+
readResource({
|
|
1789
|
+
uri,
|
|
1790
|
+
options
|
|
1791
|
+
}) {
|
|
1792
|
+
return this.readResourceInternal({ uri, options });
|
|
1793
|
+
}
|
|
1794
|
+
listResourceTemplates({
|
|
1795
|
+
options
|
|
1796
|
+
} = {}) {
|
|
1797
|
+
return this.listResourceTemplatesInternal({ options });
|
|
1798
|
+
}
|
|
1698
1799
|
onClose() {
|
|
1699
1800
|
if (this.isClosed) return;
|
|
1700
1801
|
this.isClosed = true;
|