-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_mcp.py
More file actions
29 lines (19 loc) · 985 Bytes
/
test_mcp.py
File metadata and controls
29 lines (19 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pytest
from thirdweb_ai.tools.tool import Tool
def test_get_mcp_tools(test_tools: list[Tool]):
"""Test converting thirdweb tools to MCP tools."""
pytest.importorskip("mcp.types")
import mcp.types as mcp_types # type: ignore[import]
from thirdweb_ai.adapters.mcp import get_mcp_tools
# Convert tools to MCP tools
mcp_tools = get_mcp_tools(test_tools)
# Assert we got the correct number of tools
assert len(mcp_tools) == len(test_tools)
# Check all tools were properly converted
assert all(isinstance(tool, mcp_types.Tool) for tool in mcp_tools)
# Check properties were preserved
assert [tool.name for tool in mcp_tools] == [tool.name for tool in test_tools]
assert [tool.description for tool in mcp_tools] == [tool.description for tool in test_tools]
# Check that input schemas were set correctly
for i, tool in enumerate(mcp_tools):
assert tool.inputSchema == test_tools[i].schema.get("parameters")