@ai-sdk/mcp 0.0.18 → 0.0.19
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 +19 -0
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1086,7 +1086,7 @@ var SseMCPTransport = class {
|
|
|
1086
1086
|
const stream = response.body.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream());
|
|
1087
1087
|
const reader = stream.getReader();
|
|
1088
1088
|
const processEvents = async () => {
|
|
1089
|
-
var _a4, _b4, _c2;
|
|
1089
|
+
var _a4, _b4, _c2, _d2, _e2;
|
|
1090
1090
|
try {
|
|
1091
1091
|
while (true) {
|
|
1092
1092
|
const { done, value } = await reader.read();
|
|
@@ -1101,24 +1101,32 @@ var SseMCPTransport = class {
|
|
|
1101
1101
|
}
|
|
1102
1102
|
const { event, data } = value;
|
|
1103
1103
|
if (event === "endpoint") {
|
|
1104
|
-
|
|
1105
|
-
|
|
1104
|
+
if (this.endpoint) {
|
|
1105
|
+
continue;
|
|
1106
|
+
}
|
|
1107
|
+
const endpoint = new URL(data, this.url);
|
|
1108
|
+
if (endpoint.origin !== this.url.origin) {
|
|
1109
|
+
this.connected = false;
|
|
1110
|
+
this.endpoint = void 0;
|
|
1111
|
+
(_a4 = this.sseConnection) == null ? void 0 : _a4.close();
|
|
1112
|
+
(_b4 = this.abortController) == null ? void 0 : _b4.abort();
|
|
1106
1113
|
throw new MCPClientError({
|
|
1107
|
-
message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${
|
|
1114
|
+
message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${endpoint.origin}`
|
|
1108
1115
|
});
|
|
1109
1116
|
}
|
|
1117
|
+
this.endpoint = endpoint;
|
|
1110
1118
|
this.connected = true;
|
|
1111
1119
|
resolve();
|
|
1112
1120
|
} else if (event === "message") {
|
|
1113
1121
|
try {
|
|
1114
1122
|
const message = await parseJSONRPCMessage(data);
|
|
1115
|
-
(
|
|
1123
|
+
(_c2 = this.onmessage) == null ? void 0 : _c2.call(this, message);
|
|
1116
1124
|
} catch (error) {
|
|
1117
1125
|
const e = new MCPClientError({
|
|
1118
1126
|
message: "MCP SSE Transport Error: Failed to parse message",
|
|
1119
1127
|
cause: error
|
|
1120
1128
|
});
|
|
1121
|
-
(
|
|
1129
|
+
(_d2 = this.onerror) == null ? void 0 : _d2.call(this, e);
|
|
1122
1130
|
}
|
|
1123
1131
|
}
|
|
1124
1132
|
}
|
|
@@ -1126,7 +1134,7 @@ var SseMCPTransport = class {
|
|
|
1126
1134
|
if (error instanceof Error && error.name === "AbortError") {
|
|
1127
1135
|
return;
|
|
1128
1136
|
}
|
|
1129
|
-
(
|
|
1137
|
+
(_e2 = this.onerror) == null ? void 0 : _e2.call(this, error);
|
|
1130
1138
|
reject(error);
|
|
1131
1139
|
}
|
|
1132
1140
|
};
|
|
@@ -1148,6 +1156,7 @@ var SseMCPTransport = class {
|
|
|
1148
1156
|
async close() {
|
|
1149
1157
|
var _a3, _b3, _c;
|
|
1150
1158
|
this.connected = false;
|
|
1159
|
+
this.endpoint = void 0;
|
|
1151
1160
|
(_a3 = this.sseConnection) == null ? void 0 : _a3.close();
|
|
1152
1161
|
(_b3 = this.abortController) == null ? void 0 : _b3.abort();
|
|
1153
1162
|
(_c = this.onclose) == null ? void 0 : _c.call(this);
|
|
@@ -1835,7 +1844,7 @@ var DefaultMCPClient = class {
|
|
|
1835
1844
|
try {
|
|
1836
1845
|
const listToolsResult = await this.listTools();
|
|
1837
1846
|
for (const { name: name3, description, inputSchema } of listToolsResult.tools) {
|
|
1838
|
-
if (schemas !== "automatic" && !(name3
|
|
1847
|
+
if (schemas !== "automatic" && !Object.prototype.hasOwnProperty.call(schemas, name3)) {
|
|
1839
1848
|
continue;
|
|
1840
1849
|
}
|
|
1841
1850
|
const self = this;
|