Skip to content

[BUG]: Problem with session management for stateful MCP Servers #4205

@dawid-nowak

Description

@dawid-nowak

🐞 Bug Summary

There seem to be a problem with a ContextForge session management when running against stateful MCP Gateways over HTTP Streamable transport


🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • [*] Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

🔁 Steps to Reproduce

  1. Start a stateful MCP Gateway for example : git clone `https://github.com/modelcontextprotocol/rust-sdk/; cd rust-sdk/examples/servers; cargo run --example servers_counter_streamhttp. This should start MCP counter server on 127.0.0.1:8000
  2. make serve and configure context forge (add servers and gateways, etc.)
  3. From a client Initialize MCP session (mcp inspector or curl)
  4. Increase the counter N times (mcp inspector or curl)
  5. Get the counter -> response should be N (mcp inspector or curl)

🤔 Expected Behavior

Minimally, we would expect that if there is only one client then the counter works for that single client.

Long term expected behavior is that the counter stays consistent per mcp-session. So if for every client that goes through Intialize/Notify process, there should be a unique session with an independent counter. Unfortunately, this doesn't seem to be the case. It looks like ContextForge will create ONE session with the MCP server at startup and will re-use this session for all future interactions.


📓 Logs / Error Output


🧠 Environment Info

Commit #77bd03d2cca41f9c3597d5d7abc8012ad54d38fa

Metadata

Metadata

Labels

bugSomething isn't workingtriageIssues / Features awaiting triage

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions