@decocms/bindings 1.1.0 → 1.1.1
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/package.json +1 -1
- package/src/core/client/proxy.ts +6 -22
package/package.json
CHANGED
package/src/core/client/proxy.ts
CHANGED
|
@@ -67,16 +67,8 @@ export function createMCPClientProxy<T extends Record<string, unknown>>(
|
|
|
67
67
|
}
|
|
68
68
|
async function callToolFn(
|
|
69
69
|
args: Record<string, unknown>,
|
|
70
|
-
|
|
70
|
+
toolName = name,
|
|
71
71
|
) {
|
|
72
|
-
let toolName: string | symbol;
|
|
73
|
-
let requestInit: RequestInit | undefined;
|
|
74
|
-
if (typeof toolNameOrRequestInit === "object") {
|
|
75
|
-
toolName = name;
|
|
76
|
-
requestInit = toolNameOrRequestInit;
|
|
77
|
-
} else {
|
|
78
|
-
toolName ??= name;
|
|
79
|
-
}
|
|
80
72
|
const debugId = options?.debugId?.();
|
|
81
73
|
const extraHeaders = debugId
|
|
82
74
|
? { "x-trace-debug-id": debugId }
|
|
@@ -85,21 +77,13 @@ export function createMCPClientProxy<T extends Record<string, unknown>>(
|
|
|
85
77
|
const { client, callStreamableTool } = await createClient(extraHeaders);
|
|
86
78
|
|
|
87
79
|
if (options?.streamable?.[String(toolName)]) {
|
|
88
|
-
return callStreamableTool(
|
|
89
|
-
String(toolName),
|
|
90
|
-
args,
|
|
91
|
-
requestInit?.signal ?? undefined,
|
|
92
|
-
);
|
|
80
|
+
return callStreamableTool(String(toolName), args);
|
|
93
81
|
}
|
|
94
82
|
|
|
95
|
-
const { structuredContent, isError, content } = await client.callTool(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
undefined,
|
|
101
|
-
{ signal: requestInit?.signal ?? undefined },
|
|
102
|
-
);
|
|
83
|
+
const { structuredContent, isError, content } = await client.callTool({
|
|
84
|
+
name: String(toolName),
|
|
85
|
+
arguments: args as Record<string, unknown>,
|
|
86
|
+
});
|
|
103
87
|
|
|
104
88
|
if (isError) {
|
|
105
89
|
const maybeErrorMessage = (content as { text: string }[])?.[0]?.text;
|