Skip to content

no attribute error occurs while calling MCP #630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Czhang0727 opened this issue Apr 30, 2025 · 2 comments
Open

no attribute error occurs while calling MCP #630

Czhang0727 opened this issue Apr 30, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@Czhang0727
Copy link

Please read this first

  • Have you read the docs?Agents SDK docs
  • Yes
  • Have you searched for related issues? Others may have faced similar issues.
    Yes

Describe the bug

A clear and concise description of what the bug is.

When we are using local model ( ollama for example ) the result not necessary contains content here, in my case, it was result[0].text

I added a local patch

  # The MCP tool result is a list of content items, whereas OpenAI tool outputs are a single
  # string. We'll try to convert.
  logger.info(f"Tool result content: ", result[0].text)
  if len(result.content) == 1:
      tool_output = result.content[0].model_dump_json()
  elif len(result.content) > 1:
 logger.info(f"Tool result content: ", result[0].text)
Message: 'Tool result content: '
Arguments: ('{"content": "{\\"ids\\": [[\\"caf665b7-cb2e-428d-9139-ff6da8687731\\", \\"f3d34cf7-d263-4dd4-b84f-b63f4258b43c\\", \\"4d649cfa-2c79-497b-8e27-bae7c8925311\\", \\"f2677a99-99ff-49ad-be52-b1e078a9b56a\\", \\"b463d689-bebb-4752-9e4f-f42395f977db\\"]], \\"embeddings\\": null, \\"documents\\": [[\\"The movie begin

File "/opt/homebrew/Caskroom/miniconda/base/lib/python3.11/site-packages/agents/mcp/util.py", line 116, in invoke_mcp_tool
if len(result.content) == 1:
^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'content'

Debug information

  • Agents SDK version: (v0.0.13`)
  • Python version (Python 3.11.5)

Repro steps

Ideally provide a minimal python script that can be run to reproduce the bug.
Please find my repo here https://github.com/Czhang0727/object-rag
You can reproduce by running server/agents_components/evaluation/run_router_demo.py

Expected behavior

A clear and concise description of what you expected to happen.
We should not fail the call, the result should deliver to final output

@Czhang0727 Czhang0727 added the bug Something isn't working label Apr 30, 2025
@Czhang0727
Copy link
Author

A simple solution could be to assign text to content.
Or, we can do MCP version check ( or maybe framework check ) for better data aggregation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant