Skip to content

Clarify executeTool argument encoding and returned schema shape #278

Description

@zekariasasaminew

While testing WebMCP tool registration and invocation in a browser implementation, I hit two API details that were easy to misread from the current examples/spec text.

Observed behavior:

const tools = await document.modelContext.getTools();
const tool = tools.find((entry) => entry.name === "example_tool");

await document.modelContext.executeTool(tool, { message: "hello" });
// Fails with an input parsing / type error in the tested runtime.

await document.modelContext.executeTool(tool, JSON.stringify({ message: "hello" }));
// Succeeds in the tested runtime.

console.log(typeof tool.inputSchema);
// "string" in the tested runtime, containing serialized JSON schema.

The shape that worked was:

  1. Await document.modelContext.getTools().
  2. Pass the RegisteredTool object returned by getTools() into executeTool(), not the tool name.
  3. Pass JSON-encoded argument text into executeTool().
  4. Parse returned inputSchema metadata when it is exposed as a serialized JSON string.

It would help implementers if the explainer/spec/docs explicitly state whether executeTool arguments are intended to be a JavaScript object, a JSON string, or implementation-dependent for now, and whether returned tool schemas are expected to be structured objects or serialized strings.

If the current observed behavior is the intended contract, a small normative example for executeTool would prevent a class of false-negative debugging sessions where tools are registered correctly but every manual execution attempt appears broken.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions