-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Labels
Description
What happened?
Describe the bug
When I use mcp_server_tools, I get an error, but it works perfectly fine under McpWorkbench.
To Reproduce
here is my code , the mcp_server_everything_search is installed by pip install mcp-server-everything-search
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams, mcp_server_tools
from model_utils import get_vllm_qwen3_30b_a3b_client
async def main() -> None:
params = StdioServerParams(
command="python",
args=["-m","mcp_server_everything_search"],
env={"EVERYTHING_SDK_PATH": "D:\\02 - programs\\Everything-SDK\\dll\\Everything64.dll"},
read_timeout_seconds=60,
)
tools = await mcp_server_tools(params)
print(tools)
if __name__ == "__main__":
asyncio.run(main())
this will get:
Traceback (most recent call last):
File "D:\01 - code\04 - python\agent-samples\MCP\mcp_server_tools.py", line 30, in <module>
asyncio.run(main())
File "C:\Users\l00621014\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\l00621014\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\l00621014\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "D:\01 - code\04 - python\agent-samples\MCP\mcp_server_tools.py", line 26, in main
tools = await mcp_server_tools(params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_ext\tools\mcp\_factory.py", line 206, in mcp_server_tools
return [StdioMcpToolAdapter(server_params=server_params, tool=tool, session=session) for tool in tools.tools]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_ext\tools\mcp\_stdio.py", line 52, in __init__
super().__init__(server_params=server_params, tool=tool, session=session)
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_ext\tools\mcp\_base.py", line 43, in __init__
input_model = schema_to_pydantic_model(tool.inputSchema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_core\utils\_json_to_pydantic.py", line 583, in schema_to_pydantic_model
return _JSONSchemaToPydantic().json_schema_to_pydantic(schema, model_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_core\utils\_json_to_pydantic.py", line 175, in json_schema_to_pydantic
return self._json_schema_to_model(schema, model_name, root_schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_core\utils\_json_to_pydantic.py", line 342, in _json_schema_to_model
field_type = self._json_schema_to_model(value, f"{model_name}_{key}", root_schema)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_core\utils\_json_to_pydantic.py", line 318, in _json_schema_to_model
field_type = self.get_ref(ref_name)
^^^^^^^^^^^^^^^^^^^^^^
File "D:\03 - document\12 - 大模型\斌哥交接\code\sample\venv\Lib\site-packages\autogen_core\utils\_json_to_pydantic.py", line 122, in get_ref
raise ReferenceNotFoundError(
autogen_core.utils._json_to_pydantic.ReferenceNotFoundError: Reference `WindowsSortOption` not found in cache. Available: []
when i use McpWorkbench like this:
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
from model_utils import get_vllm_qwen3_30b_a3b_client
async def main() -> None:
params = StdioServerParams(
command="python",
args=["-m","mcp_server_everything_search"],
env={"EVERYTHING_SDK_PATH": "D:\\02 - programs\\Everything-SDK\\dll\\Everything64.dll"},
read_timeout_seconds=60,
)
model_client = get_vllm_qwen3_30b_a3b_client()
# You can also use `start()` and `stop()` to manage the session.
async with McpWorkbench(server_params=params) as workbench:
tools = await workbench.list_tools()
print(tools)
if __name__ == "__main__":
asyncio.run(main())
it looks fine:
[{
'name': 'search',
'description': 'Universal file search tool for Windows\n\nCurrent Implementation:\nUsing Everything SDK with full search capabilities\n\nSearch Syntax Guide:\nSearch for files and folders using Everything SDK.\n \nFeatures:\n- Fast file and folder search across all indexed drives\n- Support for wildcards and boolean operators\n- Multiple sort options (name, path, size, dates)\n- Case-sensitive and whole word matching\n- Regular expression support\n- Path matching\nSearch Syntax Guide:\n1. Basic Operators:\n - space: AND operator\n - |: OR operator\n - !: NOT operator\n - < >: Grouping\n - " ": Search for an exact phrase\n2. Wildcards:\n - *: Matches zero or more characters\n - ?: Matches exactly one character\n Note: Wildcards match the whole filename by default. Disable Match whole filename to match wildcards anywhere.\n3. Functions:\n Size and Count:\n - size:<size>[kb|mb|gb]: Search by file size\n - count:<max>: Limit number of results\n - childcount:<count>: Folders with specific number of children\n - childfilecount:<count>: Folders with specific number of files\n - childfoldercount:<count>: Folders with specific number of subfolders\n - len:<length>: Match filename length\n Dates:\n - datemodified:<date>, dm:<date>: Modified date\n - dateaccessed:<date>, da:<date>: Access date\n - datecreated:<date>, dc:<date>: Creation date\n - daterun:<date>, dr:<date>: Last run date\n - recentchange:<date>, rc:<date>: Recently changed date\n \n Date formats: YYYY[-MM[-DD[Thh[:mm[:ss[.sss]]]]]] or today, yesterday, lastweek, etc.\n \n File Attributes and Types:\n - attrib:<attributes>, attributes:<attributes>: Search by file attributes (A:Archive, H:Hidden, S:System, etc.)\n - type:<type>: Search by file type\n - ext:<list>: Search by semicolon-separated extensions\n \n Path and Name:\n - path:<path>: Search in specific path\n - parent:<path>, infolder:<path>, nosubfolders:<path>: Search in path excluding subfolders\n - startwith:<text>: Files starting with text\n - endwith:<text>: Files ending with text\n - child:<filename>: Folders containing specific child\n - depth:<count>, parents:<count>: Files at specific folder depth\n - root: Files with no parent folder\n - shell:<name>: Search in known shell folders\n Duplicates and Lists:\n - dupe, namepartdupe, attribdupe, dadupe, dcdupe, dmdupe, sizedupe: Find duplicates\n - filelist:<list>: Search pipe-separated (|) file list\n - filelistfilename:<filename>: Search files from list file\n - frn:<frnlist>: Search by File Reference Numbers\n - fsi:<index>: Search by file system index\n - empty: Find empty folders\n4. Function Syntax:\n - function:value: Equal to value\n - function:<=value: Less than or equal\n - function:<value: Less than\n - function:=value: Equal to\n - function:>value: Greater than\n - function:>=value: Greater than or equal\n - function:start..end: Range of values\n - function:start-end: Range of values\n5. Modifiers:\n - case:, nocase:: Enable/disable case sensitivity\n - file:, folder:: Match only files or folders\n - path:, nopath:: Match full path or filename only\n - regex:, noregex:: Enable/disable regex\n - wfn:, nowfn:: Match whole filename or anywhere\n - wholeword:, ww:: Match whole words only\n - wildcards:, nowildcards:: Enable/disable wildcards\nExamples:\n1. Find Python files modified today:\n ext:py datemodified:today\n2. Find large video files:\n ext:mp4|mkv|avi size:>1gb\n3. Find files in specific folder:\n path:C:\\Projects *.js\n\n',
'parameters': {
'type': 'object',
'properties': {
'base': {
'description': 'Base search parameters common to all platforms.',
'properties': {
'query': {
'description': 'Search query string. See platform-specific documentation for syntax details.',
'title': 'Query',
'type': 'string'
},
'max_results': {
'default': 100,
'description': 'Maximum number of results to return (1-1000)',
'maximum': 1000,
'minimum': 1,
'title': 'Max Results',
'type': 'integer'
}
},
'required': ['query'],
'title': 'BaseSearchQuery',
'type': 'object'
},
'windows_params': {
'$defs': {
'WindowsSortOption': {
'description': 'Sort options for Windows Everything search.',
'enum': [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14],
'title': 'WindowsSortOption',
'type': 'integer'
}
},
'description': 'Windows-specific search parameters for Everything SDK.',
'properties': {
'match_path': {
'default': False,
'description': 'Match against full path instead of filename only',
'title': 'Match Path',
'type': 'boolean'
},
'match_case': {
'default': False,
'description': 'Enable case-sensitive search',
'title': 'Match Case',
'type': 'boolean'
},
'match_whole_word': {
'default': False,
'description': 'Match whole words only',
'title': 'Match Whole Word',
'type': 'boolean'
},
'match_regex': {
'default': False,
'description': 'Enable regex search',
'title': 'Match Regex',
'type': 'boolean'
},
'sort_by': {
'$ref': '#/$defs/WindowsSortOption',
'default': 1,
'description': 'Sort order for results'
}
},
'title': 'WindowsSpecificParams',
'type': 'object'
}
},
'required': ['base'],
'additionalProperties': False
}
}
]
Which packages was the bug in?
Python Extensions (autogen-ext)
AutoGen library version.
Python 0.6.4
Other library version.
No response
Model used
No response
Model provider
None
Other model provider
No response
Python version
3.12
.NET version
None
Operating system
Windows