jerryshao opened a new pull request, #12960:
URL: https://github.com/apache/gravitino/pull/12960

   ### What changes were proposed in this pull request?
   
   The MCP server's metalake was fixed at startup (`--metalake`) and every tool
   call resolved against that one metalake for the life of the process. This PR
   adds an optional `X-Gravitino-Metalake` HTTP request header that a caller can
   use to name the metalake for that call, taking priority over the `--metalake`
   default.
   
   The header is resolved statelessly per request (mirroring how the existing
   `Authorization` header is already forwarded per request), so the server holds
   no per-connection or per-session metalake state and stays correct no matter
   how many replicas it runs as. `--metalake` becomes optional for HTTP
   transport (still required for stdio, which has no per-request header
   channel); `GravitinoContext` now validates the resulting `Setting` at
   construction time instead of only when going through the CLI entrypoint, and
   per-metalake REST clients are cached (keyed by identity + metalake) so a new
   connection pool isn't opened on every call.
   
   ### Why are the changes needed?
   
   A metalake is Gravitino's tenant boundary, and every other interface (the
   REST API) takes it per request. The MCP server was the only interface that
   pinned it at startup, so an installation with more than one metalake needed
   one MCP server process per metalake, or had to accept that agents could only
   reach one of them.
   
   Fix: #12953
   
   ### Does this PR introduce _any_ user-facing change?
   
   - `--metalake` is now optional for HTTP transport (still required for stdio).
   - New `X-Gravitino-Metalake` request header, honored only for HTTP transport,
     taking priority over `--metalake` when present.
   - A request that names no metalake, with no `--metalake` default configured,
     now fails with a clear `Invalid params` error instead of being impossible
     to construct in the first place.
   
   ### How was this patch tested?
   
   Added `tests/unit/test_per_request_metalake.py` (21 new unit tests) covering:
   header resolution and precedence over the startup default, per-(identity,
   metalake) client caching and its LRU bound/eviction, concurrent requests for
   different metalakes never leaking into each other, stdio's header path never
   firing, `Setting` construction-time validation, and error-precedence between
   a missing metalake and `--no-service-identity-fallback`.
   
   Full suite: 250/250 unit tests pass. `isort --check`, `black --check`, and
   `pylint` (10.00/10) all pass on `mcp_server` and `tests`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to