Skip to content

Commit a0c4b18

Browse files
committed
ruff
1 parent 7e090f5 commit a0c4b18

File tree

4 files changed

+20
-26
lines changed

4 files changed

+20
-26
lines changed

examples/servers/simple-streamablehttp-stateless/mcp_simple_streamablehttp_stateless/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
if __name__ == "__main__":
44
# Click will handle CLI arguments
55
import sys
6-
6+
77
sys.exit(main()) # type: ignore[call-arg]

src/mcp/shared/session.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,19 +384,19 @@ async def _receive_loop(self) -> None:
384384
cancelled_id = notification.root.params.requestId
385385
if cancelled_id in self._in_flight:
386386
await self._in_flight[cancelled_id].cancel()
387-
# Handle progress notifications
388-
elif isinstance(notification.root, ProgressNotification):
389-
progress_token = notification.root.params.progressToken
390-
# If there is a progress callback for this token,
391-
# call it with the progress information
392-
if progress_token in self._progress_callbacks:
393-
callback = self._progress_callbacks[progress_token]
394-
callback(
395-
notification.root.params.progress,
396-
notification.root.params.total,
397-
notification.root.params.message,
398-
)
399387
else:
388+
# Handle progress notifications callback
389+
if isinstance(notification.root, ProgressNotification):
390+
progress_token = notification.root.params.progressToken
391+
# If there is a progress callback for this token,
392+
# call it with the progress information
393+
if progress_token in self._progress_callbacks:
394+
callback = self._progress_callbacks[progress_token]
395+
callback(
396+
notification.root.params.progress,
397+
notification.root.params.total,
398+
notification.root.params.message,
399+
)
400400
await self._received_notification(notification)
401401
await self._handle_incoming(notification)
402402
except Exception as e:

tests/client/test_list_methods_cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
async def test_list_tools_cursor_parameter():
1313
"""Test that the cursor parameter is accepted for list_tools.
14-
14+
1515
Note: FastMCP doesn't currently implement pagination, so this test
1616
only verifies that the cursor parameter is accepted by the client.
1717
"""

tests/server/fastmcp/test_integration.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import time
1111
from collections.abc import Generator
1212

13-
import anyio
1413
import pytest
1514
import uvicorn
1615
from pydantic import AnyUrl
@@ -20,13 +19,15 @@
2019
from mcp.client.sse import sse_client
2120
from mcp.client.streamable_http import streamablehttp_client
2221
from mcp.server.fastmcp import FastMCP
22+
from mcp.server.fastmcp.resources import FunctionResource
2323
from mcp.shared.context import RequestContext
2424
from mcp.types import (
2525
CreateMessageRequestParams,
2626
CreateMessageResult,
2727
GetPromptResult,
2828
InitializeResult,
2929
ReadResourceResult,
30+
SamplingMessage,
3031
TextContent,
3132
TextResourceContents,
3233
)
@@ -123,8 +124,6 @@ def echo(message: str) -> str:
123124
# Tool with sampling capability
124125
@mcp.tool(description="A tool that uses sampling to generate content")
125126
async def sampling_tool(prompt: str, ctx: Context) -> str:
126-
from mcp.types import SamplingMessage, TextContent
127-
128127
await ctx.info(f"Requesting sampling for prompt: {prompt}")
129128

130129
# Request sampling from the client
@@ -161,10 +160,6 @@ async def notification_tool(message: str, ctx: Context) -> str:
161160
return f"Sent notifications and logs for: {message}"
162161

163162
# Resource - static
164-
from pydantic import AnyUrl
165-
166-
from mcp.server.fastmcp.resources import FunctionResource
167-
168163
def get_static_info() -> str:
169164
return "This is static resource content"
170165

@@ -293,7 +288,7 @@ def run_streamable_http_server(server_port: int) -> None:
293288
server.run()
294289

295290

296-
def run_comprehensive_streamable_http_server(server_port: int) -> None:
291+
def run_everything_streamable_http_server(server_port: int) -> None:
297292
"""Run the comprehensive StreamableHTTP server with all features."""
298293
_, app = make_everything_fastmcp_streamable_http_app()
299294
server = uvicorn.Server(
@@ -492,7 +487,6 @@ async def test_fastmcp_stateless_streamable_http(
492487
assert tool_result.content[0].text == f"Echo: test_{i}"
493488

494489

495-
# Fixtures for comprehensive servers
496490
@pytest.fixture
497491
def everything_server_port() -> int:
498492
"""Get a free port for testing the comprehensive server."""
@@ -557,12 +551,12 @@ def everything_server(everything_server_port: int) -> Generator[None, None, None
557551

558552

559553
@pytest.fixture()
560-
def comprehensive_streamable_http_server(
554+
def everything_streamable_http_server(
561555
everything_http_server_port: int,
562556
) -> Generator[None, None, None]:
563557
"""Start the comprehensive StreamableHTTP server in a separate process."""
564558
proc = multiprocessing.Process(
565-
target=run_comprehensive_streamable_http_server,
559+
target=run_everything_streamable_http_server,
566560
args=(everything_http_server_port,),
567561
daemon=True,
568562
)
@@ -858,7 +852,7 @@ async def message_handler(message):
858852

859853
@pytest.mark.anyio
860854
async def test_fastmcp_all_features_streamable_http(
861-
comprehensive_streamable_http_server: None, everything_http_server_url: str
855+
everything_streamable_http_server: None, everything_http_server_url: str
862856
) -> None:
863857
"""Test all MCP features work correctly with StreamableHTTP transport."""
864858

0 commit comments

Comments
 (0)