Skip to content
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

[MCP server issue] Cannot access MCP server with env #6037

Open
Yuanqi-babe opened this issue Mar 20, 2025 · 1 comment
Open

[MCP server issue] Cannot access MCP server with env #6037

Yuanqi-babe opened this issue Mar 20, 2025 · 1 comment
Labels
awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster needs-triage

Comments

@Yuanqi-babe
Copy link

What happened?

Describe the bug
I installed a Stdio MCP server following the configuration:
"github.com/mendableai/firecrawl-mcp-server": {
"command": "npx",
"args": ["-y", "firecrawl-mcp"],
"env": {
"FIRECRAWL_API_KEY": "fc-294547563d9344ef8409bbb8e80f5307"
},
"disabled": false,
"autoApprove": []
}
}

However, when I ran it in AutoGEN 0.4, it throws an unexpected error when registering MCP tools:

        logger.info("Setting up fetch MCP server...")
        fetch_mcp_server = StdioServerParams(command="env", args=["FIRECRAWL_API_KEY=fc-294547563d9344ef8409bbb8e80f5307", "npx", "-y" ,"firecrawl-mcp"])
        fetch_tools = await mcp_server_tools(fetch_mcp_server)
        logger.info(f"Fetch tools loaded: {len(fetch_tools)} tools")

Printed on the console it shows the successful onboard of this tool but:

FireCrawl MCP Server running on stdio
/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/pydantic/_internal/_fields.py:192: UserWarning: Field name "schema" in "DynamicModel" shadows an attribute in parent "BaseModel"
  warnings.warn(
2025-03-20 09:15:17,824 - ERROR
An error occurred: Each oneOf variant must have a type const
Traceback (most recent call last):
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/test_mcp.py", line 99, in main
    fetch_tools = await mcp_server_tools(fetch_mcp_server)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_factory.py", line 139, in mcp_server_tools
    return [StdioMcpToolAdapter(server_params=server_params, tool=tool) for tool in tools.tools]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_stdio.py", line 48, in __init__
    super().__init__(server_params=server_params, tool=tool)
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_base.py", line 36, in __init__
    input_model = create_model(tool.inputSchema)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/__init__.py", line 42, in create_model
    return builder.create_pydantic_model(schema, root_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/model_builder.py", line 62, in create_pydantic_model
    field_type = self._get_field_type(field_schema, root_schema)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/model_builder.py", line 92, in _get_field_type
    return self.combiner_handler.handle_one_of(field_schema, root_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/handlers.py", line 135, in handle_one_of
    raise CombinerError("Each oneOf variant must have a type const")
json_schema_to_pydantic.exceptions.CombinerError: Each oneOf variant must have a type const
Traceback (most recent call last):
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/test_mcp.py", line 173, in <module>
    asyncio.run(main())
  File "/usr/lib64/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/test_mcp.py", line 99, in main
    fetch_tools = await mcp_server_tools(fetch_mcp_server)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_factory.py", line 139, in mcp_server_tools
    return [StdioMcpToolAdapter(server_params=server_params, tool=tool) for tool in tools.tools]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_stdio.py", line 48, in __init__
    super().__init__(server_params=server_params, tool=tool)
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_base.py", line 36, in __init__
    input_model = create_model(tool.inputSchema)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/__init__.py", line 42, in create_model
    return builder.create_pydantic_model(schema, root_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/model_builder.py", line 62, in create_pydantic_model
    field_type = self._get_field_type(field_schema, root_schema)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/model_builder.py", line 92, in _get_field_type
    return self.combiner_handler.handle_one_of(field_schema, root_schema)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/json_schema_to_pydantic/handlers.py", line 135, in handle_one_of
    raise CombinerError("Each oneOf variant must have a type const")
json_schema_to_pydantic.exceptions.CombinerError: Each oneOf variant must have a type const

To Reproduce

Which packages was the bug in?

Python Extensions (autogen-ext)

AutoGen library version.

Python dev (main branch)

Other library version.

-mcp

Model used

No response

Model provider

None

Other model provider

No response

Python version

3.12

.NET version

None

Operating system

CentOS

@ekzhu
Copy link
Collaborator

ekzhu commented Mar 21, 2025

Could you print out your tool schema without using AutoGen from an mcp client? Looks like the tool schema cannot be used to create a json schema using pydantic:

  File "/home/ec2-user/bedrock-access-gw/bedrock-access-gateway/test-script/venv/lib64/python3.12/site-packages/autogen_ext/tools/mcp/_base.py", line 36, in __init__
    input_model = create_model(tool.inputSchema)

@ekzhu ekzhu added the awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-op-response Issue or pr has been triaged or responded to and is now awaiting a reply from the original poster needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants