@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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1240,11 +1240,9 @@ var SseMCPTransport = class {
|
|
|
1240
1240
|
message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${response.status}): ${text}`
|
|
1241
1241
|
});
|
|
1242
1242
|
(_d = this.onerror) == null ? void 0 : _d.call(this, error);
|
|
1243
|
-
return;
|
|
1244
1243
|
}
|
|
1245
1244
|
} catch (error) {
|
|
1246
1245
|
(_e = this.onerror) == null ? void 0 : _e.call(this, error);
|
|
1247
|
-
return;
|
|
1248
1246
|
}
|
|
1249
1247
|
};
|
|
1250
1248
|
await attempt();
|
|
@@ -1794,102 +1792,74 @@ var DefaultMCPClient = class {
|
|
|
1794
1792
|
params,
|
|
1795
1793
|
options
|
|
1796
1794
|
} = {}) {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
});
|
|
1803
|
-
} catch (error) {
|
|
1804
|
-
throw error;
|
|
1805
|
-
}
|
|
1795
|
+
return this.request({
|
|
1796
|
+
request: { method: "tools/list", params },
|
|
1797
|
+
resultSchema: ListToolsResultSchema,
|
|
1798
|
+
options
|
|
1799
|
+
});
|
|
1806
1800
|
}
|
|
1807
1801
|
async callTool({
|
|
1808
1802
|
name: name3,
|
|
1809
1803
|
args,
|
|
1810
1804
|
options
|
|
1811
1805
|
}) {
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
options:
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
});
|
|
1820
|
-
} catch (error) {
|
|
1821
|
-
throw error;
|
|
1822
|
-
}
|
|
1806
|
+
return this.request({
|
|
1807
|
+
request: { method: "tools/call", params: { name: name3, arguments: args } },
|
|
1808
|
+
resultSchema: CallToolResultSchema,
|
|
1809
|
+
options: {
|
|
1810
|
+
signal: options == null ? void 0 : options.abortSignal
|
|
1811
|
+
}
|
|
1812
|
+
});
|
|
1823
1813
|
}
|
|
1824
1814
|
async listResourcesInternal({
|
|
1825
1815
|
params,
|
|
1826
1816
|
options
|
|
1827
1817
|
} = {}) {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
});
|
|
1834
|
-
} catch (error) {
|
|
1835
|
-
throw error;
|
|
1836
|
-
}
|
|
1818
|
+
return this.request({
|
|
1819
|
+
request: { method: "resources/list", params },
|
|
1820
|
+
resultSchema: ListResourcesResultSchema,
|
|
1821
|
+
options
|
|
1822
|
+
});
|
|
1837
1823
|
}
|
|
1838
1824
|
async readResourceInternal({
|
|
1839
1825
|
uri,
|
|
1840
1826
|
options
|
|
1841
1827
|
}) {
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
});
|
|
1848
|
-
} catch (error) {
|
|
1849
|
-
throw error;
|
|
1850
|
-
}
|
|
1828
|
+
return this.request({
|
|
1829
|
+
request: { method: "resources/read", params: { uri } },
|
|
1830
|
+
resultSchema: ReadResourceResultSchema,
|
|
1831
|
+
options
|
|
1832
|
+
});
|
|
1851
1833
|
}
|
|
1852
1834
|
async listResourceTemplatesInternal({
|
|
1853
1835
|
options
|
|
1854
1836
|
} = {}) {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
});
|
|
1861
|
-
} catch (error) {
|
|
1862
|
-
throw error;
|
|
1863
|
-
}
|
|
1837
|
+
return this.request({
|
|
1838
|
+
request: { method: "resources/templates/list" },
|
|
1839
|
+
resultSchema: ListResourceTemplatesResultSchema,
|
|
1840
|
+
options
|
|
1841
|
+
});
|
|
1864
1842
|
}
|
|
1865
1843
|
async listPromptsInternal({
|
|
1866
1844
|
params,
|
|
1867
1845
|
options
|
|
1868
1846
|
} = {}) {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
});
|
|
1875
|
-
} catch (error) {
|
|
1876
|
-
throw error;
|
|
1877
|
-
}
|
|
1847
|
+
return this.request({
|
|
1848
|
+
request: { method: "prompts/list", params },
|
|
1849
|
+
resultSchema: ListPromptsResultSchema,
|
|
1850
|
+
options
|
|
1851
|
+
});
|
|
1878
1852
|
}
|
|
1879
1853
|
async getPromptInternal({
|
|
1880
1854
|
name: name3,
|
|
1881
1855
|
args,
|
|
1882
1856
|
options
|
|
1883
1857
|
}) {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
});
|
|
1890
|
-
} catch (error) {
|
|
1891
|
-
throw error;
|
|
1892
|
-
}
|
|
1858
|
+
return this.request({
|
|
1859
|
+
request: { method: "prompts/get", params: { name: name3, arguments: args } },
|
|
1860
|
+
resultSchema: GetPromptResultSchema,
|
|
1861
|
+
options
|
|
1862
|
+
});
|
|
1893
1863
|
}
|
|
1894
1864
|
async notification(notification) {
|
|
1895
1865
|
const jsonrpcNotification = {
|
|
@@ -1907,44 +1877,40 @@ var DefaultMCPClient = class {
|
|
|
1907
1877
|
} = {}) {
|
|
1908
1878
|
var _a3;
|
|
1909
1879
|
const tools = {};
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
continue;
|
|
1922
|
-
}
|
|
1923
|
-
const self = this;
|
|
1924
|
-
const execute = async (args, options) => {
|
|
1925
|
-
var _a4;
|
|
1926
|
-
(_a4 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a4.throwIfAborted();
|
|
1927
|
-
return self.callTool({ name: name3, args, options });
|
|
1928
|
-
};
|
|
1929
|
-
const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils5.dynamicTool)({
|
|
1930
|
-
description,
|
|
1931
|
-
inputSchema: (0, import_provider_utils5.jsonSchema)({
|
|
1932
|
-
...inputSchema,
|
|
1933
|
-
properties: (_a3 = inputSchema.properties) != null ? _a3 : {},
|
|
1934
|
-
additionalProperties: false
|
|
1935
|
-
}),
|
|
1936
|
-
execute
|
|
1937
|
-
}) : (0, import_provider_utils5.tool)({
|
|
1938
|
-
description,
|
|
1939
|
-
inputSchema: schemas[name3].inputSchema,
|
|
1940
|
-
execute
|
|
1941
|
-
});
|
|
1942
|
-
tools[name3] = toolWithExecute;
|
|
1880
|
+
let listToolsResult = await this.listTools();
|
|
1881
|
+
const toolDefinitions = [...listToolsResult.tools];
|
|
1882
|
+
while (listToolsResult.nextCursor != null) {
|
|
1883
|
+
listToolsResult = await this.listTools({
|
|
1884
|
+
params: { cursor: listToolsResult.nextCursor }
|
|
1885
|
+
});
|
|
1886
|
+
toolDefinitions.push(...listToolsResult.tools);
|
|
1887
|
+
}
|
|
1888
|
+
for (const { name: name3, description, inputSchema } of toolDefinitions) {
|
|
1889
|
+
if (schemas !== "automatic" && !Object.prototype.hasOwnProperty.call(schemas, name3)) {
|
|
1890
|
+
continue;
|
|
1943
1891
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1892
|
+
const self = this;
|
|
1893
|
+
const execute = async (args, options) => {
|
|
1894
|
+
var _a4;
|
|
1895
|
+
(_a4 = options == null ? void 0 : options.abortSignal) == null ? void 0 : _a4.throwIfAborted();
|
|
1896
|
+
return self.callTool({ name: name3, args, options });
|
|
1897
|
+
};
|
|
1898
|
+
const toolWithExecute = schemas === "automatic" ? (0, import_provider_utils5.dynamicTool)({
|
|
1899
|
+
description,
|
|
1900
|
+
inputSchema: (0, import_provider_utils5.jsonSchema)({
|
|
1901
|
+
...inputSchema,
|
|
1902
|
+
properties: (_a3 = inputSchema.properties) != null ? _a3 : {},
|
|
1903
|
+
additionalProperties: false
|
|
1904
|
+
}),
|
|
1905
|
+
execute
|
|
1906
|
+
}) : (0, import_provider_utils5.tool)({
|
|
1907
|
+
description,
|
|
1908
|
+
inputSchema: schemas[name3].inputSchema,
|
|
1909
|
+
execute
|
|
1910
|
+
});
|
|
1911
|
+
tools[name3] = toolWithExecute;
|
|
1947
1912
|
}
|
|
1913
|
+
return tools;
|
|
1948
1914
|
}
|
|
1949
1915
|
listResources({
|
|
1950
1916
|
params,
|