Skip to content

Commit f267975

Browse files
Refactor tools integration and remove ToolsAdapter
- Deleted the ToolsAdapter class to streamline the tools integration process. - Updated server and test files to directly utilize the new plugin system for tool registration and execution. - Introduced a new YAML tools loader to handle dynamic tool implementations from YAML files. - Adjusted tests to reflect changes in tool initialization and registration, ensuring compatibility with the new structure. - Cleaned up obsolete entries in tools.yaml, marking deprecated tools as disabled.
1 parent d0f60d9 commit f267975

File tree

7 files changed

+702
-718
lines changed

7 files changed

+702
-718
lines changed

mcp_core/tests/test_tools.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
if parent_dir not in sys.path:
1919
sys.path.insert(0, parent_dir)
2020

21-
# Import the ToolsAdapter
22-
from mcp_core.tools_adapter import ToolsAdapter
21+
# Import the direct tool system
22+
from mcp_tools.plugin import registry, discover_and_register_tools
23+
from mcp_tools.dependency import injector
2324

2425
@pytest.fixture
2526
def yaml_data():
@@ -36,36 +37,39 @@ def yaml_data():
3637
return yaml.safe_load(f)
3738

3839
@pytest.fixture
39-
def tools_adapter():
40-
"""Create a ToolsAdapter instance as a fixture"""
41-
return ToolsAdapter()
40+
def tool_system():
41+
"""Initialize the tool system and return registry and injector"""
42+
discover_and_register_tools()
43+
injector.resolve_all_dependencies()
44+
return {"registry": registry, "injector": injector}
4245

4346
def test_tools_yaml_exists():
4447
"""Test that tools.yaml exists in the server directory"""
4548
server_dir = Path(parent_dir) / "server"
4649
yaml_path = server_dir / "tools.yaml"
4750
assert yaml_path.exists(), f"tools.yaml not found at {yaml_path}"
4851

49-
def test_tools_adapter_initialization(tools_adapter):
50-
"""Test that ToolsAdapter can be initialized"""
51-
assert tools_adapter is not None
52+
def test_tool_system_initialization(tool_system):
53+
"""Test that the tool system can be initialized"""
54+
assert tool_system["registry"] is not None
55+
assert tool_system["injector"] is not None
5256

5357
# Get all registered tools
54-
tools = tools_adapter.get_tools()
58+
tools = list(tool_system["injector"].instances.values())
5559
assert len(tools) > 0, "No tools were registered"
5660

57-
def test_tools_from_yaml_are_registered(yaml_data, tools_adapter):
58-
"""Test that tools defined in tools.yaml are registered in the adapter"""
61+
def test_tools_from_yaml_are_registered(yaml_data, tool_system):
62+
"""Test that tools defined in tools.yaml are registered in the system"""
5963
# Get tools from yaml
6064
yaml_tool_names = yaml_data.get('tools', {}).keys()
6165
assert len(yaml_tool_names) > 0, "No tools found in tools.yaml"
6266

6367
# Get registered tools
64-
tools = tools_adapter.get_tools()
68+
tools = list(tool_system["injector"].instances.values())
6569
registered_tool_names = [tool.name for tool in tools]
6670

6771
# Verify at least some tools are registered
68-
assert len(registered_tool_names) > 0, "No tools registered in the adapter"
72+
assert len(registered_tool_names) > 0, "No tools registered in the system"
6973

7074
# Count how many tools from yaml are registered
7175
registered_count = 0

0 commit comments

Comments
 (0)