Fix formatting per pre-commit hooks

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Jeremiah Lowin 2025-06-19 18:21:45 -04:00
commit 60c6441d7b
2 changed files with 9 additions and 8 deletions

View file

@ -181,15 +181,15 @@ class Context:
@property
def session_id(self) -> str | None:
"""Get the MCP session ID for HTTP transports.
Returns the session ID that can be used as a key for session-based
data storage (e.g., Redis) to share data between tool calls within
the same client session.
Returns:
The session ID for HTTP transports (SSE, StreamableHTTP), or None
for stdio and in-memory transports which don't use session IDs.
Example:
```python
@server.tool
@ -202,6 +202,7 @@ class Context:
"""
try:
from fastmcp.server.dependencies import get_http_headers
headers = get_http_headers(include_all=True)
return headers.get("mcp-session-id")
except RuntimeError:

View file

@ -92,7 +92,7 @@ class TestSessionId:
def test_session_id_with_http_headers(self, context):
"""Test that session_id returns the value from mcp-session-id header."""
mock_headers = {"mcp-session-id": "test-session-123"}
with patch(
"fastmcp.server.dependencies.get_http_headers", return_value=mock_headers
):
@ -101,15 +101,15 @@ class TestSessionId:
def test_session_id_without_http_headers(self, context):
"""Test that session_id returns None when no HTTP headers are available."""
with patch(
"fastmcp.server.dependencies.get_http_headers",
side_effect=RuntimeError("No active HTTP request found.")
"fastmcp.server.dependencies.get_http_headers",
side_effect=RuntimeError("No active HTTP request found."),
):
assert context.session_id is None
def test_session_id_with_missing_header(self, context):
"""Test that session_id returns None when mcp-session-id header is missing."""
mock_headers = {"other-header": "value"}
with patch(
"fastmcp.server.dependencies.get_http_headers", return_value=mock_headers
):
@ -118,7 +118,7 @@ class TestSessionId:
def test_session_id_with_empty_header(self, context):
"""Test that session_id returns None when mcp-session-id header is empty."""
mock_headers = {"mcp-session-id": ""}
with patch(
"fastmcp.server.dependencies.get_http_headers", return_value=mock_headers
):