Skip to content

Commit ba9a08b

Browse files
refactor(env): remove legacy K_SERVICE references
1 parent 60f516e commit ba9a08b

7 files changed

Lines changed: 11 additions & 44 deletions

File tree

docs/env/README.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ cache backend, and any platform-specific notes.
2626
| `MCP_CACHE_PORT` | `11211` | Memcached port |
2727
| `MCP_CACHE_URL` | _(none)_ | Redis connection URL (used when `MCP_CACHE_BACKEND=redis`) |
2828

29-
### Legacy variables (GCP Cloud Run — deprecated)
30-
31-
These are still read by the current codebase for backward compatibility with the
32-
existing GCP deployment. Prefer the explicit variables above for new deployments.
33-
34-
| Variable | Description |
35-
|---|---|
36-
| `K_SERVICE` | Cloud Run service name — auto-injects `MCP_BASE_URL`, `MCP_OPENAPI_ENV`, Memcached IPs |
37-
3829
---
3930

4031
## Why storage matters

docs/env/gcp.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,6 @@ MCP_CACHE_PORT=11211
4343

4444
---
4545

46-
## Legacy variables (backward compatibility)
47-
48-
If you are using a Cloud Run deployment without migrating to the
49-
explicit variables above, the following variables are still read:
50-
51-
| Variable | Effect |
52-
|---|---|
53-
| `K_SERVICE` | Auto-set by Cloud Run. Derives `MCP_BASE_URL` (`K_SERVICE.replace("-",".")`) and `MCP_OPENAPI_ENV` (from service name prefix), and selects the Memcached VPC IP. |
54-
55-
> **Migration path:** set `MCP_BASE_URL`, `MCP_OPENAPI_ENV`, `MCP_CACHE_HOST` explicitly
56-
> and stop relying on `K_SERVICE`. This makes the server portable to any platform.
57-
58-
---
59-
6046
## Cloud Run deployment
6147

6248
### Cloud Run service YAML

docs/testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ MCP_URL=https://abcd1234.ngrok-free.app SANDBOX=1 make test-openai-sandbox
126126
| Data | real | simulated |
127127
| Token variable | `OPENAPI_TOKEN` | `OPENAPI_SANDBOX_TOKEN` |
128128

129-
The MCP server switches between production and sandbox based on the `K_SERVICE` environment
130-
variable (handled automatically by the test runners).
129+
The MCP server switches between production and sandbox based on the `MCP_OPENAPI_ENV`
130+
environment variable (handled automatically by the test runners).
131131

132132
---
133133

src/openapi_mcp_sdk/memory_store.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
callback_results = {}
1717

18-
MCP_STORAGE_BUCKET = os.getenv("MCP_STORAGE_BUCKET", "mcp-openapi-storage")
19-
2018
MCP_ENV = os.getenv("MCP_ENV", "production").strip().lower()
2119
if MCP_ENV not in {"dev", "staging", "production"}:
2220
logger.warning("Invalid MCP_ENV=%r, defaulting to 'production'", MCP_ENV)
@@ -25,14 +23,6 @@
2523
MCP_OPENAPI_ENV = os.getenv("MCP_OPENAPI_ENV", "").strip().lower()
2624
if MCP_OPENAPI_ENV == "sandbox":
2725
MCP_OPENAPI_ENV = "test"
28-
if not MCP_OPENAPI_ENV and K_SERVICE and K_SERVICE != "mcp-openapi-com":
29-
candidate = K_SERVICE.split("-")[0].strip().lower()
30-
if candidate == "alpha":
31-
candidate = "dev"
32-
if candidate == "sandbox":
33-
candidate = "test"
34-
if candidate in {"dev", "test"}:
35-
MCP_OPENAPI_ENV = candidate
3626
if MCP_OPENAPI_ENV not in {"", "dev", "test"}:
3727
logger.warning("Invalid MCP_OPENAPI_ENV=%r, defaulting to production", MCP_OPENAPI_ENV)
3828
MCP_OPENAPI_ENV = ""

tests/integration/run-vs-claude.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ SERVER_PID=""
1414
SANDBOX="${SANDBOX:-0}"
1515
if [ "$SANDBOX" = "1" ]; then
1616
TOKEN="${OPENAPI_SANDBOX_TOKEN:-}"
17-
K_SERVICE_VALUE="test-openapi-mcp-server"
17+
MCP_OPENAPI_ENV_VALUE="test"
1818
else
1919
TOKEN="${OPENAPI_TOKEN:-}"
20-
K_SERVICE_VALUE=""
20+
MCP_OPENAPI_ENV_VALUE=""
2121
fi
2222

2323
cleanup() {
@@ -68,7 +68,7 @@ EOF
6868

6969
echo "Starting MCP server..."
7070
cd "$ROOT_DIR"
71-
K_SERVICE="$K_SERVICE_VALUE" PYTHONPATH=src uv run uvicorn openapi_mcp_sdk.main:app \
71+
MCP_OPENAPI_ENV="$MCP_OPENAPI_ENV_VALUE" PYTHONPATH=src uv run uvicorn openapi_mcp_sdk.main:app \
7272
--host 0.0.0.0 --port 8080 --log-level warning &
7373
SERVER_PID=$!
7474

tests/integration/run-vs-codex.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ SERVER_PID=""
1515
SANDBOX="${SANDBOX:-0}"
1616
if [ "$SANDBOX" = "1" ]; then
1717
TOKEN="${OPENAPI_SANDBOX_TOKEN:-}"
18-
K_SERVICE_VALUE="test-openapi-mcp-server"
18+
MCP_OPENAPI_ENV_VALUE="test"
1919
else
2020
TOKEN="${OPENAPI_TOKEN:-}"
21-
K_SERVICE_VALUE=""
21+
MCP_OPENAPI_ENV_VALUE=""
2222
fi
2323

2424
cleanup() {
@@ -66,7 +66,7 @@ codex mcp add "$MCP_SERVER_NAME" \
6666

6767
echo "Starting MCP server..."
6868
cd "$ROOT_DIR"
69-
K_SERVICE="$K_SERVICE_VALUE" PYTHONPATH=src uv run uvicorn openapi_mcp_sdk.main:app \
69+
MCP_OPENAPI_ENV="$MCP_OPENAPI_ENV_VALUE" PYTHONPATH=src uv run uvicorn openapi_mcp_sdk.main:app \
7070
--host 0.0.0.0 --port 8080 --log-level warning &
7171
SERVER_PID=$!
7272

tests/integration/run-vs-openai.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ SERVER_PID=""
1313
SANDBOX="${SANDBOX:-0}"
1414
if [ "$SANDBOX" = "1" ]; then
1515
TOKEN="${OPENAPI_SANDBOX_TOKEN:-}"
16-
K_SERVICE_VALUE="test-openapi-mcp-server"
16+
MCP_OPENAPI_ENV_VALUE="test"
1717
else
1818
TOKEN="${OPENAPI_TOKEN:-}"
19-
K_SERVICE_VALUE=""
19+
MCP_OPENAPI_ENV_VALUE=""
2020
fi
2121

2222
# MCP_URL: the URL OpenAI will use to reach the MCP server.
@@ -64,7 +64,7 @@ echo "MCP_URL: $MCP_URL"
6464

6565
echo "Starting MCP server..."
6666
cd "$ROOT_DIR"
67-
K_SERVICE="$K_SERVICE_VALUE" PYTHONPATH=src uv run uvicorn openapi_mcp_sdk.main:app \
67+
MCP_OPENAPI_ENV="$MCP_OPENAPI_ENV_VALUE" PYTHONPATH=src uv run uvicorn openapi_mcp_sdk.main:app \
6868
--host 0.0.0.0 --port 8080 --log-level warning &
6969
SERVER_PID=$!
7070

0 commit comments

Comments
 (0)