Skip to content

Conversation

@Aaronontheweb
Copy link
Member

Summary

Enables stateless mode for the MCP HTTP transport to eliminate session management issues causing "Session not found" errors when clients reconnect or the server restarts.

Changes

  • Configure WithHttpTransport() to use options.Stateless = true

Benefits

  • No session tracking: Each request is independent - no session IDs required
  • No Data Protection: Eliminates cryptographic key management complexity
  • Restart resilient: Server restarts don't invalidate client connections
  • Multi-instance ready: Works across multiple server instances without sticky sessions

Trade-offs

  • McpServer.ClientInfo will be null in request handlers (client name/version not tracked)

Testing

This resolves the "Session not found" (HTTP 404) errors when using MCP clients like Claude Code with the v1.7.1-beta1 release.

Related

Configure the MCP server to use stateless mode by setting
options.Stateless = true in WithHttpTransport(). This eliminates
session management issues that cause "Session not found" errors
when the server restarts or clients reconnect.

Benefits:
- No session IDs required - each request is independent
- No Data Protection key management needed
- Survives server restarts without breaking client connections
- Works across multiple server instances without session affinity

Trade-off: McpServer.ClientInfo will be null as client metadata
is not tracked across requests in stateless mode.

Resolves connection issues with MCP clients including Claude Code.
@Aaronontheweb Aaronontheweb merged commit e811c32 into petabridge:dev Oct 10, 2025
2 checks passed
@Aaronontheweb Aaronontheweb deleted the fix/mcp-stateless-mode branch October 10, 2025 20:49
Aaronontheweb added a commit to Aaronontheweb/memorizer-v1 that referenced this pull request Oct 10, 2025
Add PR petabridge#64 (Enable stateless mode for MCP HTTP transport) to
the 1.7.1 release notes under Bug Fixes section. This fix
resolves "Session not found" errors experienced by MCP clients
when reconnecting or after server restarts.

Updates both RELEASE_NOTES.md and Directory.Build.props with
the new bug fix entry.
Aaronontheweb added a commit that referenced this pull request Oct 10, 2025
* Enable stateless mode for MCP HTTP transport

Configure the MCP server to use stateless mode by setting
options.Stateless = true in WithHttpTransport(). This eliminates
session management issues that cause "Session not found" errors
when the server restarts or clients reconnect.

Benefits:
- No session IDs required - each request is independent
- No Data Protection key management needed
- Survives server restarts without breaking client connections
- Works across multiple server instances without session affinity

Trade-off: McpServer.ClientInfo will be null as client metadata
is not tracked across requests in stateless mode.

Resolves connection issues with MCP clients including Claude Code.

* Update release notes with stateless mode fix

Add PR #64 (Enable stateless mode for MCP HTTP transport) to
the 1.7.1 release notes under Bug Fixes section. This fix
resolves "Session not found" errors experienced by MCP clients
when reconnecting or after server restarts.

Updates both RELEASE_NOTES.md and Directory.Build.props with
the new bug fix entry.
Aaronontheweb added a commit that referenced this pull request Oct 10, 2025
* Prepare release 1.7.1

* Update release notes with stateless mode fix (#65)

* Enable stateless mode for MCP HTTP transport

Configure the MCP server to use stateless mode by setting
options.Stateless = true in WithHttpTransport(). This eliminates
session management issues that cause "Session not found" errors
when the server restarts or clients reconnect.

Benefits:
- No session IDs required - each request is independent
- No Data Protection key management needed
- Survives server restarts without breaking client connections
- Works across multiple server instances without session affinity

Trade-off: McpServer.ClientInfo will be null as client metadata
is not tracked across requests in stateless mode.

Resolves connection issues with MCP clients including Claude Code.

* Update release notes with stateless mode fix

Add PR #64 (Enable stateless mode for MCP HTTP transport) to
the 1.7.1 release notes under Bug Fixes section. This fix
resolves "Session not found" errors experienced by MCP clients
when reconnecting or after server restarts.

Updates both RELEASE_NOTES.md and Directory.Build.props with
the new bug fix entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant