Skip to content

Commit 09f2a26

Browse files
authored
Added test case for issue 19211. No code change (#20201)
1 parent 247e8f5 commit 09f2a26

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

llama-index-integrations/tools/llama-index-tools-mcp/tests/test_tools_mcp.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,40 @@ def test_additional_properties_false_parsing(client: BasicMCPClient):
151151
assert tool_spec._is_simple_object(schema_dict)
152152
result_type = tool_spec._create_dict_type(schema_dict, {})
153153
assert result_type == Dict[str, str]
154+
155+
156+
@pytest.mark.asyncio
157+
async def test_resource_tool_uses_uri_not_name(client: BasicMCPClient):
158+
"""
159+
Tests that a tool from a static resource is executable.
160+
161+
This test is designed to FAIL with the current bug, because the tool's
162+
internal function is created with the resource's name ('get_app_config')
163+
instead of its URI ('config://app'), causing the client call to fail.
164+
"""
165+
tool_spec = McpToolSpec(
166+
client, allowed_tools=["get_app_config"], include_resources=True
167+
)
168+
tools = await tool_spec.to_tool_list_async()
169+
170+
assert len(tools) == 1
171+
tool = tools[0]
172+
assert tool.metadata.name == "get_app_config"
173+
174+
# This call will fail due to the bug.
175+
result = await tool.acall()
176+
assert "MCP Test Server" in result.content
177+
178+
179+
@pytest.mark.asyncio
180+
async def test_dynamic_resource_template_tool_is_created(client: BasicMCPClient):
181+
"""
182+
Tests that a tool is created for a dynamic resource template.
183+
"""
184+
tool_spec = McpToolSpec(client, include_resources=True)
185+
tools = await tool_spec.to_tool_list_async()
186+
187+
# The server.py defines a dynamic resource template named 'get_user_profile'.
188+
# This should now be found.
189+
tool_names = {t.metadata.name for t in tools}
190+
assert "get_user_profile" in tool_names

0 commit comments

Comments
 (0)