feat(app): throw helpful error when callServerTool is called with a string (#449)
Users frequently call callServerTool("tool_name", args) instead of the
correct callServerTool({ name: "tool_name", arguments: args }), resulting
in a silent/confusing failure. Detect this and throw immediately with
a message that shows the correct call shape.
Also fixes the incorrect example in examples/pdf-server/README.md that
demonstrated this same wrong usage pattern.
Fixes #386
https://claude.ai/code/session_01GqAyN4Ux7svWoU2HqsSLZF
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
0bbbfee8c2
commit
666952980f
1 changed files with 23 additions and 1 deletions
|
|
@ -724,6 +724,12 @@ export class App extends Protocol<AppRequest, AppNotification, AppResult> {
|
|||
params: CallToolRequest["params"],
|
||||
options?: RequestOptions,
|
||||
): Promise<CallToolResult> {
|
||||
if (typeof params === "string") {
|
||||
throw new Error(
|
||||
`callServerTool() expects an object as its first argument, but received a string ("${params}"). ` +
|
||||
`Did you mean: callServerTool({ name: "${params}", arguments: { ... } })?`,
|
||||
);
|
||||
}
|
||||
return await this.request(
|
||||
{ method: "tools/call", params },
|
||||
CallToolResultSchema,
|
||||
|
|
|
|||
Loading…
Reference in a new issue