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.
The middleware introduced by #5611 ,
resolve_database_name_and_count_response_egress_middleware, does not apply to thePOST /database/:name_or_identity/mcproute. 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 itsname_or_identityargument. 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
NameOrIdentityas a path parameter, it takes aDatabasevia theResolvedDatabaseextension. This will necessarily move name resolution and 404 responses out of and before the route handler. Move the registration of the MCP route inDatabaseRoute::into_routerso that the middleware applies to it.