~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
test(security): tripwire pinning the MCP server to STDIO-only (#6544)
LearningCircuitbb1f4c84cb80
diff --git a/tests/security/test_mcp_stdio_only_tripwire.py b/tests/security/test_mcp_stdio_only_tripwire.pynew file mode 100644index 0000000000..b357c0bcb5--- /dev/null+++ b/tests/security/test_mcp_stdio_only_tripwire.py@@ -0,0 +1,73 @@+"""Structural tripwire: the MCP server never opens a network listener.++The MCP server's security posture is "STDIO-only transport, no auth by+design" (SECURITY.md / lens 15): it is launched as a child process by+a trusted local parent and exchanges JSON-RPC over stdin/stdout. The+moment anyone adds a network listener — uvicorn, a socket bind, an+HTTP server — that posture silently becomes "unauthenticated remote+API", because none of the web tier's auth stack guards this process.++Nothing pinned this. These contracts make any listener introduction+red: the single ``mcp.run()`` transport must stay ``stdio``, and the+module must not reference any network-serving machinery.+"""++from __future__ import annotations++import re+from pathlib import Path++import local_deep_research.mcp.server as mcp_server++MODULE_PATH = Path(mcp_server.__file__)+++def _code_lines() -> list[str]:+ """Module source minus comments and docstrings-approximation.++ Line comments are stripped; loguru's ``logger.bind`` is excluded+ from the bind-tripwire by the token patterns themselves.+ """+ lines = []+ for raw in MODULE_PATH.read_text(encoding="utf-8").splitlines():+ stripped = raw.strip()+ if stripped.startswith("#"):+ continue+ lines.append(raw)+ return lines+++class TestMcpStaysStdioOnly:+ def test_the_only_transport_is_stdio(self):+ runs = [+ line+ for line in _code_lines()+ if re.search(r"\bmcp\.run\s*\(", line)+ ]+ assert runs, "no mcp.run() call found — transport moved elsewhere?"+ for line in runs:+ assert 'transport="stdio"' in line, (+ f"mcp.run() without stdio transport: {line.strip()!r}"+ )++ def test_no_network_listener_machinery(self):+ patterns = {+ "uvicorn": r"\buvicorn\b",+ "socket bind/listen": r"\.(?:bind|listen)\s*\(",+ "socket module": r"\bimport\s+socket\b|\bsocket\.socket\b",+ "http server": r"\b(?:HTTPServer|TCPServer|UDPServer|Flask)\b",+ }+ for label, pattern in patterns.items():+ hits = [+ line.strip()+ for line in _code_lines()+ if re.search(pattern, line)+ # loguru's logger.bind(...) is not a socket bind.+ and not re.search(r"logger\.bind\s*\(", line)+ ]+ assert hits == [], f"{label} referenced in MCP server: {hits}"++ def test_module_path_is_the_production_server(self):+ # Guard against the scan drifting onto a test double.+ assert MODULE_PATH.name == "server.py"+ assert MODULE_PATH.parent.name == "mcp"