UNPKG

ant-design-x-vue-next

Version:

Ant Design X for Vue — community continuation aligned with @ant-design/x

51 lines (50 loc) 1.17 kB
import h from "../x-request/x-request.mjs"; class l { constructor(e, o) { if (!e || typeof e != "string") throw new Error("The baseURL is not valid!"); this.baseURL = e, this.options = o; } /** * Fetch MCP tool list from the given endpoint (POST JSON via XRequest). * Aligned with `@ant-design/x-sdk` XMCPClient.tools(). */ async tools() { const { headers: e, params: o, middlewares: t, ...u } = this.options || {}, d = { ...t, onRequest: async (r, s) => { const n = { ...s || {}, headers: { ...(s == null ? void 0 : s.headers) || {}, ...e || {} } }; return t != null && t.onRequest ? t.onRequest(r, n) : [r, n]; } }; return new Promise((r, s) => { h({ baseURL: this.baseURL, ...u, middlewares: d }).value.create(o || {}, { onSuccess: (a) => { r(a[0] || []); }, onError: (a) => { s(a); }, onUpdate: () => { } }).catch(s); }); } } function f(c, e) { return new l(c, e); } export { f as XMCPClient, f as default };