Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

feat(mcp): warn add_resource callers about gateway headers on temp_upload (#5068)

yorick1c0e68e267a1
diff --git a/openviking/server/mcp_endpoint.py b/openviking/server/mcp_endpoint.py
index 0061e4a7d..14b83fc17 100644
--- a/openviking/server/mcp_endpoint.py
+++ b/openviking/server/mcp_endpoint.py
@@ -1227,8 +1227,16 @@ async def add_resource(
"\n"
f" {upload_url}\n"
"\n"
- "The URL's token authorizes the upload (no API key needed); the server ingests "
- "the file automatically once received — you do NOT need to call add_resource again.\n"
+ "The URL's token authorizes the upload against OpenViking itself (no OpenViking "
+ "API key needed); the server ingests the file automatically once received — you "
+ "do NOT need to call add_resource again.\n"
+ "\n"
+ "If the OpenViking server sits behind a private gateway or reverse proxy that "
+ "requires extra request headers (e.g. `openviking_name`, tenant/vault headers, "
+ "or a gateway API key), those headers are enforced on every request including "
+ "this upload — replay the same headers you use for MCP calls when POSTing the "
+ "file. A gateway rejection typically looks like HTTP 400/401/403 before the "
+ "token is even checked.\n"
"\n"
f"This upload URL expires in ~{minutes} minutes ({expires_iso})."
)
diff --git a/tests/server/test_mcp_endpoint.py b/tests/server/test_mcp_endpoint.py
index 20977edf2..336072e9a 100644
--- a/tests/server/test_mcp_endpoint.py
+++ b/tests/server/test_mcp_endpoint.py
@@ -1053,6 +1053,23 @@ async def test_add_resource_local_path_returns_upload_instruction(service):
upload_token_store.clear()
+async def test_add_resource_local_path_mentions_gateway_headers(service):
+ """The prose must warn agents that private-gateway headers apply to the upload too.
+
+ Prevents the "no API key needed" line from being read as "no headers needed" when
+ the deployment sits behind a gateway that enforces tenant/vault headers.
+ """
+ from openviking.server.upload_token_store import upload_token_store
+
+ upload_token_store.clear()
+ result = await add_resource(path="/tmp/sample_local_file_xyz.pdf")
+ lower = result.lower()
+ assert "gateway" in lower or "reverse proxy" in lower
+ assert "openviking_name" in lower or "extra request headers" in lower
+ assert "replay" in lower or "same headers" in lower
+ upload_token_store.clear()
+
+
async def test_add_resource_local_path_uses_env_var_when_set(service, monkeypatch):
from openviking.server.upload_token_store import upload_token_store