Skip to content

Clean up MCP sessions on delete#27

Merged
dawid-nowak merged 3 commits into
mainfrom
user/luca/mcp-session-delete-cleanup
Jun 4, 2026
Merged

Clean up MCP sessions on delete#27
dawid-nowak merged 3 commits into
mainfrom
user/luca/mcp-session-delete-cleanup

Conversation

@lucarlig

@lucarlig lucarlig commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Splits MCP session DELETE cleanup out of the larger session/SSE work so this PR stays focused.

This PR:

  • replaces the custom tower-layer session-id layer with Axum middleware state so DELETE can run cleanup after RMCP handles the request
  • keeps Mcp-session-id optional; requests without the header pass through, including DELETE
  • inserts SessionId extensions when the header is present, then uses match request.method() to run DELETE cleanup only after a successful downstream response
  • scopes stored user sessions by authenticated principal plus downstream MCP session id
  • scopes backend transport keys and cleanup by authenticated principal plus downstream MCP session id, so one user cannot clean up another user
  • removes the session-store entry and in-memory backend transports after RMCP accepts DELETE
  • removes the now-unused tower-layer dependency

Verification:

  • cargo fmt --all --check
  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • cargo test --locked --workspace
  • CI: fmt, clippy, cargo-deny, cargo-shear, test, build, bench

@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch from 8f7a9a7 to dba60c8 Compare June 2, 2026 13:01
@lucarlig
lucarlig requested a review from dawid-nowak June 2, 2026 13:41
@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch from dba60c8 to 65ca993 Compare June 3, 2026 08:46
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch 3 times, most recently from d53aa18 to eab6832 Compare June 3, 2026 13:58
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch from eab6832 to 3e5387f Compare June 3, 2026 14:17
Comment thread crates/contextforge-gateway-rs-lib/src/layers/session_id.rs Outdated
Comment thread crates/contextforge-gateway-rs-lib/src/layers/session_id.rs Outdated
Comment thread crates/contextforge-gateway-rs-lib/src/layers/session_id.rs Outdated
@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch 4 times, most recently from 1ad0d13 to a570c24 Compare June 3, 2026 16:05
@lucarlig
lucarlig requested a review from dawid-nowak June 3, 2026 16:16
@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch from a570c24 to e5dbcb3 Compare June 4, 2026 08:09
Signed-off-by: lucarlig <luca.carlig@ibm.com>
@lucarlig
lucarlig force-pushed the user/luca/mcp-session-delete-cleanup branch from e5dbcb3 to 7db1d3c Compare June 4, 2026 08:11
@dawid-nowak
dawid-nowak merged commit b53258e into main Jun 4, 2026
7 checks passed
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.

2 participants