Skip to content

Python: Bug: AttributeError: module 'mcp.types' has no attribute 'ToolUseContent' after PR #2597 #2734

Closed

Description

PR #2597 introduced a breaking change that prevents agent-framework from importing. The code references types.ToolUseContent and types.ToolResultContent which don't exist in any released version of the mcp package.

Error

AttributeError: module 'mcp.types' has no attribute 'ToolUseContent'

Traceback:

File "/agent_framework/__init__.py", line 12, in <module>
    from ._agents import *
File "/agent_framework/_agents.py", line 18, in <module>
    from ._clients import BaseChatClient, ChatClientProtocol
File "/agent_framework/_clients.py", line 11, in <module>
    from ._mcp import MCPTool
File "/agent_framework/_mcp.py", line 134, in <module>
    | types.ToolUseContent
      ^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'mcp.types' has no attribute 'ToolUseContent'

Root Cause

The issue was introduced in PR #2597 at _mcp.py:L134-L135:

def _mcp_type_to_ai_content(
    mcp_type: types.ImageContent
    | types.TextContent
    | types.AudioContent
    | types.EmbeddedResource
    | types.ResourceLink
    | types.ToolUseContent      # ❌ DOES NOT EXIST in mcp package
    | types.ToolResultContent   # ❌ DOES NOT EXIST in mcp package
    | Sequence[...],
) -> list[Contents]:

Verification

I've tested with multiple mcp package versions (1.13.0, 1.19.0, 1.23.3). None contain these attributes.

Available Tool-related types in mcp.types:

  • Tool
  • ToolAnnotations
  • CallToolRequest
  • CallToolRequestParams
  • CallToolResult
  • ListToolsRequest
  • ListToolsResult
  • ToolListChangedNotification
  • ToolsCapability

Not available:

  • ❌ ToolUseContent
  • ❌ ToolResultContent

Reproduction

from agent_framework import ChatMessage, Role, SequentialBuilder
# Fails immediately with AttributeError

Environment

  • agent-framework: 1.0.0b251204
  • mcp: 1.13.0 / 1.19.0 / 1.23.3 (all fail)
  • Python: 3.13
  • OS: macOS

Impact

  • ⚠️ Breaks all imports of agent-framework
  • ⚠️ Affects DeepLearning.AI Microsoft Agent Framework course materials
  • ⚠️ Students and developers cannot use the package at all

Possible Solutions

  1. Remove the references to ToolUseContent and ToolResultContent if they're not needed
  2. Pin mcp to a specific version that contains these types (if one exists)
  3. Add these types to the mcp package first, then reference them
  4. Make these types optional with proper type guards

Related

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Dec 9, 2025
  2. changed the title [-]Bug: `AttributeError: module 'mcp.types' has no attribute 'ToolUseContent'` after PR #2597[/-] [+]Python: Bug: `AttributeError: module 'mcp.types' has no attribute 'ToolUseContent'` after PR #2597[/+] on Dec 9, 2025
  3. gauravbrills commented on Dec 10, 2025

    @gauravbrills

    ya seeing the same is there a workaround what version to use till this gets fixed

  4. eavanvalkenburg commented on Dec 10, 2025

    @eavanvalkenburg
    Member

    This is strange, I suggest updating MCP, those types were added in modelcontextprotocol/python-sdk#1594 that was released as part of mcp>=1.23.0

  5. gauravbrills commented on Dec 10, 2025

    @gauravbrills

    yes worked post upgrading to "mcp==1.23.3",

  6. eavanvalkenburg commented on Dec 12, 2025

    @eavanvalkenburg
    Member

    I fix has gone out to sets the minimum MCP dependency to 1.23 to resolve this.

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

Metadata

Metadata

Labels

mcpUsage: [Issues, PRs], Target: MCPpythonUsage: [Issues, PRs], Target: Python

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions