Skip to content

Failure to list MCP tools due to unsupported format #6841

@onematchfox

Description

@onematchfox

What happened?

Describe the bug

When trying to make use of the Notion MCP server, I ran into the following exception when calling autogen_ext.tools.mcp.mcp_server_tools.

Exception has occurred: FormatNotSupportedError
Unknown format `json` for `icon` in `GeneratedModel`
  File "main.py", line 59, in main
    tools = await mcp_server_tools(server_params)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 66, in <module>
    asyncio.run(main())
autogen_core.utils._json_to_pydantic.FormatNotSupportedError: Unknown format `json` for `icon` in `GeneratedModel`

This seems to stem from their use of "format": "json" within the inputSchema on tool definitions. Whereas, json is not a known/defined format value within the autogen utils for converting json to pydantic.

Disclaimer: I'm a complete n00b to all of this, so I don't quite know where to turn or how best to address this issue. That being said...

The MCP specification defines:

inputSchema: JSON Schema defining expected parameters

JSON Schema, in turn, specifies:

format is not limited to a specific set of valid values or types. Users may define their own custom keywords including ones that work with JSON data types other than string, such as number.

Hence, I wonder, should this code be as opinionated as it is right now, and fail for any unknown format? Alternatively, as a short-stop/quick-fix, would the maintainers be open to adding support for "format": "json"? Adding support for JSON is an easy fix, and I have the code ready to open up a PR; however, I am hesitating as the utils method schema_to_pydantic_model is used in other parts of the codebase beyond just converting tool schemas.

To Reproduce

import asyncio
from autogen_ext.tools.mcp import StdioServerParams, mcp_server_tools

async def main() -> None:
    server_params = StdioServerParams(
        command="npx", args=["-y", "@notionhq/notion-mcp-server"]
    )

    # Get all available tools from the server
    tools = await mcp_server_tools(server_params)

    for tool in tools:
        print(f"{tool.name} - {tool.description}")


if __name__ == "__main__":
    asyncio.run(main())

Expected behavior

I would expect to be able to use any (valid) MCP server with Autogen without any error.

Which packages was the bug in?

Python Core (autogen-core), Python Extensions (autogen-ext)

AutoGen library version.

Python dev (main branch)

Other library version.

No response

Model used

No response

Model provider

None

Other model provider

No response

Python version

3.11

.NET version

None

Operating system

Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions