This is an automated email from the ASF dual-hosted git repository.
bharos pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino-mcp-gateway.git
The following commit(s) were added to refs/heads/main by this push:
new bc77d59 [#3] improvement: Move the code to the repository root (#9)
bc77d59 is described below
commit bc77d591fcd6460d1f0dea6227b1ee74e8917070
Author: Bharath Krishna <[email protected]>
AuthorDate: Wed Nov 18 20:17:00 2026 -0800
[#3] improvement: Move the code to the repository root (#9)
The gateway is now the repository itself, so its Python project moves
from mcp-gateway/ to the root, and its Docker files to docker/. The image
builds from the repository root with
"docker build -f docker/Dockerfile .", which replaces the packaging
script, and .dockerignore keeps local state out of the build. The Gradle
build file goes; the README shows the same checks with uv.
The README, user documentation and ARCHITECTURE.md use the new paths, and
links to Gravitino's own documentation point at gravitino.apache.org.
NOTICE names the product as the Apache Gravitino MCP Gateway.
With pyproject.toml at the root, black now formats for Python 3.11, the
minimum version, which groups context managers in six tests.
---
.dockerignore | 29 +++
mcp-gateway/.gitignore => .gitignore | 0
mcp-gateway/.python-version => .python-version | 0
mcp-gateway/ARCHITECTURE.md => ARCHITECTURE.md | 2 +-
mcp-gateway/LICENSE.bin => LICENSE.bin | 0
NOTICE | 3 +
mcp-gateway/NOTICE.bin => NOTICE.bin | 2 +-
README.md | 196 +++++++++++++++-
dev/docker/mcp-gateway/mcp-gateway-dependency.sh | 37 ---
.../dev => dev}/keycloak/docker-compose.yaml | 0
.../dev => dev}/keycloak/setup-gravitino.sh | 0
{mcp-gateway/dev => dev}/keycloak/setup-realm.sh | 0
{dev/docker/mcp-gateway => docker}/Dockerfile | 11 +-
.../mcp-gateway => docker}/start-mcp-gateway.sh | 0
docs/gravitino-mcp-gateway.md | 21 +-
mcp-gateway/LICENSE | 201 -----------------
mcp-gateway/NOTICE | 8 -
mcp-gateway/README.md | 201 -----------------
mcp-gateway/build.gradle.kts | 248 ---------------------
.../mcp_gateway => mcp_gateway}/__init__.py | 0
{mcp-gateway/mcp_gateway => mcp_gateway}/audit.py | 0
.../mcp_gateway => mcp_gateway}/body_limit.py | 0
.../catalog_defaults.py | 0
{mcp-gateway/mcp_gateway => mcp_gateway}/config.py | 0
.../mcp_gateway => mcp_gateway}/database.py | 0
.../mcp_gateway => mcp_gateway}/gateway_keys.py | 0
.../gravitino_admins.py | 0
.../mcp_gateway => mcp_gateway}/log_filter.py | 0
{mcp-gateway/mcp_gateway => mcp_gateway}/main.py | 0
.../mcp_gateway => mcp_gateway}/metrics.py | 0
{mcp-gateway/mcp_gateway => mcp_gateway}/models.py | 0
.../mcp_gateway => mcp_gateway}/oauth/__init__.py | 0
.../oauth/mcp_oauth_discovery.py | 0
.../oauth/mcp_service_auth.py | 0
.../oauth/oidc_client.py | 0
.../oauth/secret_storage.py | 0
.../oauth/token_encryption.py | 0
.../oauth/token_manager.py | 0
.../mcp_gateway => mcp_gateway}/oauth_auth.py | 0
{mcp-gateway/mcp_gateway => mcp_gateway}/pages.py | 0
{mcp-gateway/mcp_gateway => mcp_gateway}/purge.py | 0
.../mcp_gateway => mcp_gateway}/routes/__init__.py | 0
.../mcp_gateway => mcp_gateway}/routes/admin.py | 0
.../mcp_gateway => mcp_gateway}/routes/audit.py | 0
.../mcp_gateway => mcp_gateway}/routes/auth.py | 0
.../mcp_gateway => mcp_gateway}/routes/connect.py | 0
.../routes/device_flow.py | 0
.../routes/mcp_access.py | 0
.../routes/mcp_admin.py | 0
.../routes/mcp_catalog.py | 0
.../routes/mcp_oauth.py | 0
.../routes/mcp_server.py | 0
.../routes/mcp_upstream.py | 0
.../routes/user_tokens.py | 0
.../mcp_gateway => mcp_gateway}/routes/users.py | 0
.../security_headers.py | 0
.../mcp_gateway => mcp_gateway}/sessions.py | 0
.../mcp_gateway => mcp_gateway}/slack/__init__.py | 0
.../mcp_gateway => mcp_gateway}/slack/app.py | 0
.../mcp_gateway => mcp_gateway}/slack_service.py | 0
.../templates/device_approval.html | 0
.../templates/message.html | 0
.../__init__.py | 0
.../mcp_gateway_cli => mcp_gateway_cli}/auth.py | 0
.../autostart.py | 0
.../mcp_gateway_cli => mcp_gateway_cli}/cli.py | 0
.../mcp_gateway_cli => mcp_gateway_cli}/clients.py | 0
.../constants.py | 0
.../device_flow.py | 0
.../mcp_gateway_cli => mcp_gateway_cli}/doctor.py | 0
.../mcp_client.py | 0
.../mcp_gateway_cli => mcp_gateway_cli}/proxy.py | 0
.../proxy_daemon.py | 0
.../proxy_identity.py | 0
.../setup_cmd.py | 0
.../__init__.py | 0
.../aws_token.py | 0
.../sa_token.py | 0
.../slack_signature.py | 0
mcp-gateway/pylintrc => pylintrc | 0
mcp-gateway/pyproject.toml => pyproject.toml | 0
{mcp-gateway/tests => tests}/__init__.py | 0
{mcp-gateway/tests => tests}/conftest.py | 0
.../tests => tests}/integration/test_keycloak.py | 0
{mcp-gateway/tests => tests}/request_utils.py | 0
{mcp-gateway/tests => tests}/test_admin.py | 0
{mcp-gateway/tests => tests}/test_audit.py | 0
{mcp-gateway/tests => tests}/test_audit_logger.py | 9 +-
{mcp-gateway/tests => tests}/test_auth_routes.py | 0
{mcp-gateway/tests => tests}/test_aws_token.py | 7 +-
.../tests => tests}/test_catalog_defaults.py | 0
{mcp-gateway/tests => tests}/test_cli_autostart.py | 0
{mcp-gateway/tests => tests}/test_cli_clients.py | 0
{mcp-gateway/tests => tests}/test_cli_doctor.py | 0
.../tests => tests}/test_cli_mcp_client.py | 0
{mcp-gateway/tests => tests}/test_cli_setup.py | 0
.../tests => tests}/test_client_isolation.py | 0
{mcp-gateway/tests => tests}/test_database.py | 0
{mcp-gateway/tests => tests}/test_device_flow.py | 0
.../tests => tests}/test_device_flow_routes.py | 0
{mcp-gateway/tests => tests}/test_end_to_end.py | 0
{mcp-gateway/tests => tests}/test_gateway_jwt.py | 0
.../tests => tests}/test_gravitino_admins.py | 0
{mcp-gateway/tests => tests}/test_license_bin.py | 0
.../tests => tests}/test_local_proxy_forwarding.py | 0
{mcp-gateway/tests => tests}/test_log_filter.py | 0
{mcp-gateway/tests => tests}/test_main_app.py | 0
{mcp-gateway/tests => tests}/test_mcp_access.py | 0
{mcp-gateway/tests => tests}/test_mcp_admin.py | 0
{mcp-gateway/tests => tests}/test_mcp_catalog.py | 0
{mcp-gateway/tests => tests}/test_mcp_oauth.py | 0
.../tests => tests}/test_mcp_oauth_discovery.py | 5 +-
{mcp-gateway/tests => tests}/test_mcp_proxy.py | 0
{mcp-gateway/tests => tests}/test_mcp_sessions.py | 0
.../tests => tests}/test_mcp_upstream_auth.py | 0
{mcp-gateway/tests => tests}/test_metrics.py | 0
.../tests => tests}/test_oauth_auth_jwt.py | 0
{mcp-gateway/tests => tests}/test_oidc_client.py | 0
.../tests => tests}/test_oidc_non_blocking.py | 35 +--
{mcp-gateway/tests => tests}/test_purge.py | 0
{mcp-gateway/tests => tests}/test_sa_token.py | 0
.../tests => tests}/test_secret_storage.py | 0
{mcp-gateway/tests => tests}/test_settings.py | 0
{mcp-gateway/tests => tests}/test_slack_bot.py | 23 +-
{mcp-gateway/tests => tests}/test_slack_service.py | 0
.../tests => tests}/test_slack_signature.py | 0
{mcp-gateway/tests => tests}/test_templates.py | 0
.../tests => tests}/test_token_encryption.py | 0
{mcp-gateway/tests => tests}/test_token_manager.py | 0
.../tests => tests}/test_tool_filtering.py | 0
{mcp-gateway/tests => tests}/test_upstream_tls.py | 0
{mcp-gateway/tests => tests}/test_user_tokens.py | 16 +-
{mcp-gateway/tests => tests}/test_users.py | 0
mcp-gateway/uv.lock => uv.lock | 0
134 files changed, 302 insertions(+), 752 deletions(-)
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..4395b1a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Keep local state, caches and secrets out of the build context.
+.git
+.venv
+**/__pycache__
+**/.pytest_cache
+*.egg-info
+build
+dist
+*.db
+.secrets.json
+.env
+.env.*
diff --git a/mcp-gateway/.gitignore b/.gitignore
similarity index 100%
rename from mcp-gateway/.gitignore
rename to .gitignore
diff --git a/mcp-gateway/.python-version b/.python-version
similarity index 100%
rename from mcp-gateway/.python-version
rename to .python-version
diff --git a/mcp-gateway/ARCHITECTURE.md b/ARCHITECTURE.md
similarity index 99%
rename from mcp-gateway/ARCHITECTURE.md
rename to ARCHITECTURE.md
index 5d2012f..b8b6d40 100644
--- a/mcp-gateway/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -167,7 +167,7 @@ created at startup:
## Deployment
-`dev/docker/build-docker.sh --type mcp-gateway` builds the gateway's image. It
+`docker build -f docker/Dockerfile .` builds the gateway's image. It
keeps its state in the database, except upstream MCP sessions and the refresh
locks, which each process holds in memory. To run more than one replica, point
them at the same MySQL database and give them the same `JWT_SECRET_KEY`,
diff --git a/mcp-gateway/LICENSE.bin b/LICENSE.bin
similarity index 100%
rename from mcp-gateway/LICENSE.bin
rename to LICENSE.bin
diff --git a/NOTICE b/NOTICE
index 9c265b8..3846a3c 100644
--- a/NOTICE
+++ b/NOTICE
@@ -3,3 +3,6 @@ Copyright 2026 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
+
+The initial code for the Gravitino MCP Gateway was donated to the ASF
+by Roku, Inc. (https://www.roku.com/) copyright 2026.
diff --git a/mcp-gateway/NOTICE.bin b/NOTICE.bin
similarity index 99%
rename from mcp-gateway/NOTICE.bin
rename to NOTICE.bin
index ec8079a..9453f71 100644
--- a/mcp-gateway/NOTICE.bin
+++ b/NOTICE.bin
@@ -1,4 +1,4 @@
-Apache Gravitino
+Apache Gravitino MCP Gateway
Copyright 2026 The Apache Software Foundation
This product includes software developed at
diff --git a/README.md b/README.md
index c7c633e..c132cbb 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
@@ -19,9 +19,9 @@
# Apache Gravitino MCP Gateway
-The Apache Gravitino MCP Gateway is a secure authentication gateway for MCP
(Model Context
-Protocol) servers. Users authenticate with OAuth through your identity
provider, such as Okta,
-Keycloak or Microsoft Entra ID, and the gateway:
+The Apache Gravitino MCP Gateway is a secure authentication gateway for MCP
(Model
+Context Protocol) servers. Users authenticate with OAuth through your identity
+provider, such as Okta, Keycloak or Microsoft Entra ID, and the gateway:
- handles each MCP server's credentials;
- controls who can use which server;
@@ -29,6 +29,194 @@ Keycloak or Microsoft Entra ID, and the gateway:
It is part of the [Apache Gravitino](https://gravitino.apache.org) project.
+> The gateway is in beta: its configuration and APIs may change in later
+> releases.
+
+The [user documentation](docs/gravitino-mcp-gateway.md) covers deploying the
+gateway with an identity provider, registering MCP servers, service accounts,
+and connecting MCP clients. [ARCHITECTURE.md](ARCHITECTURE.md) describes the
+design.
+
+## Features
+
+- **Sign-in.** Browser sign-in, and the OAuth device flow (RFC 8628) for the
CLI.
+ The gateway publishes OAuth protected-resource metadata (RFC 9728), so MCP
+ clients can find out how to sign in.
+- **A credential for each MCP server.** The caller's own token, a token
+ exchanged for the server (RFC 8693, or the Microsoft Entra on-behalf-of
+ flow), a token the user connected to the server's own sign-in, a short-lived
+ token the gateway signs, or basic auth. Stored tokens are encrypted with
+ AES-256-GCM.
+- **MCP proxy.** Streamable HTTP at `/mcp/<server ID>`, with per-server tool
+ filters.
+- **Access control.** Users ask for access to a server and an admin approves
+ it, or the server is open to everyone. Service accounts authenticate with GCP
+ or EKS workload identity tokens.
+- **Audit and metrics.** The calls the gateway passes on, the ones it refuses
+ for want of access, and admins' changes
+ are written to the audit log. Prometheus metrics are served at `/metrics`.
+- **Gravitino's web UI** manages the gateway: servers, access requests, service
+ accounts and the audit log.
+- **CLI** (`gravitino-mcp`). Signs in, configures installed AI clients, and
runs
+ a local proxy on port 8001 that adds the user's token to each MCP call.
+
+## Layout
+
+| Path | Contents |
+| --- | --- |
+| `mcp_gateway/` | The gateway (FastAPI): sign-in, MCP proxy, access control,
audit |
+| `mcp_gateway_cli/` | The `gravitino-mcp` command-line client and its local
proxy |
+| `mcp_gateway_sdk/` | Helpers for service accounts that call the gateway |
+| `dev/keycloak/` | Keycloak, Gravitino and Gravitino's MCP server in Docker,
for trying the gateway |
+| `docker/` | The gateway's Docker image |
+| `docs/` | The user documentation |
+| `tests/` | Unit tests, and integration tests under `tests/integration/` |
+
+## Run the gateway
+
+Python 3.11 or later is required. The commands use
[uv](https://docs.astral.sh/uv/);
+`pip install -e .` works too.
+
+```bash
+uv sync && source .venv/bin/activate
+
+# Key that encrypts stored OAuth tokens; keep it stable across restarts
+export TOKEN_ENCRYPTION_KEY=$(python -c "import base64, os;
print(base64.b64encode(os.urandom(32)).decode())")
+export JWT_SECRET_KEY=$(python -c "import secrets;
print(secrets.token_hex(32))")
+export GATEWAY_BASE_URL=http://localhost:8000 # the gateway's external URL
+export OIDC_DISCOVERY_URL=https://<provider>/.well-known/openid-configuration
+export GATEWAY_OAUTH_CLIENT_ID=<client id>
+export GATEWAY_OAUTH_CLIENT_SECRET=<client secret>
+export JWT_AUDIENCE=<audience of the tokens the gateway accepts>
+export [email protected]
+
+uvicorn mcp_gateway.main:app --port 8000
+```
+
+Register `http://localhost:8000/auth/oauth/callback` as a redirect URI of the
+gateway's client at the identity provider, then open http://localhost:8000 and
+sign in. Settings can also go in a `.env` file, or the one
`MCP_GATEWAY_ENV_FILE`
+names; [mcp_gateway/config.py](mcp_gateway/config.py) lists them all with their
+defaults, and the [user
documentation](docs/gravitino-mcp-gateway.md#run-the-gateway)
+describes the main ones.
+
+The gateway's session and sign-in cookies use the `__Host-` prefix, which
+browsers accept only over HTTPS and, in recent Chrome and Firefox, on
+`http://localhost`. To sign in over plain HTTP anywhere else, or from Safari on
+`localhost`, set `DEBUG=true`, which drops the prefix and the `Secure` flag;
+production refuses it.
+
+The gateway uses SQLite (`./mcp_gateway.db`) unless `DATABASE_URL` points
+elsewhere, for example `mysql+pymysql://user:password@host:3306/mcp_gateway`.
+Tables are created at startup.
+
+The token encryption key can also come from a file
(`TOKEN_ENCRYPTION_KEY_FILE`)
+or from a secret store: `SECRET_STORAGE_BACKEND` is `local` (`./.secrets.json`,
+which the gateway only reads), `gcp_secret_manager`, `aws_secrets` or
+`azure_keyvault`, under the secret name `mcp-gateway-encryption-key`. For
+example, in GCP Secret Manager:
+
+```bash
+python -c "import base64, os; print(base64.b64encode(os.urandom(32)).decode(),
end='')" |
+ gcloud secrets create mcp-gateway-encryption-key --data-file=-
+```
+
+The cloud backends need the `gcp`, `aws` or `azure` extra, for example
+`uv sync --extra gcp`.
+
+## Try it with Keycloak
+
+[dev/keycloak](dev/keycloak) runs Keycloak, Gravitino and Gravitino's MCP
server
+in Docker. Keycloak gets a `gravitino` realm with users `alice` and `bob`,
whose
+passwords are their names. Alice is Gravitino's service admin and owns the
+metalake `demo`, which bob can't see. The passwords and the client secret are
+fixed, so use it only on your own machine.
+
+```bash
+docker compose -f dev/keycloak/docker-compose.yaml up -d
+
+export
OIDC_DISCOVERY_URL=http://localhost:8080/realms/gravitino/.well-known/openid-configuration
+export GATEWAY_OAUTH_CLIENT_ID=mcp-gateway
+export GATEWAY_OAUTH_CLIENT_SECRET=mcp-gateway-secret
+export GATEWAY_OAUTH_ACCEPT_ANY_CLIENT=true
+export JWT_AUDIENCE=gravitino
+export GATEWAY_API_SCOPES=gravitino
+export GRAVITINO_MCP_URL=http://localhost:8100/mcp
+export GRAVITINO_URI=http://localhost:8090 # alice, Gravitino's
service admin, is an admin
+export USER_ID_CLAIM=preferred_username # the first of Gravitino's
principalFields
+export CORS_ALLOWED_ORIGINS=http://localhost:3000 # Gravitino's web UI, run
with pnpm dev
+# TOKEN_ENCRYPTION_KEY and JWT_SECRET_KEY as above
+uvicorn mcp_gateway.main:app --port 8000
+```
+
+Point an MCP client at http://localhost:8000/mcp/gravitino: it registers itself
+with Keycloak, signs you in, and the gateway forwards your token to Gravitino.
+To have the gateway exchange tokens instead (RFC 8693), set
+`JWT_AUDIENCE=mcp-gateway`, `GATEWAY_API_SCOPES=mcp-gateway` and
+`GRAVITINO_MCP_AUDIENCE=gravitino`.
[setup-realm.sh](dev/keycloak/setup-realm.sh)
+shows the Keycloak settings each needs.
+
+Gravitino signs in with Keycloak too, and points its web UI at the gateway. The
+UI in the Gravitino image predates the MCP pages; to see them, run the UI from
+this repository with `pnpm install && pnpm dev` in `web-v2/web`, then open
+http://localhost:3000 and sign in as alice.
+
+`MCP_GATEWAY_KEYCLOAK_TEST=1 uv run pytest -m integration
tests/integration/test_keycloak.py`
+tests the gateway against this setup.
+
+## Use the CLI
+
+```bash
+pip install . # from this repository; installs the gravitino-mcp command
+export MCP_GATEWAY_URL=https://mcp-gateway.example.com
+gravitino-mcp setup # sign in, configure AI clients, start the local proxy
+gravitino-mcp doctor # diagnose sign-in, gateway, and proxy problems
+```
+
+Other commands include `login`, `logout`, `whoami`, `services`,
+`connect <server ID>`, `tools <server ID>`, `call <server ID> <tool>`, `proxy`
+and `autostart`; run `gravitino-mcp --help` for the full list.
+
+## Service accounts
+
+Workloads on GKE, GCE, or EKS call the gateway with their platform identity
+token, once an admin has registered the service account in Gravitino's web UI:
+
+```python
+from mcp_gateway_sdk import get_gateway_sa_token
+
+token = get_gateway_sa_token("https://mcp-gateway.example.com")
# GCP
+token = get_gateway_sa_token("https://mcp-gateway.example.com", source="aws")
# EKS
+```
+
+With no URL, the SDK reads `MCP_GATEWAY_URL`. The token is for the gateway's
+URL, unless `audience=` names the gateway's `JWT_AUDIENCE` instead. The
+[user documentation](docs/gravitino-mcp-gateway.md#service-accounts) covers
+registering service accounts, the issuers the gateway trusts, workload headers,
+and forwarding secrets to MCP servers.
+
+## Development
+
+```bash
+uv sync --all-extras
+uv run pytest -m "not integration"
+```
+
+Tests marked `integration` need running services and are excluded above.
+Check the formatting and run pylint with:
+
+```bash
+uvx black==26.5.1 --check mcp_gateway mcp_gateway_cli mcp_gateway_sdk tests
+uvx isort==9.0.0 --check-only mcp_gateway mcp_gateway_cli mcp_gateway_sdk tests
+uv run pylint mcp_gateway mcp_gateway_cli mcp_gateway_sdk tests
+```
+
+Build the Docker image with:
+
+```bash
+docker build -f docker/Dockerfile -t apache/gravitino-mcp-gateway .
+```
+
## Community
- Mailing list:
[[email protected]](https://lists.apache.org/[email protected])
diff --git a/dev/docker/mcp-gateway/mcp-gateway-dependency.sh
b/dev/docker/mcp-gateway/mcp-gateway-dependency.sh
deleted file mode 100755
index d00cd13..0000000
--- a/dev/docker/mcp-gateway/mcp-gateway-dependency.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-set -ex
-mcp_gateway_dir="$(dirname "${BASH_SOURCE-$0}")"
-mcp_gateway_dir="$(cd "${mcp_gateway_dir}">/dev/null; pwd)"
-gravitino_home="$(cd "${mcp_gateway_dir}/../../..">/dev/null; pwd)"
-
-# Removed old packages
-rm -rf "${mcp_gateway_dir}/packages"
-mkdir -p "${mcp_gateway_dir}/packages/mcp-gateway"
-
-# Copy only what the image needs, so local state (.secrets.json, *.db, .venv)
never ships.
-cd "${gravitino_home}/mcp-gateway"
-cp -r pyproject.toml uv.lock .python-version README.md \
- mcp_gateway mcp_gateway_cli mcp_gateway_sdk \
- "${mcp_gateway_dir}/packages/mcp-gateway"
-# The image bundles third-party packages, so it ships the binary LICENSE and
NOTICE.
-cp LICENSE.bin "${mcp_gateway_dir}/packages/mcp-gateway/LICENSE"
-cp NOTICE.bin "${mcp_gateway_dir}/packages/mcp-gateway/NOTICE"
-find "${mcp_gateway_dir}/packages/mcp-gateway" -name "__pycache__" -type d
-prune -exec rm -rf {} +
diff --git a/mcp-gateway/dev/keycloak/docker-compose.yaml
b/dev/keycloak/docker-compose.yaml
similarity index 100%
rename from mcp-gateway/dev/keycloak/docker-compose.yaml
rename to dev/keycloak/docker-compose.yaml
diff --git a/mcp-gateway/dev/keycloak/setup-gravitino.sh
b/dev/keycloak/setup-gravitino.sh
similarity index 100%
rename from mcp-gateway/dev/keycloak/setup-gravitino.sh
rename to dev/keycloak/setup-gravitino.sh
diff --git a/mcp-gateway/dev/keycloak/setup-realm.sh
b/dev/keycloak/setup-realm.sh
similarity index 100%
rename from mcp-gateway/dev/keycloak/setup-realm.sh
rename to dev/keycloak/setup-realm.sh
diff --git a/dev/docker/mcp-gateway/Dockerfile b/docker/Dockerfile
similarity index 78%
rename from dev/docker/mcp-gateway/Dockerfile
rename to docker/Dockerfile
index 3f632af..41f7c5b 100644
--- a/dev/docker/mcp-gateway/Dockerfile
+++ b/docker/Dockerfile
@@ -16,15 +16,22 @@
# specific language governing permissions and limitations
# under the License.
#
+# Build from the repository root: docker build -f docker/Dockerfile .
FROM python:3.11-slim
LABEL maintainer="[email protected]"
WORKDIR /opt/mcp-gateway
-COPY --chmod=755 packages/mcp-gateway /opt/mcp-gateway
+COPY --chmod=755 pyproject.toml uv.lock .python-version README.md
/opt/mcp-gateway/
+COPY --chmod=755 mcp_gateway /opt/mcp-gateway/mcp_gateway
+COPY --chmod=755 mcp_gateway_cli /opt/mcp-gateway/mcp_gateway_cli
+COPY --chmod=755 mcp_gateway_sdk /opt/mcp-gateway/mcp_gateway_sdk
+# The image bundles third-party packages, which LICENSE.bin and NOTICE.bin
cover.
+COPY --chmod=755 LICENSE.bin /opt/mcp-gateway/LICENSE
+COPY --chmod=755 NOTICE.bin /opt/mcp-gateway/NOTICE
-COPY --chmod=755 start-mcp-gateway.sh /opt/mcp-gateway
+COPY --chmod=755 docker/start-mcp-gateway.sh /opt/mcp-gateway/
# uv defaults its cache to $HOME/.cache/uv, which a non-root user cannot
create.
ENV UV_CACHE_DIR=/opt/mcp-gateway/.cache/uv
diff --git a/dev/docker/mcp-gateway/start-mcp-gateway.sh
b/docker/start-mcp-gateway.sh
similarity index 100%
rename from dev/docker/mcp-gateway/start-mcp-gateway.sh
rename to docker/start-mcp-gateway.sh
diff --git a/docs/gravitino-mcp-gateway.md b/docs/gravitino-mcp-gateway.md
index 0b8f6a4..e842875 100644
--- a/docs/gravitino-mcp-gateway.md
+++ b/docs/gravitino-mcp-gateway.md
@@ -12,7 +12,7 @@ The MCP gateway is in beta. Its configuration and APIs may
change in later relea
:::
The Gravitino MCP gateway sits between AI clients and the MCP servers they
use, including the
-[Gravitino MCP server](./gravitino-mcp-server.md). People sign in once with
their organization's
+[Gravitino MCP
server](https://gravitino.apache.org/docs/latest/gravitino-mcp-server). People
sign in once with their organization's
identity provider. The gateway then:
- Calls each MCP server with a credential that server accepts: the caller's
own token, a token
@@ -36,7 +36,7 @@ person's own token, or one exchanged for Gravitino, so each
call runs as that pe
## Requirements
- An OpenID Connect provider, such as Keycloak, Okta, Auth0 or Microsoft Entra
ID, which Gravitino
- also uses for [OAuth
authentication](./security/how-to-authenticate.md#oauth-mode). People's
+ also uses for [OAuth
authentication](https://gravitino.apache.org/docs/latest/security/how-to-authenticate#oauth-mode).
People's
access tokens must be JWTs signed with RS256 that name their client in
`azp`, `client_id` or
`appid`, and carry an `email` claim and an `email_verified` claim that is
true. Okta's and
Auth0's access tokens leave the email out unless a claim or an action adds
it. With Microsoft
@@ -59,15 +59,14 @@ person's own token, or one exchanged for Gravitino, so each
call runs as that pe
## Run the gateway
-Build the image from the Gravitino source tree. To run the gateway without
Docker, follow the
-`mcp-gateway`
[README](https://github.com/apache/gravitino/blob/main/mcp-gateway/README.md).
+Build the image from this repository. To run the gateway without Docker,
follow the
+[README](https://github.com/apache/gravitino-mcp-gateway/blob/main/README.md).
```shell
-./dev/docker/build-docker.sh --platform linux/amd64 --type mcp-gateway \
- --image apache/gravitino-mcp-gateway --tag 2.0.0
+docker build -f docker/Dockerfile -t apache/gravitino-mcp-gateway .
docker run -d -p 8000:8000 --env-file gateway.env \
-v "$PWD/signing-key.pem:/etc/mcp-gateway/signing-key.pem:ro" \
- apache/gravitino-mcp-gateway:2.0.0
+ apache/gravitino-mcp-gateway
```
The gateway reads its settings from environment variables, here from
`gateway.env`:
@@ -123,7 +122,7 @@ The main settings are:
| `MAX_REQUEST_BYTES` | The largest request body the gateway reads, 10 MiB by
default. |
| `ENVIRONMENT` | `production`, which the Docker image sets, turns on the
checks in [In production](#in-production). |
-`mcp-gateway/mcp_gateway/config.py` lists every setting and its default.
+`mcp_gateway/config.py` lists every setting and its default.
### In production
@@ -430,11 +429,11 @@ no such registration; with Entra, use the CLI.
### The CLI
The `gravitino-mcp` CLI signs you in through the browser and runs a local
proxy, at
-`http://localhost:8001`, which adds your token to each call. Install it from
the Gravitino
-source tree:
+`http://localhost:8001`, which adds your token to each call. Install it from a
checkout of
+this repository:
```shell
-pip install ./mcp-gateway
+pip install .
export MCP_GATEWAY_URL=https://mcp-gateway.example.com
gravitino-mcp setup
```
diff --git a/mcp-gateway/LICENSE b/mcp-gateway/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/mcp-gateway/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/mcp-gateway/NOTICE b/mcp-gateway/NOTICE
deleted file mode 100644
index 226a9ed..0000000
--- a/mcp-gateway/NOTICE
+++ /dev/null
@@ -1,8 +0,0 @@
-Apache Gravitino
-Copyright 2026 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-
-The initial code for the Gravitino MCP Gateway was donated to the ASF
-by Roku, Inc. (https://www.roku.com/) copyright 2026.
diff --git a/mcp-gateway/README.md b/mcp-gateway/README.md
deleted file mode 100644
index 85eb5ee..0000000
--- a/mcp-gateway/README.md
+++ /dev/null
@@ -1,201 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-# Gravitino MCP Gateway
-
-Gravitino MCP Gateway sits between AI clients and the MCP servers they use.
-Users sign in once with their organization's identity provider. The gateway
-calls each MCP server with a credential that server accepts, controls who may
-use which server, and writes the calls to an audit log.
-
-> The gateway is in beta in Gravitino 2.0: its configuration and APIs may
-> change in later releases.
-
-The [user documentation](../docs/gravitino-mcp-gateway.md) covers deploying the
-gateway with an identity provider, registering MCP servers, service accounts,
-and connecting MCP clients. [ARCHITECTURE.md](ARCHITECTURE.md) describes the
-design.
-
-## Features
-
-- **Sign-in.** Browser sign-in, and the OAuth device flow (RFC 8628) for the
CLI.
- The gateway publishes OAuth protected-resource metadata (RFC 9728), so MCP
- clients can find out how to sign in.
-- **A credential for each MCP server.** The caller's own token, a token
- exchanged for the server (RFC 8693, or the Microsoft Entra on-behalf-of
- flow), a token the user connected to the server's own sign-in, a short-lived
- token the gateway signs, or basic auth. Stored tokens are encrypted with
- AES-256-GCM.
-- **MCP proxy.** Streamable HTTP at `/mcp/<server ID>`, with per-server tool
- filters.
-- **Access control.** Users ask for access to a server and an admin approves
- it, or the server is open to everyone. Service accounts authenticate with GCP
- or EKS workload identity tokens.
-- **Audit and metrics.** The calls the gateway passes on, the ones it refuses
- for want of access, and admins' changes
- are written to the audit log. Prometheus metrics are served at `/metrics`.
-- **Gravitino's web UI** manages the gateway: servers, access requests, service
- accounts and the audit log.
-- **CLI** (`gravitino-mcp`). Signs in, configures installed AI clients, and
runs
- a local proxy on port 8001 that adds the user's token to each MCP call.
-
-## Layout
-
-| Path | Contents |
-| --- | --- |
-| `mcp_gateway/` | The gateway (FastAPI): sign-in, MCP proxy, access control,
audit |
-| `mcp_gateway_cli/` | The `gravitino-mcp` command-line client and its local
proxy |
-| `mcp_gateway_sdk/` | Helpers for service accounts that call the gateway |
-| `dev/keycloak/` | Keycloak, Gravitino and Gravitino's MCP server in Docker,
for trying the gateway |
-| `tests/` | Unit tests, and integration tests under `tests/integration/` |
-
-## Run the gateway
-
-Python 3.11 or later is required. The commands use
[uv](https://docs.astral.sh/uv/);
-`pip install -e .` works too.
-
-```bash
-cd mcp-gateway
-uv sync && source .venv/bin/activate
-
-# Key that encrypts stored OAuth tokens; keep it stable across restarts
-export TOKEN_ENCRYPTION_KEY=$(python -c "import base64, os;
print(base64.b64encode(os.urandom(32)).decode())")
-export JWT_SECRET_KEY=$(python -c "import secrets;
print(secrets.token_hex(32))")
-export GATEWAY_BASE_URL=http://localhost:8000 # the gateway's external URL
-export OIDC_DISCOVERY_URL=https://<provider>/.well-known/openid-configuration
-export GATEWAY_OAUTH_CLIENT_ID=<client id>
-export GATEWAY_OAUTH_CLIENT_SECRET=<client secret>
-export JWT_AUDIENCE=<audience of the tokens the gateway accepts>
-export [email protected]
-
-uvicorn mcp_gateway.main:app --port 8000
-```
-
-Register `http://localhost:8000/auth/oauth/callback` as a redirect URI of the
-gateway's client at the identity provider, then open http://localhost:8000 and
-sign in. Settings can also go in a `.env` file, or the one
`MCP_GATEWAY_ENV_FILE`
-names; [mcp_gateway/config.py](mcp_gateway/config.py) lists them all with their
-defaults, and the [user
documentation](../docs/gravitino-mcp-gateway.md#run-the-gateway)
-describes the main ones.
-
-The gateway's session and sign-in cookies use the `__Host-` prefix, which
-browsers accept only over HTTPS and, in recent Chrome and Firefox, on
-`http://localhost`. To sign in over plain HTTP anywhere else, or from Safari on
-`localhost`, set `DEBUG=true`, which drops the prefix and the `Secure` flag;
-production refuses it.
-
-The gateway uses SQLite (`./mcp_gateway.db`) unless `DATABASE_URL` points
-elsewhere, for example `mysql+pymysql://user:password@host:3306/mcp_gateway`.
-Tables are created at startup.
-
-The token encryption key can also come from a file
(`TOKEN_ENCRYPTION_KEY_FILE`)
-or from a secret store: `SECRET_STORAGE_BACKEND` is `local` (`./.secrets.json`,
-which the gateway only reads), `gcp_secret_manager`, `aws_secrets` or
-`azure_keyvault`, under the secret name `mcp-gateway-encryption-key`. For
-example, in GCP Secret Manager:
-
-```bash
-python -c "import base64, os; print(base64.b64encode(os.urandom(32)).decode(),
end='')" |
- gcloud secrets create mcp-gateway-encryption-key --data-file=-
-```
-
-The cloud backends need the `gcp`, `aws` or `azure` extra, for example
-`uv sync --extra gcp`.
-
-## Try it with Keycloak
-
-[dev/keycloak](dev/keycloak) runs Keycloak, Gravitino and Gravitino's MCP
server
-in Docker. Keycloak gets a `gravitino` realm with users `alice` and `bob`,
whose
-passwords are their names. Alice is Gravitino's service admin and owns the
-metalake `demo`, which bob can't see. The passwords and the client secret are
-fixed, so use it only on your own machine.
-
-```bash
-docker compose -f dev/keycloak/docker-compose.yaml up -d
-
-export
OIDC_DISCOVERY_URL=http://localhost:8080/realms/gravitino/.well-known/openid-configuration
-export GATEWAY_OAUTH_CLIENT_ID=mcp-gateway
-export GATEWAY_OAUTH_CLIENT_SECRET=mcp-gateway-secret
-export GATEWAY_OAUTH_ACCEPT_ANY_CLIENT=true
-export JWT_AUDIENCE=gravitino
-export GATEWAY_API_SCOPES=gravitino
-export GRAVITINO_MCP_URL=http://localhost:8100/mcp
-export GRAVITINO_URI=http://localhost:8090 # alice, Gravitino's
service admin, is an admin
-export USER_ID_CLAIM=preferred_username # the first of Gravitino's
principalFields
-export CORS_ALLOWED_ORIGINS=http://localhost:3000 # Gravitino's web UI, run
with pnpm dev
-# TOKEN_ENCRYPTION_KEY and JWT_SECRET_KEY as above
-uvicorn mcp_gateway.main:app --port 8000
-```
-
-Point an MCP client at http://localhost:8000/mcp/gravitino: it registers itself
-with Keycloak, signs you in, and the gateway forwards your token to Gravitino.
-To have the gateway exchange tokens instead (RFC 8693), set
-`JWT_AUDIENCE=mcp-gateway`, `GATEWAY_API_SCOPES=mcp-gateway` and
-`GRAVITINO_MCP_AUDIENCE=gravitino`.
[setup-realm.sh](dev/keycloak/setup-realm.sh)
-shows the Keycloak settings each needs.
-
-Gravitino signs in with Keycloak too, and points its web UI at the gateway. The
-UI in the Gravitino image predates the MCP pages; to see them, run the UI from
-this repository with `pnpm install && pnpm dev` in `web-v2/web`, then open
-http://localhost:3000 and sign in as alice.
-
-`MCP_GATEWAY_KEYCLOAK_TEST=1 uv run pytest -m integration
tests/integration/test_keycloak.py`
-tests the gateway against this setup.
-
-## Use the CLI
-
-```bash
-pip install ./mcp-gateway # installs the gravitino-mcp command
-export MCP_GATEWAY_URL=https://mcp-gateway.example.com
-gravitino-mcp setup # sign in, configure AI clients, start the local proxy
-gravitino-mcp doctor # diagnose sign-in, gateway, and proxy problems
-```
-
-Other commands include `login`, `logout`, `whoami`, `services`,
-`connect <server ID>`, `tools <server ID>`, `call <server ID> <tool>`, `proxy`
-and `autostart`; run `gravitino-mcp --help` for the full list.
-
-## Service accounts
-
-Workloads on GKE, GCE, or EKS call the gateway with their platform identity
-token, once an admin has registered the service account in Gravitino's web UI:
-
-```python
-from mcp_gateway_sdk import get_gateway_sa_token
-
-token = get_gateway_sa_token("https://mcp-gateway.example.com")
# GCP
-token = get_gateway_sa_token("https://mcp-gateway.example.com", source="aws")
# EKS
-```
-
-With no URL, the SDK reads `MCP_GATEWAY_URL`. The token is for the gateway's
-URL, unless `audience=` names the gateway's `JWT_AUDIENCE` instead. The
-[user documentation](../docs/gravitino-mcp-gateway.md#service-accounts) covers
-registering service accounts, the issuers the gateway trusts, workload headers,
-and forwarding secrets to MCP servers.
-
-## Development
-
-```bash
-uv sync --all-extras
-uv run pytest -m "not integration"
-```
-
-Tests marked `integration` need running services and are excluded above.
-From the Gravitino root, `./gradlew :mcp-gateway:build` checks the formatting
-(black and isort), runs pylint and runs the unit tests, as the CI does.
diff --git a/mcp-gateway/build.gradle.kts b/mcp-gateway/build.gradle.kts
deleted file mode 100644
index cf5b8a9..0000000
--- a/mcp-gateway/build.gradle.kts
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.gradle.api.GradleException
-import org.gradle.api.tasks.Delete
-import org.gradle.api.tasks.Exec
-import org.gradle.kotlin.dsl.register
-
-val pythonProjectDir = project.projectDir
-val venvDir = pythonProjectDir.resolve(".venv")
-val pythonSources = listOf("mcp_gateway", "mcp_gateway_cli",
"mcp_gateway_sdk", "tests")
-
-val isWindows = System.getProperty("os.name").contains("win", ignoreCase =
true)
-val globalUvExecutable = if (isWindows) "uv.exe" else "uv"
-
-fun getUvExecutable(): String {
- return if (project.extensions.extraProperties.has("uvExecutable")) {
- project.extensions.extraProperties.get("uvExecutable") as String
- } else {
- globalUvExecutable
- }
-}
-
-val venvPython = if (isWindows) {
- venvDir.resolve("Scripts/python.exe").absolutePath
-} else {
- venvDir.resolve("bin/python").absolutePath
-}
-
-// Same pins as mcp-server, so both modules are formatted identically. The
formatters run in
-// isolated uv tool environments: pylint (in the project venv) needs an older
isort.
-val blackRequirement = "black==26.5.1"
-val isortRequirement = "isort==9.0.0"
-
-tasks {
- register<Exec>("installUv") {
- group = "python"
- description = "Install UV if not present"
-
- val uvInstallDir = file("$pythonProjectDir/.uv/bin").apply { mkdirs() }
- val uvExecutable = if (isWindows) {
- file("$uvInstallDir/uv.exe")
- } else {
- file("$uvInstallDir/uv")
- }
-
- onlyIf {
- if (uvExecutable.exists()) {
- project.extensions.extraProperties.set("uvExecutable",
uvExecutable.absolutePath)
- logger.lifecycle("UV already installed at:
${uvExecutable.absolutePath}")
- false
- } else {
- try {
- exec {
- commandLine(globalUvExecutable, "--version")
- isIgnoreExitValue = true
- }.exitValue != 0
- } catch (e: Exception) {
- true
- }
- }
- }
-
- doFirst {
- logger.lifecycle("UV not found, installing via official script...")
- }
-
- if (isWindows) {
- commandLine(
- "powershell",
- "-Command",
- "\$env:UV_INSTALL_DIR='${uvInstallDir.absolutePath}'; " +
- "irm https://astral.sh/uv/install.ps1 | iex"
- )
- } else {
- commandLine(
- "/bin/sh",
- "-c",
- "export UV_INSTALL_DIR=${uvInstallDir.absolutePath}; " +
- "curl -LsSf https://astral.sh/uv/install.sh | sh"
- )
- }
-
- doLast {
- val uvCheck = exec {
- commandLine(uvExecutable.absolutePath, "--version")
- isIgnoreExitValue = true
- }
- if (uvCheck.exitValue != 0) {
- throw GradleException("UV installation failed")
- }
-
- project.extensions.extraProperties.set("uvExecutable",
uvExecutable.absolutePath)
- }
- }
-
- register<Exec>("syncDependencies") {
- group = "python"
- description = "Create the virtual environment from uv.lock, with every
extra and the dev group"
- dependsOn("installUv")
- workingDir(pythonProjectDir)
-
- doFirst {
- // --locked fails the build when pyproject.toml and uv.lock disagree.
- commandLine(getUvExecutable(), "sync", "--locked", "--all-extras")
- }
-
- doLast {
- if (executionResult.get().exitValue != 0) {
- throw GradleException("Failed to sync dependencies. Exit code:
${executionResult.get().exitValue}")
- }
- }
- }
-
- register("buildPython") {
- group = "python"
- description = "Build Python project"
- dependsOn("syncDependencies")
- doLast {
- logger.lifecycle("Python project built successfully")
- }
- }
-
- register<Exec>("testPython") {
- group = "python"
- description = "Run Python unit tests with pytest"
- dependsOn("buildPython")
- workingDir(pythonProjectDir)
-
- // Integration tests need live services and run separately.
- commandLine(venvPython, "-m", "pytest", "-m", "not integration", "-p",
"no:cacheprovider")
-
- doLast {
- if (executionResult.get().exitValue != 0) {
- throw GradleException("Unit tests failed. Exit code:
${executionResult.get().exitValue}")
- }
- }
- }
-
- register<Delete>("cleanPython") {
- group = "python"
- description = "Clean Python build artifacts"
- delete(venvDir)
- delete(pythonProjectDir.resolve(".uv"))
- delete(pythonProjectDir.resolve("dist"))
- delete(pythonProjectDir.resolve("build"))
- delete(pythonProjectDir.resolve("gravitino_mcp_gateway.egg-info"))
- }
-
- register<DefaultTask>("formatApplyPython") {
- group = "python"
- description = "Apply Black formatting and isort import sorting"
- dependsOn("installUv")
-
- doLast {
- exec {
- workingDir = pythonProjectDir
- commandLine(listOf(getUvExecutable(), "tool", "run", "--from",
isortRequirement, "isort") + pythonSources)
- }
-
- exec {
- workingDir = pythonProjectDir
- commandLine(listOf(getUvExecutable(), "tool", "run", "--from",
blackRequirement, "black") + pythonSources)
- }
-
- logger.lifecycle("Python formatting applied (isort + Black)")
- }
- }
-
- register<DefaultTask>("formatCheckPython") {
- group = "python"
- description = "Check Python code formatting with Black and import order
with isort"
- dependsOn("installUv")
-
- doLast {
- val isortExitCode = exec {
- workingDir = pythonProjectDir
- commandLine(
- listOf(getUvExecutable(), "tool", "run", "--from", isortRequirement,
"isort", "--check") + pythonSources
- )
- isIgnoreExitValue = true
- }.exitValue
-
- if (isortExitCode != 0) {
- throw GradleException("Python isort formatting check failed")
- }
-
- val blackExitCode = exec {
- workingDir = pythonProjectDir
- commandLine(
- listOf(getUvExecutable(), "tool", "run", "--from", blackRequirement,
"black", "--check") + pythonSources
- )
- isIgnoreExitValue = true
- }.exitValue
-
- if (blackExitCode != 0) {
- throw GradleException("Python black formatting check failed")
- }
- }
- }
-}
-
-tasks.register<Exec>("pylint") {
- dependsOn("syncDependencies")
- mustRunAfter("buildPython")
- workingDir(pythonProjectDir)
- commandLine(listOf(venvPython, "-m", "pylint") + pythonSources)
-}
-
-tasks.named("test") {
- val skipUTs = project.hasProperty("skipTests")
- if (!skipUTs) {
- dependsOn("testPython")
- }
-}
-
-tasks.named("build") {
- dependsOn("buildPython")
- dependsOn("pylint")
-}
-
-tasks.named("clean") {
- dependsOn("cleanPython")
-}
-
-tasks.named("spotlessCheck") {
- dependsOn("formatCheckPython")
-}
-
-tasks.named("spotlessApply") {
- dependsOn("formatApplyPython")
-}
diff --git a/mcp-gateway/mcp_gateway/__init__.py b/mcp_gateway/__init__.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/__init__.py
rename to mcp_gateway/__init__.py
diff --git a/mcp-gateway/mcp_gateway/audit.py b/mcp_gateway/audit.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/audit.py
rename to mcp_gateway/audit.py
diff --git a/mcp-gateway/mcp_gateway/body_limit.py b/mcp_gateway/body_limit.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/body_limit.py
rename to mcp_gateway/body_limit.py
diff --git a/mcp-gateway/mcp_gateway/catalog_defaults.py
b/mcp_gateway/catalog_defaults.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/catalog_defaults.py
rename to mcp_gateway/catalog_defaults.py
diff --git a/mcp-gateway/mcp_gateway/config.py b/mcp_gateway/config.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/config.py
rename to mcp_gateway/config.py
diff --git a/mcp-gateway/mcp_gateway/database.py b/mcp_gateway/database.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/database.py
rename to mcp_gateway/database.py
diff --git a/mcp-gateway/mcp_gateway/gateway_keys.py
b/mcp_gateway/gateway_keys.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/gateway_keys.py
rename to mcp_gateway/gateway_keys.py
diff --git a/mcp-gateway/mcp_gateway/gravitino_admins.py
b/mcp_gateway/gravitino_admins.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/gravitino_admins.py
rename to mcp_gateway/gravitino_admins.py
diff --git a/mcp-gateway/mcp_gateway/log_filter.py b/mcp_gateway/log_filter.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/log_filter.py
rename to mcp_gateway/log_filter.py
diff --git a/mcp-gateway/mcp_gateway/main.py b/mcp_gateway/main.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/main.py
rename to mcp_gateway/main.py
diff --git a/mcp-gateway/mcp_gateway/metrics.py b/mcp_gateway/metrics.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/metrics.py
rename to mcp_gateway/metrics.py
diff --git a/mcp-gateway/mcp_gateway/models.py b/mcp_gateway/models.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/models.py
rename to mcp_gateway/models.py
diff --git a/mcp-gateway/mcp_gateway/oauth/__init__.py
b/mcp_gateway/oauth/__init__.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/__init__.py
rename to mcp_gateway/oauth/__init__.py
diff --git a/mcp-gateway/mcp_gateway/oauth/mcp_oauth_discovery.py
b/mcp_gateway/oauth/mcp_oauth_discovery.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/mcp_oauth_discovery.py
rename to mcp_gateway/oauth/mcp_oauth_discovery.py
diff --git a/mcp-gateway/mcp_gateway/oauth/mcp_service_auth.py
b/mcp_gateway/oauth/mcp_service_auth.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/mcp_service_auth.py
rename to mcp_gateway/oauth/mcp_service_auth.py
diff --git a/mcp-gateway/mcp_gateway/oauth/oidc_client.py
b/mcp_gateway/oauth/oidc_client.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/oidc_client.py
rename to mcp_gateway/oauth/oidc_client.py
diff --git a/mcp-gateway/mcp_gateway/oauth/secret_storage.py
b/mcp_gateway/oauth/secret_storage.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/secret_storage.py
rename to mcp_gateway/oauth/secret_storage.py
diff --git a/mcp-gateway/mcp_gateway/oauth/token_encryption.py
b/mcp_gateway/oauth/token_encryption.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/token_encryption.py
rename to mcp_gateway/oauth/token_encryption.py
diff --git a/mcp-gateway/mcp_gateway/oauth/token_manager.py
b/mcp_gateway/oauth/token_manager.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth/token_manager.py
rename to mcp_gateway/oauth/token_manager.py
diff --git a/mcp-gateway/mcp_gateway/oauth_auth.py b/mcp_gateway/oauth_auth.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/oauth_auth.py
rename to mcp_gateway/oauth_auth.py
diff --git a/mcp-gateway/mcp_gateway/pages.py b/mcp_gateway/pages.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/pages.py
rename to mcp_gateway/pages.py
diff --git a/mcp-gateway/mcp_gateway/purge.py b/mcp_gateway/purge.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/purge.py
rename to mcp_gateway/purge.py
diff --git a/mcp-gateway/mcp_gateway/routes/__init__.py
b/mcp_gateway/routes/__init__.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/__init__.py
rename to mcp_gateway/routes/__init__.py
diff --git a/mcp-gateway/mcp_gateway/routes/admin.py
b/mcp_gateway/routes/admin.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/admin.py
rename to mcp_gateway/routes/admin.py
diff --git a/mcp-gateway/mcp_gateway/routes/audit.py
b/mcp_gateway/routes/audit.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/audit.py
rename to mcp_gateway/routes/audit.py
diff --git a/mcp-gateway/mcp_gateway/routes/auth.py b/mcp_gateway/routes/auth.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/auth.py
rename to mcp_gateway/routes/auth.py
diff --git a/mcp-gateway/mcp_gateway/routes/connect.py
b/mcp_gateway/routes/connect.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/connect.py
rename to mcp_gateway/routes/connect.py
diff --git a/mcp-gateway/mcp_gateway/routes/device_flow.py
b/mcp_gateway/routes/device_flow.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/device_flow.py
rename to mcp_gateway/routes/device_flow.py
diff --git a/mcp-gateway/mcp_gateway/routes/mcp_access.py
b/mcp_gateway/routes/mcp_access.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/mcp_access.py
rename to mcp_gateway/routes/mcp_access.py
diff --git a/mcp-gateway/mcp_gateway/routes/mcp_admin.py
b/mcp_gateway/routes/mcp_admin.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/mcp_admin.py
rename to mcp_gateway/routes/mcp_admin.py
diff --git a/mcp-gateway/mcp_gateway/routes/mcp_catalog.py
b/mcp_gateway/routes/mcp_catalog.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/mcp_catalog.py
rename to mcp_gateway/routes/mcp_catalog.py
diff --git a/mcp-gateway/mcp_gateway/routes/mcp_oauth.py
b/mcp_gateway/routes/mcp_oauth.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/mcp_oauth.py
rename to mcp_gateway/routes/mcp_oauth.py
diff --git a/mcp-gateway/mcp_gateway/routes/mcp_server.py
b/mcp_gateway/routes/mcp_server.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/mcp_server.py
rename to mcp_gateway/routes/mcp_server.py
diff --git a/mcp-gateway/mcp_gateway/routes/mcp_upstream.py
b/mcp_gateway/routes/mcp_upstream.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/mcp_upstream.py
rename to mcp_gateway/routes/mcp_upstream.py
diff --git a/mcp-gateway/mcp_gateway/routes/user_tokens.py
b/mcp_gateway/routes/user_tokens.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/user_tokens.py
rename to mcp_gateway/routes/user_tokens.py
diff --git a/mcp-gateway/mcp_gateway/routes/users.py
b/mcp_gateway/routes/users.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/routes/users.py
rename to mcp_gateway/routes/users.py
diff --git a/mcp-gateway/mcp_gateway/security_headers.py
b/mcp_gateway/security_headers.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/security_headers.py
rename to mcp_gateway/security_headers.py
diff --git a/mcp-gateway/mcp_gateway/sessions.py b/mcp_gateway/sessions.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/sessions.py
rename to mcp_gateway/sessions.py
diff --git a/mcp-gateway/mcp_gateway/slack/__init__.py
b/mcp_gateway/slack/__init__.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/slack/__init__.py
rename to mcp_gateway/slack/__init__.py
diff --git a/mcp-gateway/mcp_gateway/slack/app.py b/mcp_gateway/slack/app.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/slack/app.py
rename to mcp_gateway/slack/app.py
diff --git a/mcp-gateway/mcp_gateway/slack_service.py
b/mcp_gateway/slack_service.py
similarity index 100%
rename from mcp-gateway/mcp_gateway/slack_service.py
rename to mcp_gateway/slack_service.py
diff --git a/mcp-gateway/mcp_gateway/templates/device_approval.html
b/mcp_gateway/templates/device_approval.html
similarity index 100%
rename from mcp-gateway/mcp_gateway/templates/device_approval.html
rename to mcp_gateway/templates/device_approval.html
diff --git a/mcp-gateway/mcp_gateway/templates/message.html
b/mcp_gateway/templates/message.html
similarity index 100%
rename from mcp-gateway/mcp_gateway/templates/message.html
rename to mcp_gateway/templates/message.html
diff --git a/mcp-gateway/mcp_gateway_cli/__init__.py
b/mcp_gateway_cli/__init__.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/__init__.py
rename to mcp_gateway_cli/__init__.py
diff --git a/mcp-gateway/mcp_gateway_cli/auth.py b/mcp_gateway_cli/auth.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/auth.py
rename to mcp_gateway_cli/auth.py
diff --git a/mcp-gateway/mcp_gateway_cli/autostart.py
b/mcp_gateway_cli/autostart.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/autostart.py
rename to mcp_gateway_cli/autostart.py
diff --git a/mcp-gateway/mcp_gateway_cli/cli.py b/mcp_gateway_cli/cli.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/cli.py
rename to mcp_gateway_cli/cli.py
diff --git a/mcp-gateway/mcp_gateway_cli/clients.py b/mcp_gateway_cli/clients.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/clients.py
rename to mcp_gateway_cli/clients.py
diff --git a/mcp-gateway/mcp_gateway_cli/constants.py
b/mcp_gateway_cli/constants.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/constants.py
rename to mcp_gateway_cli/constants.py
diff --git a/mcp-gateway/mcp_gateway_cli/device_flow.py
b/mcp_gateway_cli/device_flow.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/device_flow.py
rename to mcp_gateway_cli/device_flow.py
diff --git a/mcp-gateway/mcp_gateway_cli/doctor.py b/mcp_gateway_cli/doctor.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/doctor.py
rename to mcp_gateway_cli/doctor.py
diff --git a/mcp-gateway/mcp_gateway_cli/mcp_client.py
b/mcp_gateway_cli/mcp_client.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/mcp_client.py
rename to mcp_gateway_cli/mcp_client.py
diff --git a/mcp-gateway/mcp_gateway_cli/proxy.py b/mcp_gateway_cli/proxy.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/proxy.py
rename to mcp_gateway_cli/proxy.py
diff --git a/mcp-gateway/mcp_gateway_cli/proxy_daemon.py
b/mcp_gateway_cli/proxy_daemon.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/proxy_daemon.py
rename to mcp_gateway_cli/proxy_daemon.py
diff --git a/mcp-gateway/mcp_gateway_cli/proxy_identity.py
b/mcp_gateway_cli/proxy_identity.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/proxy_identity.py
rename to mcp_gateway_cli/proxy_identity.py
diff --git a/mcp-gateway/mcp_gateway_cli/setup_cmd.py
b/mcp_gateway_cli/setup_cmd.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_cli/setup_cmd.py
rename to mcp_gateway_cli/setup_cmd.py
diff --git a/mcp-gateway/mcp_gateway_sdk/__init__.py
b/mcp_gateway_sdk/__init__.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_sdk/__init__.py
rename to mcp_gateway_sdk/__init__.py
diff --git a/mcp-gateway/mcp_gateway_sdk/aws_token.py
b/mcp_gateway_sdk/aws_token.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_sdk/aws_token.py
rename to mcp_gateway_sdk/aws_token.py
diff --git a/mcp-gateway/mcp_gateway_sdk/sa_token.py
b/mcp_gateway_sdk/sa_token.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_sdk/sa_token.py
rename to mcp_gateway_sdk/sa_token.py
diff --git a/mcp-gateway/mcp_gateway_sdk/slack_signature.py
b/mcp_gateway_sdk/slack_signature.py
similarity index 100%
rename from mcp-gateway/mcp_gateway_sdk/slack_signature.py
rename to mcp_gateway_sdk/slack_signature.py
diff --git a/mcp-gateway/pylintrc b/pylintrc
similarity index 100%
rename from mcp-gateway/pylintrc
rename to pylintrc
diff --git a/mcp-gateway/pyproject.toml b/pyproject.toml
similarity index 100%
rename from mcp-gateway/pyproject.toml
rename to pyproject.toml
diff --git a/mcp-gateway/tests/__init__.py b/tests/__init__.py
similarity index 100%
rename from mcp-gateway/tests/__init__.py
rename to tests/__init__.py
diff --git a/mcp-gateway/tests/conftest.py b/tests/conftest.py
similarity index 100%
rename from mcp-gateway/tests/conftest.py
rename to tests/conftest.py
diff --git a/mcp-gateway/tests/integration/test_keycloak.py
b/tests/integration/test_keycloak.py
similarity index 100%
rename from mcp-gateway/tests/integration/test_keycloak.py
rename to tests/integration/test_keycloak.py
diff --git a/mcp-gateway/tests/request_utils.py b/tests/request_utils.py
similarity index 100%
rename from mcp-gateway/tests/request_utils.py
rename to tests/request_utils.py
diff --git a/mcp-gateway/tests/test_admin.py b/tests/test_admin.py
similarity index 100%
rename from mcp-gateway/tests/test_admin.py
rename to tests/test_admin.py
diff --git a/mcp-gateway/tests/test_audit.py b/tests/test_audit.py
similarity index 100%
rename from mcp-gateway/tests/test_audit.py
rename to tests/test_audit.py
diff --git a/mcp-gateway/tests/test_audit_logger.py b/tests/test_audit_logger.py
similarity index 97%
rename from mcp-gateway/tests/test_audit_logger.py
rename to tests/test_audit_logger.py
index 0b5e40b..da87e6f 100644
--- a/mcp-gateway/tests/test_audit_logger.py
+++ b/tests/test_audit_logger.py
@@ -98,9 +98,12 @@ async def
test_a_failed_audit_write_does_not_fail_the_call(db_session, regular_u
async def test_a_failed_audit_write_keeps_the_tools_own_error(db_session,
regular_user):
- with patch.object(
- AuditLogger, "log_tool_call", side_effect=SQLAlchemyError("data too
long")
- ), pytest.raises(HTTPException):
+ with (
+ patch.object(
+ AuditLogger, "log_tool_call", side_effect=SQLAlchemyError("data
too long")
+ ),
+ pytest.raises(HTTPException),
+ ):
async with AuditLogger.track_tool_call(
db=db_session, user=regular_user, service="logs", tool_name="t"
):
diff --git a/mcp-gateway/tests/test_auth_routes.py b/tests/test_auth_routes.py
similarity index 100%
rename from mcp-gateway/tests/test_auth_routes.py
rename to tests/test_auth_routes.py
diff --git a/mcp-gateway/tests/test_aws_token.py b/tests/test_aws_token.py
similarity index 96%
rename from mcp-gateway/tests/test_aws_token.py
rename to tests/test_aws_token.py
index 8d0daf2..d1bd9e7 100644
--- a/mcp-gateway/tests/test_aws_token.py
+++ b/tests/test_aws_token.py
@@ -126,9 +126,10 @@ def
test_a_token_for_a_named_audience_is_minted_for_the_pods_service_account(
def
test_the_token_is_for_the_gateways_url_without_asking_the_gateway(in_cluster):
"""Whoever answers the gateway's discovery documents must not choose the
audience."""
- with patch.object(
- aws_token.requests, "post", return_value=_minted("t")
- ) as post, patch("mcp_gateway_sdk.sa_token.requests.get") as get:
+ with (
+ patch.object(aws_token.requests, "post", return_value=_minted("t")) as
post,
+ patch("mcp_gateway_sdk.sa_token.requests.get") as get,
+ ):
assert get_gateway_sa_token(f"{GATEWAY}/", source="aws") == "t"
get.assert_not_called()
diff --git a/mcp-gateway/tests/test_catalog_defaults.py
b/tests/test_catalog_defaults.py
similarity index 100%
rename from mcp-gateway/tests/test_catalog_defaults.py
rename to tests/test_catalog_defaults.py
diff --git a/mcp-gateway/tests/test_cli_autostart.py
b/tests/test_cli_autostart.py
similarity index 100%
rename from mcp-gateway/tests/test_cli_autostart.py
rename to tests/test_cli_autostart.py
diff --git a/mcp-gateway/tests/test_cli_clients.py b/tests/test_cli_clients.py
similarity index 100%
rename from mcp-gateway/tests/test_cli_clients.py
rename to tests/test_cli_clients.py
diff --git a/mcp-gateway/tests/test_cli_doctor.py b/tests/test_cli_doctor.py
similarity index 100%
rename from mcp-gateway/tests/test_cli_doctor.py
rename to tests/test_cli_doctor.py
diff --git a/mcp-gateway/tests/test_cli_mcp_client.py
b/tests/test_cli_mcp_client.py
similarity index 100%
rename from mcp-gateway/tests/test_cli_mcp_client.py
rename to tests/test_cli_mcp_client.py
diff --git a/mcp-gateway/tests/test_cli_setup.py b/tests/test_cli_setup.py
similarity index 100%
rename from mcp-gateway/tests/test_cli_setup.py
rename to tests/test_cli_setup.py
diff --git a/mcp-gateway/tests/test_client_isolation.py
b/tests/test_client_isolation.py
similarity index 100%
rename from mcp-gateway/tests/test_client_isolation.py
rename to tests/test_client_isolation.py
diff --git a/mcp-gateway/tests/test_database.py b/tests/test_database.py
similarity index 100%
rename from mcp-gateway/tests/test_database.py
rename to tests/test_database.py
diff --git a/mcp-gateway/tests/test_device_flow.py b/tests/test_device_flow.py
similarity index 100%
rename from mcp-gateway/tests/test_device_flow.py
rename to tests/test_device_flow.py
diff --git a/mcp-gateway/tests/test_device_flow_routes.py
b/tests/test_device_flow_routes.py
similarity index 100%
rename from mcp-gateway/tests/test_device_flow_routes.py
rename to tests/test_device_flow_routes.py
diff --git a/mcp-gateway/tests/test_end_to_end.py b/tests/test_end_to_end.py
similarity index 100%
rename from mcp-gateway/tests/test_end_to_end.py
rename to tests/test_end_to_end.py
diff --git a/mcp-gateway/tests/test_gateway_jwt.py b/tests/test_gateway_jwt.py
similarity index 100%
rename from mcp-gateway/tests/test_gateway_jwt.py
rename to tests/test_gateway_jwt.py
diff --git a/mcp-gateway/tests/test_gravitino_admins.py
b/tests/test_gravitino_admins.py
similarity index 100%
rename from mcp-gateway/tests/test_gravitino_admins.py
rename to tests/test_gravitino_admins.py
diff --git a/mcp-gateway/tests/test_license_bin.py b/tests/test_license_bin.py
similarity index 100%
rename from mcp-gateway/tests/test_license_bin.py
rename to tests/test_license_bin.py
diff --git a/mcp-gateway/tests/test_local_proxy_forwarding.py
b/tests/test_local_proxy_forwarding.py
similarity index 100%
rename from mcp-gateway/tests/test_local_proxy_forwarding.py
rename to tests/test_local_proxy_forwarding.py
diff --git a/mcp-gateway/tests/test_log_filter.py b/tests/test_log_filter.py
similarity index 100%
rename from mcp-gateway/tests/test_log_filter.py
rename to tests/test_log_filter.py
diff --git a/mcp-gateway/tests/test_main_app.py b/tests/test_main_app.py
similarity index 100%
rename from mcp-gateway/tests/test_main_app.py
rename to tests/test_main_app.py
diff --git a/mcp-gateway/tests/test_mcp_access.py b/tests/test_mcp_access.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_access.py
rename to tests/test_mcp_access.py
diff --git a/mcp-gateway/tests/test_mcp_admin.py b/tests/test_mcp_admin.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_admin.py
rename to tests/test_mcp_admin.py
diff --git a/mcp-gateway/tests/test_mcp_catalog.py b/tests/test_mcp_catalog.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_catalog.py
rename to tests/test_mcp_catalog.py
diff --git a/mcp-gateway/tests/test_mcp_oauth.py b/tests/test_mcp_oauth.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_oauth.py
rename to tests/test_mcp_oauth.py
diff --git a/mcp-gateway/tests/test_mcp_oauth_discovery.py
b/tests/test_mcp_oauth_discovery.py
similarity index 98%
rename from mcp-gateway/tests/test_mcp_oauth_discovery.py
rename to tests/test_mcp_oauth_discovery.py
index df469a9..0de1d08 100644
--- a/mcp-gateway/tests/test_mcp_oauth_discovery.py
+++ b/tests/test_mcp_oauth_discovery.py
@@ -157,8 +157,9 @@ async def
test_metadata_that_isnt_the_servers_own_or_https_is_refused(
):
monkeypatch.setattr(mod.settings, "DEBUG", False)
- with patch.object(mod, "_fetch_json", return_value=document),
pytest.raises(
- ValueError, match=refusal
+ with (
+ patch.object(mod, "_fetch_json", return_value=document),
+ pytest.raises(ValueError, match=refusal),
):
await mod.discover_oauth_metadata(mcp_url)
diff --git a/mcp-gateway/tests/test_mcp_proxy.py b/tests/test_mcp_proxy.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_proxy.py
rename to tests/test_mcp_proxy.py
diff --git a/mcp-gateway/tests/test_mcp_sessions.py b/tests/test_mcp_sessions.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_sessions.py
rename to tests/test_mcp_sessions.py
diff --git a/mcp-gateway/tests/test_mcp_upstream_auth.py
b/tests/test_mcp_upstream_auth.py
similarity index 100%
rename from mcp-gateway/tests/test_mcp_upstream_auth.py
rename to tests/test_mcp_upstream_auth.py
diff --git a/mcp-gateway/tests/test_metrics.py b/tests/test_metrics.py
similarity index 100%
rename from mcp-gateway/tests/test_metrics.py
rename to tests/test_metrics.py
diff --git a/mcp-gateway/tests/test_oauth_auth_jwt.py
b/tests/test_oauth_auth_jwt.py
similarity index 100%
rename from mcp-gateway/tests/test_oauth_auth_jwt.py
rename to tests/test_oauth_auth_jwt.py
diff --git a/mcp-gateway/tests/test_oidc_client.py b/tests/test_oidc_client.py
similarity index 100%
rename from mcp-gateway/tests/test_oidc_client.py
rename to tests/test_oidc_client.py
diff --git a/mcp-gateway/tests/test_oidc_non_blocking.py
b/tests/test_oidc_non_blocking.py
similarity index 87%
rename from mcp-gateway/tests/test_oidc_non_blocking.py
rename to tests/test_oidc_non_blocking.py
index 231bb91..1cb7192 100644
--- a/mcp-gateway/tests/test_oidc_non_blocking.py
+++ b/tests/test_oidc_non_blocking.py
@@ -96,11 +96,15 @@ async def
test_refreshing_a_servers_token_keeps_the_loop_running():
encryption = MagicMock()
encryption.decrypt.return_value = "plain-refresh-token"
- with patch(
- "mcp_gateway.oauth.token_manager.get_token_encryption",
- AsyncMock(return_value=encryption),
- ), patch.object(TokenManager, "store_user_oauth_token", AsyncMock()),
patch.object(
- oidc_module.requests, "post", side_effect=_blocking(threads, response)
+ with (
+ patch(
+ "mcp_gateway.oauth.token_manager.get_token_encryption",
+ AsyncMock(return_value=encryption),
+ ),
+ patch.object(TokenManager, "store_user_oauth_token", AsyncMock()),
+ patch.object(
+ oidc_module.requests, "post", side_effect=_blocking(threads,
response)
+ ),
):
refreshed, ticks = await _ticks_during(
TokenManager(db)._refresh_user_token(1, "trino", stored)
@@ -126,8 +130,9 @@ async def
test_the_refresh_endpoint_reaches_the_provider_off_the_loop():
id=1, email="[email protected]"
)
- with patch("mcp_gateway.routes.auth.OIDCClient", return_value=oidc),
patch.object(
- TokenManager, "store_user_oauth_token", AsyncMock()
+ with (
+ patch("mcp_gateway.routes.auth.OIDCClient", return_value=oidc),
+ patch.object(TokenManager, "store_user_oauth_token", AsyncMock()),
):
response = await auth_routes.refresh_access_token(
auth_routes.RefreshTokenRequest(refresh_token="rt"), db=db
@@ -149,14 +154,14 @@ async def
test_fetching_a_jwt_signing_key_keeps_the_loop_running(monkeypatch):
db.query.return_value.filter.return_value.first.return_value = user
claims = {"preferred_username": user.email}
- with patch.object(
- oauth_auth, "_get_jwks_client", return_value=MagicMock()
- ), patch.object(
- oauth_auth,
- "_get_signing_key_with_retry",
- side_effect=_blocking(threads, MagicMock(key="signing-key")),
- ), patch.object(
- oauth_auth.jwt, "decode", return_value=claims
+ with (
+ patch.object(oauth_auth, "_get_jwks_client", return_value=MagicMock()),
+ patch.object(
+ oauth_auth,
+ "_get_signing_key_with_retry",
+ side_effect=_blocking(threads, MagicMock(key="signing-key")),
+ ),
+ patch.object(oauth_auth.jwt, "decode", return_value=claims),
):
result, ticks = await _ticks_during(
oauth_auth._validate_human_user_jwt(
diff --git a/mcp-gateway/tests/test_purge.py b/tests/test_purge.py
similarity index 100%
rename from mcp-gateway/tests/test_purge.py
rename to tests/test_purge.py
diff --git a/mcp-gateway/tests/test_sa_token.py b/tests/test_sa_token.py
similarity index 100%
rename from mcp-gateway/tests/test_sa_token.py
rename to tests/test_sa_token.py
diff --git a/mcp-gateway/tests/test_secret_storage.py
b/tests/test_secret_storage.py
similarity index 100%
rename from mcp-gateway/tests/test_secret_storage.py
rename to tests/test_secret_storage.py
diff --git a/mcp-gateway/tests/test_settings.py b/tests/test_settings.py
similarity index 100%
rename from mcp-gateway/tests/test_settings.py
rename to tests/test_settings.py
diff --git a/mcp-gateway/tests/test_slack_bot.py b/tests/test_slack_bot.py
similarity index 95%
rename from mcp-gateway/tests/test_slack_bot.py
rename to tests/test_slack_bot.py
index 314bf3e..6d717c4 100644
--- a/mcp-gateway/tests/test_slack_bot.py
+++ b/tests/test_slack_bot.py
@@ -88,10 +88,13 @@ def fixture_device_data():
@pytest.fixture(name="bot_db")
def fixture_bot_db(db_engine):
"""The bot's own database sessions, on the test's database."""
- with patch(SESSIONS, sessionmaker(bind=db_engine)), patch(
- "mcp_gateway.oauth.token_manager.get_token_encryption",
- new_callable=AsyncMock,
- return_value=ENCRYPTION,
+ with (
+ patch(SESSIONS, sessionmaker(bind=db_engine)),
+ patch(
+ "mcp_gateway.oauth.token_manager.get_token_encryption",
+ new_callable=AsyncMock,
+ return_value=ENCRYPTION,
+ ),
):
yield
@@ -278,9 +281,10 @@ async def
test_a_failure_after_login_does_not_escape_the_background_task(
respond = AsyncMock(side_effect=reply_error)
db = MagicMock()
- with patch(SESSIONS, lambda: db), patch(
- "mcp_gateway.slack.app.TokenManager"
- ) as token_manager:
+ with (
+ patch(SESSIONS, lambda: db),
+ patch("mcp_gateway.slack.app.TokenManager") as token_manager,
+ ):
token_manager.return_value.store_user_oauth_token = AsyncMock(
side_effect=store_error
)
@@ -315,8 +319,9 @@ def
test_the_cli_login_saves_the_tokens_the_device_flow_returns(
token_data={"access_token": "at", "refresh_token": "rt", "expires_in":
3600},
)
- with patch("mcp_gateway_cli.auth.save_tokens") as save_tokens, patch(
- "mcp_gateway_cli.auth.requests.get", side_effect=Exception("no
network")
+ with (
+ patch("mcp_gateway_cli.auth.save_tokens") as save_tokens,
+ patch("mcp_gateway_cli.auth.requests.get", side_effect=Exception("no
network")),
):
assert device_flow_login("https://gw.example.com") is True
diff --git a/mcp-gateway/tests/test_slack_service.py
b/tests/test_slack_service.py
similarity index 100%
rename from mcp-gateway/tests/test_slack_service.py
rename to tests/test_slack_service.py
diff --git a/mcp-gateway/tests/test_slack_signature.py
b/tests/test_slack_signature.py
similarity index 100%
rename from mcp-gateway/tests/test_slack_signature.py
rename to tests/test_slack_signature.py
diff --git a/mcp-gateway/tests/test_templates.py b/tests/test_templates.py
similarity index 100%
rename from mcp-gateway/tests/test_templates.py
rename to tests/test_templates.py
diff --git a/mcp-gateway/tests/test_token_encryption.py
b/tests/test_token_encryption.py
similarity index 100%
rename from mcp-gateway/tests/test_token_encryption.py
rename to tests/test_token_encryption.py
diff --git a/mcp-gateway/tests/test_token_manager.py
b/tests/test_token_manager.py
similarity index 100%
rename from mcp-gateway/tests/test_token_manager.py
rename to tests/test_token_manager.py
diff --git a/mcp-gateway/tests/test_tool_filtering.py
b/tests/test_tool_filtering.py
similarity index 100%
rename from mcp-gateway/tests/test_tool_filtering.py
rename to tests/test_tool_filtering.py
diff --git a/mcp-gateway/tests/test_upstream_tls.py b/tests/test_upstream_tls.py
similarity index 100%
rename from mcp-gateway/tests/test_upstream_tls.py
rename to tests/test_upstream_tls.py
diff --git a/mcp-gateway/tests/test_user_tokens.py b/tests/test_user_tokens.py
similarity index 98%
rename from mcp-gateway/tests/test_user_tokens.py
rename to tests/test_user_tokens.py
index 514dd7c..36f559b 100644
--- a/mcp-gateway/tests/test_user_tokens.py
+++ b/tests/test_user_tokens.py
@@ -141,12 +141,16 @@ def fixture_lookup(regular_user):
@pytest.fixture(autouse=True, name="send")
def fixture_send():
"""Slack accepts the approval message; tests may change the answer."""
- with patch(
- "mcp_gateway.routes.user_tokens.send_token_approval_message",
- new_callable=AsyncMock,
- return_value=True,
- ) as mock, patch(
- "mcp_gateway.routes.user_tokens.get_slack_web_client",
new_callable=AsyncMock
+ with (
+ patch(
+ "mcp_gateway.routes.user_tokens.send_token_approval_message",
+ new_callable=AsyncMock,
+ return_value=True,
+ ) as mock,
+ patch(
+ "mcp_gateway.routes.user_tokens.get_slack_web_client",
+ new_callable=AsyncMock,
+ ),
):
yield mock
diff --git a/mcp-gateway/tests/test_users.py b/tests/test_users.py
similarity index 100%
rename from mcp-gateway/tests/test_users.py
rename to tests/test_users.py
diff --git a/mcp-gateway/uv.lock b/uv.lock
similarity index 100%
rename from mcp-gateway/uv.lock
rename to uv.lock