@ai-sdk/mcp 0.0.34 → 0.0.35
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 +8 -0
- package/dist/index.js +69 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -103
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1208,11 +1208,9 @@ var SseMCPTransport = class {
|
|
|
1208
1208
|
message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`
|
|
1209
1209
|
});
|
|
1210
1210
|
(_d = this.onerror) == null ? void 0 : _d.call(this, error);
|
|
1211
|
-
return;
|
|
1212
1211
|
}
|
|
1213
1212
|
} catch (error) {
|
|
1214
1213
|
(_e = this.onerror) == null ? void 0 : _e.call(this, error);
|
|
1215
|
-
return;
|
|
1216
1214
|
}
|
|
1217
1215
|
};
|
|
1218
1216
|
await attempt();
|
|
@@ -1766,102 +1764,74 @@ var DefaultMCPClient = class {
|
|
|
1766
1764
|
params,
|
|
1767
1765
|
options
|
|
1768
1766
|
} = {}) {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
});
|
|
1775
|
-
} catch (error) {
|
|
1776
|
-
throw error;
|
|
1777
|
-
}
|
|
1767
|
+
return this.request({
|
|
1768
|
+
request: { method: "tools/list", params },
|
|
1769
|
+
resultSchema: ListToolsResultSchema,
|
|
1770
|
+
options
|
|
1771
|
+
});
|
|
1778
1772
|
}
|
|
1779
1773
|
async callTool({
|
|
1780
1774
|
name: name3,
|
|
1781
1775
|
args,
|
|
1782
1776
|
options
|
|
1783
1777
|
}) {
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
options:
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
});
|
|
1792
|
-
} catch (error) {
|
|
1793
|
-
throw error;
|
|
1794
|
-
}
|
|
1778
|
+
return this.request({
|
|
1779
|
+
request: { method: "tools/call", params: { name: name3, arguments: args } },
|
|
1780
|
+
resultSchema: CallToolResultSchema,
|
|
1781
|
+
options: {
|
|
1782
|
+
signal: options == null ? void 0 : options.abortSignal
|
|
1783
|
+
}
|
|
1784
|
+
});
|
|
1795
1785
|
}
|
|
1796
1786
|
async listResourcesInternal({
|
|
1797
1787
|
params,
|
|
1798
1788
|
options
|
|
1799
1789
|
} = {}) {
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
});
|
|
1806
|
-
} catch (error) {
|
|
1807
|
-
throw error;
|
|
1808
|
-
}
|
|
1790
|
+
return this.request({
|
|
1791
|
+
request: { method: "resources/list", params },
|
|
1792
|
+
resultSchema: ListResourcesResultSchema,
|
|
1793
|
+
options
|
|
1794
|
+
});
|
|
1809
1795
|
}
|
|
1810
1796
|
async readResourceInternal({
|
|
1811
1797
|
uri,
|
|
1812
1798
|
options
|
|
1813
1799
|
}) {
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
});
|
|
1820
|
-
} catch (error) {
|
|
1821
|
-
throw error;
|
|
1822
|
-
}
|
|
1800
|
+
return this.request({
|
|
1801
|
+
request: { method: "resources/read", params: { uri } },
|
|
1802
|
+
resultSchema: ReadResourceResultSchema,
|
|
1803
|
+
options
|
|
1804
|
+
});
|
|
1823
1805
|
}
|
|
1824
1806
|
async listResourceTemplatesInternal({
|
|
1825
1807
|
options
|
|
1826
1808
|
} = {}) {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
});
|
|
1833
|
-
} catch (error) {
|
|
1834
|
-
throw error;
|
|
1835
|
-
}
|
|
1809
|
+
return this.request({
|
|
1810
|
+
request: { method: "resources/templates/list" },
|
|
1811
|
+
resultSchema: ListResourceTemplatesResultSchema,
|
|
1812
|
+
options
|
|
1813
|
+
});
|
|
1836
1814
|
}
|
|
1837
1815
|
async listPromptsInternal({
|
|
1838
1816
|
params,
|
|
1839
1817
|
options
|
|
1840
1818
|
} = {}) {
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
});
|
|
1847
|
-
} catch (error) {
|
|
1848
|
-
throw error;
|
|
1849
|
-
}
|
|
1819
|
+
return this.request({
|
|
1820
|
+
request: { method: "prompts/list", params },
|
|
1821
|
+
resultSchema: ListPromptsResultSchema,
|
|
1822
|
+
options
|
|
1823
|
+
});
|
|
1850
1824
|
}
|
|
1851
1825
|
async getPromptInternal({
|
|
1852
1826
|
name: name3,
|
|
1853
1827
|
args,
|
|
1854
1828
|
options
|
|
1855
1829
|
}) {
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
});
|
|
1862
|
-
} catch (error) {
|
|
1863
|
-
throw error;
|
|
1864
|
-
}
|
|
1830
|
+
return this.request({
|
|
1831
|
+
request: { method: "prompts/get", params: { name: name3, arguments: args } },
|
|
1832
|
+
resultSchema: GetPromptResultSchema,
|
|
1833
|
+
options
|
|
1834
|
+
});
|
|
1865
1835
|
}
|
|
1866
1836
|
async notification(notification) {
|
|
1867
1837
|
const jsonrpcNotification = {
|
|
@@ -1879,44 +1849,40 @@ var DefaultMCPClient = class {
|
|
|
1879
1849
|
} = {}) {
|
|
1880
1850
|
var _a3;
|
|
1881
1851
|
const tools = {};
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
continue;
|
|
1894
|
-
}
|
|
1895
|
-
const self = this;
|
|
1896
|
-
const execute = async (args, options) => {
|
|
1897
|
-
var _a4;
|
|
1898
|
-
(_a4 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a4.throwIfAborted();
|
|
1899
|
-
return self.callTool({ name: name3, args, options });
|
|
1900
|
-
};
|
|
1901
|
-
const toolWithExecute = schemas === "automatic" ? dynamicTool({
|
|
1902
|
-
description,
|
|
1903
|
-
inputSchema: jsonSchema({
|
|
1904
|
-
...inputSchema,
|
|
1905
|
-
properties: (_a3 = inputSchema.properties) != null ? _a3 : {},
|
|
1906
|
-
additionalProperties: false
|
|
1907
|
-
}),
|
|
1908
|
-
execute
|
|
1909
|
-
}) : tool({
|
|
1910
|
-
description,
|
|
1911
|
-
inputSchema: schemas[name3].inputSchema,
|
|
1912
|
-
execute
|
|
1913
|
-
});
|
|
1914
|
-
tools[name3] = toolWithExecute;
|
|
1852
|
+
let listToolsResult = await this.listTools();
|
|
1853
|
+
const toolDefinitions = [...listToolsResult.tools];
|
|
1854
|
+
while (listToolsResult.nextCursor != null) {
|
|
1855
|
+
listToolsResult = await this.listTools({
|
|
1856
|
+
params: { cursor: listToolsResult.nextCursor }
|
|
1857
|
+
});
|
|
1858
|
+
toolDefinitions.push(...listToolsResult.tools);
|
|
1859
|
+
}
|
|
1860
|
+
for (const { name: name3, description, inputSchema } of toolDefinitions) {
|
|
1861
|
+
if (schemas !== "automatic" && !Object.prototype.hasOwnProperty.call(schemas, name3)) {
|
|
1862
|
+
continue;
|
|
1915
1863
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1864
|
+
const self = this;
|
|
1865
|
+
const execute = async (args, options) => {
|
|
1866
|
+
var _a4;
|
|
1867
|
+
(_a4 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a4.throwIfAborted();
|
|
1868
|
+
return self.callTool({ name: name3, args, options });
|
|
1869
|
+
};
|
|
1870
|
+
const toolWithExecute = schemas === "automatic" ? dynamicTool({
|
|
1871
|
+
description,
|
|
1872
|
+
inputSchema: jsonSchema({
|
|
1873
|
+
...inputSchema,
|
|
1874
|
+
properties: (_a3 = inputSchema.properties) != null ? _a3 : {},
|
|
1875
|
+
additionalProperties: false
|
|
1876
|
+
}),
|
|
1877
|
+
execute
|
|
1878
|
+
}) : tool({
|
|
1879
|
+
description,
|
|
1880
|
+
inputSchema: schemas[name3].inputSchema,
|
|
1881
|
+
execute
|
|
1882
|
+
});
|
|
1883
|
+
tools[name3] = toolWithExecute;
|
|
1919
1884
|
}
|
|
1885
|
+
return tools;
|
|
1920
1886
|
}
|
|
1921
1887
|
listResources({
|
|
1922
1888
|
params,
|