Skip to content

Doesn't seem to work with newer python/deps in Python 3.13 #3

@badvision

Description

@badvision

The MCP library tries to do type introspection at runtime, but is choking on the union types in the code.

The issue was caused by type annotations in the MCP tool function parameters. The MCP library's issubclass() check was failing because it couldn't handle certain type annotations like typing.Any,
typing.Optional[str], union types, and return type annotations.

The fix involved:

  1. Removing all parameter type annotations from @mcp.tool() decorated functions
  2. Removing **kwargs type annotations
  3. Removing return type annotations
  4. Keeping default parameter values intact

Original error

  2025-08-07 09:45:21,894 - src.main - INFO - Registering MCP tools...
  Traceback (most recent call last):
    File "/Users/brobert/Documents/code/chrome-devtools-mcp/server.py", line 33, in <module>
      from src import main
    File "/Users/brobert/Documents/code/chrome-devtools-mcp/src/__init__.py", line 6, in <module>
      from . import main
    File "/Users/brobert/Documents/code/chrome-devtools-mcp/src/main.py", line 75, in <module>
      register_all_tools()
      ~~~~~~~~~~~~~~~~~~^^
    File "/Users/brobert/Documents/code/chrome-devtools-mcp/src/main.py", line 62, in register_all_tools
      register_chrome_tools(mcp)
      ~~~~~~~~~~~~~~~~~~~~~^^^^^
    File "/Users/brobert/Documents/code/chrome-devtools-mcp/src/tools/chrome_management.py", line 171, in register_chrome_tools
      @mcp.tool()
       ~~~~~~~~^^
    File "/opt/homebrew/lib/python3.13/site-packages/mcp/server/fastmcp/server.py", line 421, in decorator
      self.add_tool(
      ~~~~~~~~~~~~~^
          fn,
          ^^^
      ...<4 lines>...
          structured_output=structured_output,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/opt/homebrew/lib/python3.13/site-packages/mcp/server/fastmcp/server.py", line 366, in add_tool
      self._tool_manager.add_tool(
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^
          fn,
          ^^^
      ...<4 lines>...
          structured_output=structured_output,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/opt/homebrew/lib/python3.13/site-packages/mcp/server/fastmcp/tools/tool_manager.py", line 55, in add_tool
      tool = Tool.from_function(
          fn,
      ...<4 lines>...
          structured_output=structured_output,
      )
    File "/opt/homebrew/lib/python3.13/site-packages/mcp/server/fastmcp/tools/base.py", line 67, in from_function
      if issubclass(param.annotation, Context):
         ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen abc>", line 123, in __subclasscheck__
  TypeError: issubclass() arg 1 must be a class

Repair

See provided diff. I would hope that there is a more elegant way to fix this than what Claude did, but this at least got the mcp server running for me and I'm providing it just in case it helps.

diff.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions