Skip to content

Commit 205314c

Browse files
Add sse_retry_interval setting to FastMCP
Expose the retry_interval parameter through FastMCP so servers can configure the SSE retry field in priming events. This allows clients to know the recommended reconnection interval. - Add sse_retry_interval to Settings class - Pass through to StreamableHTTPSessionManager - Update everything_server to use 3000ms interval for conformance tests
1 parent d6c70ba commit 205314c

File tree

2 files changed

+6
-0
lines changed
  • examples/servers/everything-server/mcp_everything_server
  • src/mcp/server/fastmcp

2 files changed

+6
-0
lines changed

examples/servers/everything-server/mcp_everything_server/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ async def replay_events_after(
8888
mcp = FastMCP(
8989
name="mcp-conformance-test-server",
9090
event_store=event_store,
91+
sse_retry_interval=3000, # 3 seconds
9192
)
9293

9394

src/mcp/server/fastmcp/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ class Settings(BaseSettings, Generic[LifespanResultT]):
102102
json_response: bool
103103
stateless_http: bool
104104
"""Define if the server should create a new transport per request."""
105+
sse_retry_interval: int | None
106+
"""SSE retry interval in milliseconds sent in priming event for client reconnection."""
105107

106108
# resource settings
107109
warn_on_duplicate_resources: bool
@@ -161,6 +163,7 @@ def __init__( # noqa: PLR0913
161163
streamable_http_path: str = "/mcp",
162164
json_response: bool = False,
163165
stateless_http: bool = False,
166+
sse_retry_interval: int | None = None,
164167
warn_on_duplicate_resources: bool = True,
165168
warn_on_duplicate_tools: bool = True,
166169
warn_on_duplicate_prompts: bool = True,
@@ -180,6 +183,7 @@ def __init__( # noqa: PLR0913
180183
streamable_http_path=streamable_http_path,
181184
json_response=json_response,
182185
stateless_http=stateless_http,
186+
sse_retry_interval=sse_retry_interval,
183187
warn_on_duplicate_resources=warn_on_duplicate_resources,
184188
warn_on_duplicate_tools=warn_on_duplicate_tools,
185189
warn_on_duplicate_prompts=warn_on_duplicate_prompts,
@@ -939,6 +943,7 @@ def streamable_http_app(self) -> Starlette:
939943
json_response=self.settings.json_response,
940944
stateless=self.settings.stateless_http, # Use the stateless setting
941945
security_settings=self.settings.transport_security,
946+
retry_interval=self.settings.sse_retry_interval,
942947
)
943948

944949
# Create the ASGI handler

0 commit comments

Comments
 (0)