@ai-sdk/mcp 1.0.14 → 1.0.16
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.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/src/tool/mcp-client.ts +36 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d022fd: fix(mcp): support image returns in tool results
|
|
8
|
+
|
|
9
|
+
## 1.0.15
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [2810850]
|
|
14
|
+
- @ai-sdk/provider-utils@4.0.11
|
|
15
|
+
- @ai-sdk/provider@3.0.6
|
|
16
|
+
|
|
3
17
|
## 1.0.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1587,6 +1587,30 @@ function isCustomMcpTransport(transport) {
|
|
|
1587
1587
|
|
|
1588
1588
|
// src/tool/mcp-client.ts
|
|
1589
1589
|
var CLIENT_VERSION = "1.0.0";
|
|
1590
|
+
function mcpToModelOutput({
|
|
1591
|
+
output
|
|
1592
|
+
}) {
|
|
1593
|
+
const result = output;
|
|
1594
|
+
if (!("content" in result) || !Array.isArray(result.content)) {
|
|
1595
|
+
return { type: "json", value: result };
|
|
1596
|
+
}
|
|
1597
|
+
const convertedContent = result.content.map(
|
|
1598
|
+
(part) => {
|
|
1599
|
+
if (part.type === "text" && "text" in part) {
|
|
1600
|
+
return { type: "text", text: part.text };
|
|
1601
|
+
}
|
|
1602
|
+
if (part.type === "image" && "data" in part && "mimeType" in part) {
|
|
1603
|
+
return {
|
|
1604
|
+
type: "image-data",
|
|
1605
|
+
data: part.data,
|
|
1606
|
+
mediaType: part.mimeType
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
return { type: "text", text: JSON.stringify(part) };
|
|
1610
|
+
}
|
|
1611
|
+
);
|
|
1612
|
+
return { type: "content", value: convertedContent };
|
|
1613
|
+
}
|
|
1590
1614
|
async function createMCPClient(config) {
|
|
1591
1615
|
const client = new DefaultMCPClient(config);
|
|
1592
1616
|
await client.init();
|
|
@@ -1913,13 +1937,15 @@ var DefaultMCPClient = class {
|
|
|
1913
1937
|
properties: (_b3 = inputSchema.properties) != null ? _b3 : {},
|
|
1914
1938
|
additionalProperties: false
|
|
1915
1939
|
}),
|
|
1916
|
-
execute
|
|
1940
|
+
execute,
|
|
1941
|
+
toModelOutput: mcpToModelOutput
|
|
1917
1942
|
}) : (0, import_provider_utils3.tool)({
|
|
1918
1943
|
description,
|
|
1919
1944
|
title: resolvedTitle,
|
|
1920
1945
|
inputSchema: schemas[name3].inputSchema,
|
|
1921
1946
|
...outputSchema != null ? { outputSchema } : {},
|
|
1922
|
-
execute
|
|
1947
|
+
execute,
|
|
1948
|
+
toModelOutput: mcpToModelOutput
|
|
1923
1949
|
});
|
|
1924
1950
|
tools[name3] = { ...toolWithExecute, _meta };
|
|
1925
1951
|
}
|