Skip to content

Commit cf7103e

Browse files
author
Tapan Chugh
committed
nit: Remove unnecessary explicit URI parameters in tests
1 parent 5a752ad commit cf7103e

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

tests/server/fastmcp/test_title.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from mcp.server.fastmcp.resources import FunctionResource
88
from mcp.shared.memory import create_connected_server_and_client_session
99
from mcp.shared.metadata_utils import get_display_name
10-
from mcp.types import PROMPT_SCHEME, TOOL_SCHEME, Prompt, Resource, ResourceTemplate, Tool, ToolAnnotations
10+
from mcp.types import Prompt, Resource, ResourceTemplate, Tool, ToolAnnotations
1111

1212

1313
@pytest.mark.anyio
@@ -181,23 +181,21 @@ async def test_get_display_name_utility():
181181
"""Test the get_display_name utility function."""
182182

183183
# Test tool precedence: title > annotations.title > name
184-
tool_name_only = Tool(name="test_tool", uri=f"{TOOL_SCHEME}/test_tool", inputSchema={})
184+
tool_name_only = Tool(name="test_tool", inputSchema={})
185185
assert get_display_name(tool_name_only) == "test_tool"
186186

187-
tool_with_title = Tool(name="test_tool", uri=f"{TOOL_SCHEME}/test_tool", title="Test Tool", inputSchema={})
187+
tool_with_title = Tool(name="test_tool", title="Test Tool", inputSchema={})
188188
assert get_display_name(tool_with_title) == "Test Tool"
189189

190190
tool_with_annotations = Tool(
191191
name="test_tool",
192-
uri=f"{TOOL_SCHEME}/test_tool",
193192
inputSchema={},
194193
annotations=ToolAnnotations(title="Annotated Tool"),
195194
)
196195
assert get_display_name(tool_with_annotations) == "Annotated Tool"
197196

198197
tool_with_both = Tool(
199198
name="test_tool",
200-
uri=f"{TOOL_SCHEME}/test_tool",
201199
title="Primary Title",
202200
inputSchema={},
203201
annotations=ToolAnnotations(title="Secondary Title"),
@@ -211,10 +209,10 @@ async def test_get_display_name_utility():
211209
resource_with_title = Resource(uri=AnyUrl("file://test"), name="test_res", title="Test Resource")
212210
assert get_display_name(resource_with_title) == "Test Resource"
213211

214-
prompt = Prompt(name="test_prompt", uri=f"{PROMPT_SCHEME}/test_prompt")
212+
prompt = Prompt(name="test_prompt")
215213
assert get_display_name(prompt) == "test_prompt"
216214

217-
prompt_with_title = Prompt(name="test_prompt", uri=f"{PROMPT_SCHEME}/test_prompt", title="Test Prompt")
215+
prompt_with_title = Prompt(name="test_prompt", title="Test Prompt")
218216
assert get_display_name(prompt_with_title) == "Test Prompt"
219217

220218
template = ResourceTemplate(uriTemplate="file://{id}", name="test_template")

tests/server/test_lowlevel_input_validation.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from mcp.server.session import ServerSession
1515
from mcp.shared.message import SessionMessage
1616
from mcp.shared.session import RequestResponder
17-
from mcp.types import TOOL_SCHEME, CallToolResult, ClientResult, ServerNotification, ServerRequest, TextContent, Tool
17+
from mcp.types import CallToolResult, ClientResult, ServerNotification, ServerRequest, TextContent, Tool
1818

1919

2020
async def run_tool_test(
@@ -99,7 +99,6 @@ async def handle_messages():
9999
def create_add_tool() -> Tool:
100100
"""Create a standard 'add' tool for testing."""
101101
return Tool(
102-
uri=f"{TOOL_SCHEME}/add",
103102
name="add",
104103
description="Add two numbers",
105104
inputSchema={
@@ -190,7 +189,6 @@ async def test_cache_refresh_on_missing_tool():
190189
"""Test that tool cache is refreshed when tool is not found."""
191190
tools = [
192191
Tool(
193-
uri=f"{TOOL_SCHEME}/multiply",
194192
name="multiply",
195193
description="Multiply two numbers",
196194
inputSchema={
@@ -232,7 +230,6 @@ async def test_enum_constraint_validation():
232230
"""Test that enum constraints are validated."""
233231
tools = [
234232
Tool(
235-
uri=f"{TOOL_SCHEME}/greet",
236233
name="greet",
237234
description="Greet someone",
238235
inputSchema={
@@ -270,7 +267,6 @@ async def test_tool_not_in_list_logs_warning(caplog):
270267
"""Test that calling a tool not in list_tools logs a warning and skips validation."""
271268
tools = [
272269
Tool(
273-
uri=f"{TOOL_SCHEME}/add",
274270
name="add",
275271
description="Add two numbers",
276272
inputSchema={

tests/shared/test_streamable_http.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
)
4646
from mcp.shared.session import RequestResponder
4747
from mcp.types import (
48-
TOOL_SCHEME,
4948
InitializeResult,
5049
TextContent,
5150
TextResourceContents,
@@ -147,31 +146,26 @@ async def handle_list_tools(_) -> list[Tool]:
147146
inputSchema={"type": "object", "properties": {}},
148147
),
149148
Tool(
150-
uri=f"{TOOL_SCHEME}/test_tool_with_standalone_notification",
151149
name="test_tool_with_standalone_notification",
152150
description="A test tool that sends a notification",
153151
inputSchema={"type": "object", "properties": {}},
154152
),
155153
Tool(
156-
uri=f"{TOOL_SCHEME}/long_running_with_checkpoints",
157154
name="long_running_with_checkpoints",
158155
description="A long-running tool that sends periodic notifications",
159156
inputSchema={"type": "object", "properties": {}},
160157
),
161158
Tool(
162-
uri=f"{TOOL_SCHEME}/test_sampling_tool",
163159
name="test_sampling_tool",
164160
description="A tool that triggers server-side sampling",
165161
inputSchema={"type": "object", "properties": {}},
166162
),
167163
Tool(
168-
uri=f"{TOOL_SCHEME}/wait_for_lock_with_notification",
169164
name="wait_for_lock_with_notification",
170165
description="A tool that sends a notification and waits for lock",
171166
inputSchema={"type": "object", "properties": {}},
172167
),
173168
Tool(
174-
uri=f"{TOOL_SCHEME}/release_lock",
175169
name="release_lock",
176170
description="A tool that releases the lock",
177171
inputSchema={"type": "object", "properties": {}},

0 commit comments

Comments
 (0)