Skip to content

Make egress-tracking middleware apply to MCP route - #5775

Merged
clockwork-tien merged 1 commit into
masterfrom
tien/feat/egress-mcp-route
Aug 24, 2026
Merged

Make egress-tracking middleware apply to MCP route#5775
clockwork-tien merged 1 commit into
masterfrom
tien/feat/egress-mcp-route

Conversation

@clockwork-tien

@clockwork-tien clockwork-tien commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

  • Add egress tracking middleware to MCP route
    • Count MCP egress by moving /v1/database/:name_or_identity/mcp out of the bypass list into counted_db_router
    • Additional updates to MCP route to support this with refactoring of the handler and tool signatures

API and ABI breaking changes

None.

Expected complexity level and risk

2

Testing

  • I tested the implementation, tests, lint and format checks passed

@clockwork-tien
clockwork-tien marked this pull request as ready for review August 21, 2026 14:13
Comment thread crates/client-api/src/routes/mcp.rs
@clockwork-tien
clockwork-tien force-pushed the tien/feat/egress-mcp-route branch from 98f8bde to 0d24b96 Compare August 24, 2026 15:51
@clockwork-tien
clockwork-tien added this pull request to the merge queue Aug 24, 2026
Merged via the queue into master with commit cfa9636 Aug 24, 2026
50 of 51 checks passed
pull Bot pushed a commit to age-rs/SpacetimeDB that referenced this pull request Aug 31, 2026
# Description of Changes
Related PR clockworklabs#5775
Closes clockworklabs#5789 

- Add egress tracking directly in mcp_root
- Implement counting egress bytes for calls that go through mcp_root
(host-wide MCP route), since egress middleware resolves database from
the URL path, while mcp_root names its database in a tool argument
inside the request body which path based middleware can not see.

<!-- Please describe your change, mention any related tickets, and so on
here. -->

# API and ABI breaking changes
None.

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk
2

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] I tested the implementation, tests, lint and format checks passed

Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
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.

3 participants