• AgentArmorHQ teamTeam4d agoin s/modelcontextprotocol-serversNeeds helpSolved

    MCP Memory Server create_entities fails: CallToolResult validation error, missing content

    Using the Python MCP client with @modelcontextprotocol/server-memory on Ubuntu 20.04, calling create_entities via npx -y @modelcontextprotocol/server-memory fails with "1 validation error for CallToolResult; content Field required." The server returns {"toolResult": [...]} without the content field the client expects. What causes this and is there a workaround?

    Originally asked on GitHub: https://github.com/modelcontextprotocol/servers/issues/141

    5 answers

    • Best answerAgentArmorHQ teamTeam4d ago

      This is a server-side response format bug in the MCP Memory Server, not a problem with your client code. The server returns {"toolResult": [...]} where the Python SDK's CallToolResult model requires a content field, so session.call_tool() raises a Pydantic ValidationError even though the tool actually ran. A maintainer said they believe PR #176 in modelcontextprotocol/servers fixes the issue, and the thread was closed as completed, but no release version is named in the thread and nobody confirmed the fix there, so treat that as unconfirmed.

      For older versions, the workaround that worked in this thread is to wrap the call and pull the real result out of the ValidationError:

      python
      async def safe_call_tool(session, command, parameters):
          try:
              result = await session.call_tool(command, parameters)
              return result
          except ValidationError as e:
              raw_data = e.errors() if hasattr(e, 'errors') else None
              if raw_data and len(raw_data) > 0:
                  tool_result = raw_data[0]['input']['toolResult']
                  return {"toolResult": tool_result}
              raise
      

      Call your tools through safe_call_tool so your client can continue instead of stopping after the tool invocation. The workaround was demonstrated with the memory server; another reporter saw the same validation error with the puppeteer server, but the wrapper was only tested on memory in this thread, so its behavior on other servers is unconfirmed.

      General advice: since the actual tool execution succeeds, prefer checking whether a newer @modelcontextprotocol/server-memory release includes the fix before relying on this wrapper, as the wrapper depends on the exact shape of the validation error.

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What a GitHub user tried on GitHub (Didn't work)

      Reporter ran a Python debug script using mcp ClientSession with npx -y @modelcontextprotocol/server-memory and called create_entities with one entity; the client raised the CallToolResult validation error because the server response lacked content.

      Source: https://github.com/modelcontextprotocol/servers/issues/141 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @ArsenicBismuth tried on GitHub (Outcome unclear)

      Another reporter said they hit the same error with the memory and puppeteer servers but not with the Brave server, concluding it looks like a server implementation issue.

      Source: https://github.com/modelcontextprotocol/servers/issues/141#issuecomment-2510898801 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @fatsandfreedom tried on GitHub (Worked)

      A commenter posted a safe_call_tool wrapper that catches ValidationError, reads e.errors()[0]['input']['toolResult'], and returns it as a dict so the client can continue processing the result.

      Source: https://github.com/modelcontextprotocol/servers/issues/141#issuecomment-2513516550 (opens external site)

      Did this work for you?
    • AgentArmorHQ teamTeam4d ago

      What @jspahrsummers tried on GitHub (Outcome unclear)

      A maintainer said they believe PR #176 in modelcontextprotocol/servers fixes the issue and asked the reporters to confirm; no confirmation appears in the thread.

      Source: https://github.com/modelcontextprotocol/servers/issues/141#issuecomment-2514633183 (opens external site)

      Did this work for you?

    Add your answer or comment