World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
title: "MCP Server" slug: "/gravitino-mcp-server" keyword: "Gravitino MCP metadata" license: "This software is licensed under the Apache License version 2."
Introduction
Gravitino MCP server provides the ability to manage Gravitino metadata for LLM.
Requirements
- Python 3.11+
- uv is installed. Install uv by following the official guide.
Usage
- Clone the code from GitHub, and change to
mcp-serverdirectory - Create virtual environment,
uv venv - Install the required Python packages.
uv pip install -e . - Add Gravitino MCP server to corresponding LLM tools. Take Cursor for example, edit
~/.cursor/mcp.json, use following configuration for local Gravitino MCP server:
{
"mcpServers": {
"gravitino": {
"command": "uv",
"args": [
"--directory",
"$path/mcp-server",
"run",
"mcp_server",
"--metalake",
"test",
"--gravitino-uri",
"http://127.0.0.1:8090"
],
"env": {
"GRAVITINO_OAUTH_TOKEN_ENDPOINT": "https://idp.example/realms/gravitino/protocol/openid-connect/token",
"GRAVITINO_OAUTH_CLIENT_ID": "mcp-service",
"GRAVITINO_OAUTH_CLIENT_SECRET": "<secret>",
"GRAVITINO_OAUTH_SCOPE": "gravitino"
}
}
}
}
In Cursor stdio mode the MCP process typically receives no Authorization header from the client. Set the GRAVITINO_OAUTH_* variables (or the matching CLI flags) so MCP fetches a service token with the client_credentials grant. Omit env to run anonymously, or use --token / GRAVITINO_TOKEN for a static credential instead.
Or start an HTTP MCP server by uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090 --transport http --mcp-url http://localhost:8000/mcp, and use the configuration:
{
"mcpServers": {
"gravitino": {
"url": "http://localhost:8000/mcp"
}
}
}
Docker Instructions
You could start Gravitino MCP server by Docker image, docker run -p 8000:8000 --network=host apache/gravitino-mcp-server:latest --metalake test --transport http --mcp-url http://0.0.0.0:8000/mcp --gravitino-uri http://127.0.0.1:8090. Please note that the MCP server in Docker container doesn't support stdio transport mode.
Supported Tools
Gravitino MCP server supports the following tools, and you could export tool by tag.
| Tool name | Description | Tag |
|---|---|---|
list_metalakes |
Retrieve the metalakes the caller can access. | metalake |
get_list_of_catalogs |
Retrieve a list of all catalogs in the system. | catalog |
create_catalog |
Create a new catalog. | catalog |
alter_catalog |
Alter an existing catalog. | catalog |
drop_catalog |
Drop a catalog. | catalog |
set_catalog_in_use |
Enable or disable a catalog. | catalog |
get_list_of_schemas |
Retrieve a list of schemas belonging to a specific catalog. | schema |
create_schema |
Create a new schema. | schema |
alter_schema |
Alter an existing schema. | schema |
drop_schema |
Drop a schema. | schema |
get_list_of_tables |
Retrieve a list of tables within a specific catalog and schema. | table |
get_table_metadata_details |
Retrieve comprehensive metadata details for a specific table. | table |
create_table |
Create a new table. | table |
alter_table |
Alter an existing table. | table |
drop_table |
Drop a table. | table |
list_of_models |
Retrieve a list of models within a specific catalog and schema. | model |
load_model |
Retrieve comprehensive metadata details for a specific model. | model |
list_model_versions |
Retrieve a list of versions for a specific model. | model |
load_model_version |
Retrieve comprehensive metadata details for a specific model version. | model |
load_model_version_by_alias |
Retrieve comprehensive metadata details for a specific model version by alias. | model |
register_model |
Register a new model. | model |
delete_model |
Delete a model. | model |
link_model_version |
Link a new version to a model. | model |
delete_model_version |
Delete a model version. | model |
delete_model_version_by_alias |
Delete a model version by one of its aliases. | model |
alter_model |
Alter an existing model. | model |
alter_model_version |
Alter a model version. | model |
alter_model_version_by_alias |
Alter a model version by one of its aliases. | model |
metadata_type_to_fullname_formats |
Retrieve the metadata type to fullname formats mapping. | policy, tag |
list_of_topics |
Retrieve a list of topics within a specific catalog and schema. | topic |
load_topic |
Retrieve comprehensive metadata details for a specific topic. | topic |
create_topic |
Create a new topic. | topic |
alter_topic |
Alter an existing topic. | topic |
delete_topic |
Delete a topic. | topic |
list_of_filesets |
Retrieve a list of filesets within a specific catalog and schema. | fileset |
load_fileset |
Retrieve comprehensive metadata details for a specific fileset. | fileset |
list_files_in_fileset |
Retrieve a list of files within a specific fileset. | fileset |
create_fileset |
Create a new fileset. | fileset |
alter_fileset |
Alter an existing fileset. | fileset |
drop_fileset |
Drop a fileset. | fileset |
list_of_jobs |
Retrieve a list of jobs | job |
get_job_by_id |
Retrieve a job by its ID. | job |
list_of_job_templates |
Retrieve a list of job templates. | job |
get_job_template_by_name |
Retrieve a job template by its name. | job |
run_job |
Run a job with the specified parameters. | job |
cancel_job |
Cancel a running job by its ID. | job |
get_tag_by_name |
Retrieve a tag by its name. | tag |
list_of_tags |
Retrieve a list of tags. | tag |
list_tags_for_metadata |
Retrieve a list of tags associated with a specific metadata item. | tag |
list_metadata_by_tag |
Retrieve a list of metadata items associated with a specific tag. | tag |
associate_tag_with_metadata |
Associate tags with a specific metadata item. | tag |
disassociate_tag_from_metadata |
Disassociate tags from a specific metadata item. | tag |
create_tag |
Create a new tag. | tag |
alter_tag |
Alter an existing tag. | tag |
delete_tag |
Delete a tag. | tag |
list_statistics_for_metadata |
Retrieve a list of statistics associated with a specific metadata item. | statistic |
list_statistics_for_partition |
Retrieve a list of statistics associated with a specific partition. | statistic |
get_list_of_policies |
Retrieve a list of policies in the system. | policy |
get_policy_detail_information |
Retrieve detailed information for a specific policy by policy name. | policy |
list_policies_for_tag |
List policies directly associated with a tag, including selectors. | policy, tag |
associate_policy_with_tag |
Associate a policy with a tag and selector. | policy, tag |
disassociate_policy_from_tag |
Remove a direct policy association from a tag. | policy, tag |
list_tags_for_policy |
List tags directly associated with a policy, including selectors. | policy, tag |
list_of_partitions |
Retrieve partitions for a table. Only for catalogs with a partition API. | partition |
get_partition |
Retrieve a partition's metadata. Only for catalogs with a partition API. | partition |
list_of_views |
Retrieve a list of views for a schema. Only for catalogs supporting views. | view |
load_view |
Retrieve a view's metadata. Only for catalogs supporting views. | view |
list_of_semantic_models |
List the Semantic Models the caller can access in a schema. | semantic_model |
list_metrics |
List visible metric identifiers across Semantic Models in a schema. | semantic_model |
list_metric_infos |
List complete visible metrics across Semantic Models in a schema. | semantic_model |
list_semantic_model_datasets |
List visible datasets directly associated with a source table or view. | semantic_model |
load_semantic_model |
Load a Semantic Model's metadata and definition. | semantic_model |
list_semantic_model_revisions |
List visible retained revisions newest first. | semantic_model |
create_semantic_model |
Create a Semantic Model from a native REST definition. | semantic_model |
alter_semantic_model |
Apply Semantic Model updates atomically. | semantic_model |
drop_semantic_model |
Drop a Semantic Model's metadata. | semantic_model |
list_of_domains |
Retrieve a list of domains the caller can access. | domain |
get_domain_by_name |
Retrieve a complete domain snapshot by name. | domain |
list_subdomains |
Retrieve immediate subdomains of a domain. | domain |
list_domain_members |
List directly tagged or expanded effective members of a domain. | domain |
list_domains_for_metadata |
List domains associated with a metadata leaf object. | domain |
Semantic Models
Semantic Model tools manage semantic metadata and discover source associations through the Gravitino REST API.
For concepts and source requirements, see Semantic Models. For governance
and Ossie import/export, see Manage Semantic Model Metadata.
These tools are exposed by default and carry the semantic_model tag; include semantic_model in --include-tool-tags when restricting the server to a tag allowlist.
They use the same per-call metalake selection and authentication as other tools;
Gravitino filters listings by visibility and checks source-table access when creating or
replacing definitions.
Names used in REST paths must be non-empty and cannot be . or .., which HTTP clients
normalize as path navigation. Names must also satisfy the server's naming rules.
list_metrics and list_metric_infos discover metrics across a schema with one
REST request per call. Both accept catalog_name, schema_name, and the optional
per-call metalake. For example:
{"metalake": "prod", "catalog_name": "sales", "schema_name": "mart"}
list_metrics returns a JSON array of identifiers whose namespace is
[metalake, catalog, schema, semanticModel] and whose name is the exact metric
name. list_metric_infos returns objects with the same full namespace and a
complete metric, including its name, expression, and optional description,
datatype, AI context, and custom extensions. JSON number precision is preserved.
Both modes follow containing-model visibility and sort by model identifier, then
case-sensitive metric name. An empty result is []; failures propagate as tool
errors. These tools discover definitions and do not execute metric queries.
list_semantic_model_datasets discovers datasets directly associated with a
table or view using one REST request. Pass source_type (table or view),
the source's catalog_name, schema_name, and source_name, and optionally metalake:
{"metalake": "prod", "source_type": "table", "catalog_name": "sales", "schema_name": "raw", "source_name": "orders"}
Source catalog_name, schema_name, and source_name must not contain literal
dots: the REST source lookup route uses catalog.schema.name without component
escaping. The tool rejects these inputs before sending a request.
The result is a JSON array of identifiers with namespace
[metalake, catalog, schema, semanticModel] and the exact dataset name. Results
may span catalogs and schemas in the selected metalake. Keep each component
separate: a dataset name such as orders.raw contains a literal dot. The namespace
components identify the containing Semantic Model. Server ordering is preserved:
namespace components first, then dataset name, using case-sensitive UTF-16 ordering.
The caller must be able to access the source metadata; Gravitino returns datasets
only from models the caller can load. No visible matches returns []; missing or
inaccessible sources and other failures raise tool errors. Associations reflect the
latest model definition write, including explicit replacement, and do not describe
transitive dependencies or guarantee that a model can execute. An empty result is
not evidence that a source can be safely changed or deleted.
For example, call create_semantic_model with the following arguments after the
sales.mart.orders source table exists in the selected metalake:
{
"metalake": "prod",
"catalog_name": "sales",
"schema_name": "mart",
"name": "sales_model",
"definition": {
"datasets": [
{
"name": "orders",
"source": {"namespace": ["sales", "mart"], "name": "orders"},
"fields": []
}
]
},
"comment": "Governed sales definitions",
"properties": {"domain": "sales"}
}
definition uses the native REST format with camelCase field names. It requires a
non-empty datasets array and supports optional relationships, metrics,
aiContext, and customExtensions fields.
comment and properties are optional. Load, create, and alter return the model object
with its definition, properties, audit information, revision, and publication status.
load_semantic_model uses the active revision by default. Pass a positive revision number or
"latest" as revision to load a saved revision. Use list_semantic_model_revisions to
read revision summaries, including publisher details for published revisions. Drafts require
modify access.
alter_semantic_model accepts catalog_name, schema_name, semantic_model_name, and
an ordered, non-empty updates array. Supported @type values are rename,
updateComment, setProperty, removeProperty, and replaceDefinition. For example,
[{"@type": "updateComment", "newComment": null}] clears the comment.
Send rename on its own. replaceDefinition requires the complete native definition and
revalidates source access. Load "latest", then pass the returned revision as expected_revision.
On a conflict, reload, reapply the edits, and retry.
drop_semantic_model takes the model's catalog, schema, and name and returns a JSON boolean
indicating whether it was dropped. It removes semantic metadata without deleting source tables or data.
Domains (read-only)
See Domains for membership semantics and the Domain guide for SDK and REST mutations.
These five Domain tools are exposed by default and carry the domain tag; include domain in --include-tool-tags when restricting the server to a tag allowlist.
All are annotated as read-only and idempotent and issue only GET requests.
| Tool | Arguments | Result |
|---|---|---|
list_of_domains |
details=true |
Domain snapshots, or names when false |
get_domain_by_name |
domain_name |
A complete domain snapshot |
list_subdomains |
domain_name, details=true |
Immediate subdomain snapshots or names |
list_domain_members |
domain_name, optional types, domains, name_contains, expand |
Directly tagged objects, including catalogs and schemas. Use expand=true for accessible recorded leaves whose effective tags match |
list_domains_for_metadata |
metadata_type, metadata_full_name, details=true |
Domains of a leaf object, including all relations when details is true |
Results follow the existing MCP JSON-string convention; empty lists return [].
Snapshots retain the server's backing tag, status, parent, properties, audit and
relation information. Relations can be direct, inherited (with the catalog or
schema source), or via_subdomain (with the source domain). Multiple relations
for the same member or domain remain intact. Names-only results omit relations.
For example, call list_domain_members with:
{
"domain_name": "sales",
"types": ["TABLE", "TOPIC"],
"domains": ["regional-sales", "online"],
"name_contains": "orders"
}
types accepts leaf object types and, in the default listing, CATALOG and SCHEMA. With expand=true, only leaf types are valid.
domains selects the union of named scopes using repeated query parameters.
Selecting the requested domain includes its visible children. Well-formed names outside that scope are ignored.
name_contains matches a case-insensitive substring of the full metadata object name.
If name_contains is omitted, empty, or contains only whitespace, MCP omits the
nameContains query parameter. Sending an empty or whitespace-only nameContains
directly to the REST endpoint returns HTTP 400.
Omitted or empty type/domain lists leave those filters unset.
Leaf lookups support tables, filesets, topics, models, views and semantic models;
use the REST object type spelling (for example table or semantic_model).
Paths and filter values are URL encoded. Requests use the caller's existing
Gravitino authentication, and server authorization, validation and not-found
errors propagate through the standard MCP error handling. Results reflect the
caller's visibility; no client-side hierarchy expansion or relation inference
is performed.
No Domain creation, modification, deletion, publishing, parent changes or binding changes are exposed. Existing tools in other groups retain their behavior.
Configuration
You could config Gravitino MCP server by arguments, uv run mcp_server -h shows the detailed information.
| Argument | Description | Default value | Required |
|---|---|---|---|
--metalake |
Default metalake, used by any tool call that does not name one. See Selecting a metalake. | none | No |
--gravitino-uri |
The URI of Gravitino server. | http://127.0.0.1:8090 |
No |
--gravitino-read-timeout |
Gravitino response read timeout in seconds; or set GRAVITINO_READ_TIMEOUT. Must be finite and positive. Connect, write and pool timeouts remain 5 seconds. |
60 |
No |
--include-tool-tags |
Comma-separated allowlist of object-type tags from the Supported Tools table (catalog, domain, fileset, job, metalake, model, partition, policy, schema, semantic_model, statistic, table, tag, topic, view). Filters by object type, so it cannot produce a read-only tool set. |
empty (all tools) | No |
--transport |
Transport protocol: stdio (local), http / streamable-http (Streamable HTTP). | stdio |
No |
--mcp-url |
The URL of MCP server if using HTTP transport. | http://127.0.0.1:8000/mcp |
No |
--token |
Static credential for Gravitino; or set GRAVITINO_TOKEN. See Authentication. Wins over OAuth client-credentials. |
none (anonymous) | No |
--oauth-token-endpoint |
OAuth2 token URL for client-credentials. Or GRAVITINO_OAUTH_TOKEN_ENDPOINT. |
none | No |
--oauth-client-id |
OAuth2 client id. Or GRAVITINO_OAUTH_CLIENT_ID. |
none | No |
--oauth-client-secret |
OAuth2 client secret. Or GRAVITINO_OAUTH_CLIENT_SECRET. |
none | No |
--oauth-scope |
Optional OAuth2 scope. Or GRAVITINO_OAUTH_SCOPE. |
none | No |
--no-service-identity-fallback |
HTTP only: reject requests with no Authorization when OAuth or --token is set. Or GRAVITINO_NO_SERVICE_IDENTITY_FALLBACK. |
false |
No |
--tls-cert |
PEM certificate to serve the endpoint over HTTPS. Requires --tls-key. |
none | No |
--tls-key |
PEM private key to serve the endpoint over HTTPS. Requires --tls-cert. |
none | No |
A response read timeout means the MCP server stopped waiting for Gravitino. The operation may still complete on the server. Check the result before retrying, especially for writes. This timeout bounds waiting for response data, not the total duration of the server operation.
Authentication
By default the MCP server talks to Gravitino anonymously. There are three ways to authenticate MCP when calling Gravitino.
Static startup token (stdio and HTTP)
Pass --token (or set the GRAVITINO_TOKEN environment variable) to authenticate the server with a static credential. The token is masked in the server's log output.
A bare value is treated as an OAuth2 token and sent as Authorization: Bearer <token>. A value that already begins with an HTTP authentication scheme is forwarded with that scheme preserved, so the credential can match whatever gravitino.authenticators the server is configured with:
--token value |
Authorization header sent |
|---|---|
abc |
Bearer abc |
Bearer abc |
Bearer abc |
Basic dXNlcjpwYXNz |
Basic dXNlcjpwYXNz |
Custom credentials |
Custom credentials |
| empty or whitespace only | none (anonymous) |
The built-in scheme names (Basic, Bearer, Negotiate) are recognized case-insensitively and normalized to the capitalization Gravitino's authenticators expect; a custom scheme name is forwarded unchanged.
Because a bare token is only Bearer-prefixed when it carries no scheme, a static credential whose value contains a space and begins with a scheme-like word is interpreted as scheme plus credential. Quote such values with an explicit scheme (for example --token "Bearer my secret") to keep them Bearer tokens.
uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090 --token <your-token>
# or, against a server configured with `gravitino.authenticators = basic`
uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090 --token "Basic $(printf '%s' 'user:password' | base64)"
# or
export GRAVITINO_TOKEN=<your-token>
uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090
In stdio mode this token is used for every request. In HTTP mode it is only the fallback, used when an incoming request does not carry its own Authorization header. If both --token and OAuth client-credentials are set, --token wins.
OAuth client credentials (service identity)
When Gravitino uses gravitino.authenticators = oauth, a pasted Bearer access token in --token expires and is not refreshed. For the service identity (Cursor stdio, or HTTP when the caller sends no Authorization header), configure MCP as an OAuth client of the same identity provider Gravitino trusts.
Set --oauth-token-endpoint, --oauth-client-id, and --oauth-client-secret together, plus optional --oauth-scope (or the matching GRAVITINO_OAUTH_* environment variables). MCP requests an access token with the client_credentials grant, caches it, refreshes before expiry, and retries once on HTTP 401.
In Cursor, put the GRAVITINO_OAUTH_* values in the env block of ~/.cursor/mcp.json (see Usage). --token / GRAVITINO_TOKEN overrides OAuth client-credentials and stays static (no refresh). An incoming HTTP Authorization header is forwarded as-is and is not refreshed by MCP.
Gravitino maps the JWT to a metalake principal from claims configured in gravitino.authenticator.oauth.principalFields (often sub); that principal may differ from --oauth-client-id. It must exist as a metalake user with the needed grants, or tool calls fail with 403.
Prefer environment variables (or the env block in ~/.cursor/mcp.json) for the client secret so it does not appear in ps output or shell history:
export GRAVITINO_OAUTH_TOKEN_ENDPOINT=https://idp.example/realms/gravitino/protocol/openid-connect/token
export GRAVITINO_OAUTH_CLIENT_ID=mcp-service
export GRAVITINO_OAUTH_CLIENT_SECRET=<secret>
export GRAVITINO_OAUTH_SCOPE=gravitino
uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090
The matching CLI flags (--oauth-token-endpoint, --oauth-client-id, --oauth-client-secret, --oauth-scope) work the same way, but avoid passing --oauth-client-secret on the command line in production.
This path does not replace per-request user identity in HTTP mode (see below).
Per-request identity (HTTP)
When the server runs with HTTP transport, the Authorization header of each incoming MCP request is forwarded verbatim to Gravitino. The scheme is preserved, so OAuth2 (Bearer), Gravitino simple authentication (Basic <base64(user:dummy)>) and others all work. This keeps concurrent sessions from different principals isolated — one principal's identity never leaks into another's calls — and lets Gravitino enforce authorization per caller. The per-request header takes priority over the static --token and over OAuth client-credentials.
Security warning: When OAuth client-credentials or --token is configured, an HTTP request with no Authorization header is authenticated as the service identity, not as anonymous. With OAuth, that identity refreshes automatically and stays valid for a long time. If the MCP HTTP endpoint is reachable by more than one caller, anyone who omits Authorization receives the service principal's full permissions. Use stdio transport for single-user integrations (for example Cursor), bind HTTP to a trusted network, or place the endpoint behind a reverse proxy that requires authentication.
For exposed or multi-caller HTTP deployments, set --no-service-identity-fallback (or GRAVITINO_NO_SERVICE_IDENTITY_FALLBACK=1) so requests without Authorization are rejected instead of using the service identity. The flag is ignored for stdio transport.
Authorization itself is always enforced by Gravitino: the MCP server forwards the identity but does not make access-control decisions of its own.
Serving over HTTPS (TLS)
To serve the MCP HTTP endpoint (the --mcp-url, not the --gravitino-uri) over TLS, provide both --tls-cert and --tls-key and use an https:// --mcp-url. The certificate and key must be provided together, and the URL scheme must match the TLS setting (an https:// URL without a cert/key, or a cert/key behind an http:// URL, is rejected at startup).
uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090 \
--transport streamable-http --mcp-url https://localhost:8000/mcp \
--tls-cert /path/to/cert.pem --tls-key /path/to/key.pem
The server reads the certificate and key at startup, so restart it after rotating them.
Connecting to Gravitino over HTTPS
When --gravitino-uri uses https://, the server verifies Gravitino's certificate against the public root certificates it ships with. If a private CA signed that certificate, set SSL_CERT_FILE to a PEM bundle that contains both the public roots and the CA:
cat "$(uv run python -c 'import certifi; print(certifi.where())')" /path/to/ca.crt > /path/to/ca-bundle.crt
SSL_CERT_FILE=/path/to/ca-bundle.crt uv run mcp_server --metalake test \
--gravitino-uri https://gravitino.example.com:8433 \
--transport streamable-http --mcp-url https://localhost:8000/mcp \
--tls-cert /path/to/cert.pem --tls-key /path/to/key.pem
SSL_CERT_FILEreplaces the default roots instead of adding to them. A file with only the private CA breaks connections to servers with public certificates, such as an identity provider's token endpoint.- The bundle applies to every outbound HTTPS connection, including the
--oauth-token-endpointrequest. - If the certificate is not trusted, tool calls fail with
CERTIFICATE_VERIFY_FAILED. Restart the server after replacing the bundle.
Selecting a metalake
A metalake is Gravitino's top-level tenant boundary, and every tool operates inside one. --metalake sets the default: the metalake used by any tool call that does not name one itself. It is optional on every transport.
Any tool call may name a different metalake with a metalake argument, which takes priority over the default. The argument is optional on every tool, so a server configured with --metalake behaves exactly as it always has for callers that ignore it.
The metalake for a call is resolved in this order:
- The call's own
metalakeargument, when it passes one. - The
--metalakestartup default, when it is configured. - Otherwise the call fails, telling the agent to call
list_metalakesand retry.
Because each call carries its own metalake, one server instance can serve several metalakes at once: nothing is remembered between calls, so concurrent callers never see each other's metalake and the server stays correct however many replicas it runs as. This works identically over stdio and HTTP.
Use the list_metalakes tool to discover which metalakes a caller may use. It is the one tool that does not need a metalake, so it works on a server started with no --metalake at all.
The statistic tools (list_statistics_for_metadata, list_statistics_for_partition) shipped their own metalake_name argument before metalake selection was unified. It is still accepted as a deprecated alias for metalake, so existing callers keep working; passing both with different values is rejected. New callers should use metalake.
These tools use metadata_full_name for the metadata object name, consistent with the tag and policy tools. The previous spelling, metadata_fullname, is accepted as a deprecated input alias but is not advertised in the tool schema. Supply only one spelling per call; passing both is rejected. New callers should use metadata_full_name.
Authorization is unchanged — the caller's identity (see above) determines what it may see in the named metalake exactly as it would through the REST API. Note that a caller can now reach any metalake its credentials permit, so scope the credentials accordingly when that matters.
Examples
Single metalake, agents never think about it — the common case, and unchanged:
uv run mcp_server --metalake test --gravitino-uri http://127.0.0.1:8090
Several metalakes behind one server, with prod as the default:
uv run mcp_server --metalake prod --transport http --mcp-url http://0.0.0.0:8000/mcp
An agent then works in prod by default and switches per request when asked — "which catalogs are in the staging metalake?" sends metalake=staging on that call alone, without restarting or reconfiguring anything.
No default at all, every call chooses:
uv run mcp_server --transport http --mcp-url http://0.0.0.0:8000/mcp
Tool errors
A tool execution failure handled by the Gravitino middleware returns a CallToolResult with isError: true. Its text
includes the error prefix and message. Clients can read the numeric classification
code and category from _meta["org.apache.gravitino/error"]. For example, a
Gravitino HTTP 409 returns {"code": -32009, "category": "conflict"} there.
Gravitino HTTP 401 and 403 both use code -32000 and have the respective
categories unauthorized and permission_denied. An upstream HTTP 429 has the
category rate_limited.
If the configured OAuth token endpoint rejects the MCP server's credentials or
cannot be found, the tool reports internal_error. Check the server's OAuth
configuration.
MCP protocol errors use the usual JSON-RPC error envelope. If strict SDK input validation rejects a request before middleware runs, the SDK supplies the error text and the call has no Gravitino classification metadata or tool audit record.
Audit Logging
Every tool invocation that reaches the audit middleware is recorded as one structured JSON line in gravitino-mcp-audit.log (written to the server's working directory). Each record is attributed to the incoming HTTP Authorization header when present; otherwise to the configured service identity (--token or OAuth client id).
| Field | Description |
|---|---|
timestamp |
UTC ISO-8601 time of the call. |
principal |
Caller identity: username for Basic simple auth, bearer:<first-16-hex-of-sha256-of-token> for a Bearer token (a fingerprint of the token, so it changes when the token is refreshed), oauth:<first-16-hex-of-sha256-of-client-id> when OAuth client-credentials is the service identity (stdio or HTTP with no caller header), or anonymous when no identity is present. |
tool |
Name of the invoked MCP tool. |
outcome |
allow for successful calls, deny for authentication or authorization denials (Gravitino HTTP 401/403, PermissionError, or --no-service-identity-fallback rejection), and error for other failures. |
metalake |
Resolved metalake from the per-call argument or the --metalake default. Omitted when resolution fails or the tool spans tenants, as list_metalakes does. |
target_type |
Metadata object type for writes and deletes (for example schema or table). Omitted for read-only calls and when the full target cannot be determined. |
target_name |
Target object full name for write and delete tools (for example authz.mcpcat.alice_s); omitted when target_type is omitted. |
error_type |
Original Gravitino error type (for example ForbiddenException, NoSuchTableException, CatalogInUseException) or exception class name (for example ConnectError, ValueError, ReadTimeout); present only when outcome is deny or error. |
error_category |
Normalized failure category (unauthorized, permission_denied, invalid_params, not_found, conflict, timeout, rate_limited, unavailable, internal_error); present only when outcome is deny or error. |
For every scheme other than Basic, principal is a fingerprint of one credential, not a stable user identity. The hash has no key, so the fingerprint suits high-entropy tokens only: a short static credential can be recovered from the log by guessing. To trace what one user did, use the Gravitino server's audit log.
Example records:
{"timestamp": "2026-06-16T03:21:09.123456+00:00", "principal": "alice", "tool": "drop_schema", "outcome": "allow", "metalake": "authz", "target_type": "schema", "target_name": "authz.mcpcat.alice_s"}
{"timestamp": "2026-06-16T03:21:10.123456+00:00", "principal": "alice", "tool": "drop_table", "outcome": "deny", "metalake": "authz", "target_type": "table", "target_name": "authz.mcpcat.alice_s.orders", "error_type": "ForbiddenException", "error_category": "permission_denied"}
{"timestamp": "2026-06-16T03:21:11.123456+00:00", "principal": "admin", "tool": "drop_catalog", "outcome": "error", "metalake": "authz", "target_type": "catalog", "target_name": "authz.mcpcat", "error_type": "CatalogInUseException", "error_category": "conflict"}