Skip to content

call_tool_chain return value is always empty in MCP bridge; data only accessible via console.log #33

@cmtonkinson

Description

@cmtonkinson

Bug Report

Summary

When using call_tool_chain via the @utcp/code-mode-mcp MCP bridge, the result field in the response is always empty ({}). Data returned via return statements inside the tool chain is silently dropped. The only way to retrieve output is by using console.log(JSON.stringify(...)) and reading from the logs array.

Environment

  • @utcp/code-mode-mcp: 1.2.0
  • MCP client: Claude Desktop (claude-ai/0.1.0, protocolVersion 2025-11-25)
  • Node.js: v24.14.0
  • npm: 11.9.0
  • macOS (arm64)
  • Underlying MCP server: mcp/github via Docker (stdio transport)

Steps to Reproduce

  1. Configure @utcp/code-mode-mcp as an MCP server in Claude Desktop with a valid .utcp_config.json
  2. Invoke call_tool_chain with a code block that returns a value:
(async () => {
  const repos = await github.github_search_repositories({ query: "user:cmtonkinson", perPage: 5 });
  return repos;
})()
  1. Inspect the MCP tool response

Actual Behavior

The MCP tool response contains:

{
  "success": true,
  "nonMcpContentResults": {},
  "logs": []
}

The result / nonMcpContentResults field is empty. The return value is silently discarded.

Workaround

Using console.log(JSON.stringify(result)) instead of return result causes the data to appear in the logs array:

(async () => {
  const repos = await github.github_search_repositories({ query: "user:cmtonkinson", perPage: 5 });
  console.log(JSON.stringify(repos));
})()

Response:

{
  "success": true,
  "nonMcpContentResults": {},
  "logs": ["{\"total_count\":11,\"items\":[...]}"]
}

Expected Behavior

Per the README documentation:

const { result, logs } = await client.callToolChain(`
  const repos = await github.search_repositories({ query: "user:example" });
  return repos;
`);
console.log(result); // should contain the returned value

The result field should contain the return value of the executed code block.

Additional Notes

  • The bug appears to be in the MCP bridge layer (code-mode-mcp) specifically — the underlying @utcp/code-mode TypeScript library likely serializes result correctly, but it is lost when the MCP tool response is constructed.
  • Top-level await also does not work inside call_tool_chain despite documentation suggesting it should — an explicit async IIFE wrapper is required.
  • Related: issue Example from readme incorrect #7 notes several other discrepancies between the README examples and actual behavior.

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