clockworklabs / clockworklabs/SpacetimeDB

Make egress-tracking middleware apply to MCP route

Open
#5,685 0 comments 0 reactions 1 assignee View on GitHub

@clockwork-tien is already working on this.

Since Aug 7, 2026.

Dominant language
Rust
Stars
25.2k
Forks
1.1k
Avg merge
2d 7h
Merged PRs (30d)
46

Description

The middleware introduced by #5611 , resolve_database_name_and_count_response_egress_middleware, does not apply to the POST /database/:name_or_identity/mcp route. This is unfortunate, as MCP requests may generate large user-controlled responses, and so we would very much like to measure their response egress bytes. I found it challenging to apply the middleware to the MCP route due to its non-standard handling of its name_or_identity argument. I especially did not want to do this while there are outstanding PRs to update the MCP route; as of my writing this, #5582 has just merged and #5672 is outstanding.

Rewrite the MCP route so that instead of taking a NameOrIdentity as a path parameter, it takes a Database via the ResolvedDatabase extension. This will necessarily move name resolution and 404 responses out of and before the route handler. Move the registration of the MCP route in DatabaseRoute::into_router so that the middleware applies to it.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.