summaryrefslogtreecommitdiff
path: root/tests/test_mcp.py
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-06-27 01:09:00 +0900
committertanaka takashi <isazaka@gmail.com>2026-06-27 01:09:00 +0900
commitfce9dc1b2940ee6699d2acf0c9e56456d9899581 (patch)
tree6bb0cfd1b220b7a37f77d55348803dd46ea30e45 /tests/test_mcp.py
parent3a9e8e18df4c596360da54000f65e1bebc6039c2 (diff)
MCP server機能をセキュア化
Diffstat (limited to 'tests/test_mcp.py')
-rw-r--r--tests/test_mcp.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/test_mcp.py b/tests/test_mcp.py
index f538a8f..4f649d9 100644
--- a/tests/test_mcp.py
+++ b/tests/test_mcp.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import sys
import tempfile
from pathlib import Path
@@ -25,6 +26,8 @@ def client(monkeypatch):
monkeypatch.setattr(settings, "pin", "123456")
monkeypatch.setattr(settings, "secret_key", "test-secret")
monkeypatch.setattr(settings, "allowed_origins", [])
+ monkeypatch.setattr(settings, "mcp_stdio_allowlist", [sys.executable])
+ monkeypatch.setattr(settings, "mcp_https_allowlist", [])
with tempfile.TemporaryDirectory() as tmp:
monkeypatch.setattr(settings, "data_dir", tmp)
client = TestClient(create_app())
@@ -67,8 +70,11 @@ def test_mcp_config_api(client):
payload = {
"mcpServers": {
- "fs": {"command": "npx", "args": ["-y", "server"]},
- "remote": {"url": "https://example.com/mcp", "timeout": 60},
+ "fs": {
+ "command": sys.executable,
+ "args": ["mcp_servers/calc_server.py"],
+ },
+ "remote": {"url": "http://127.0.0.1:9000/mcp", "timeout": 60},
}
}
res = client.put(
@@ -78,7 +84,7 @@ def test_mcp_config_api(client):
)
assert res.status_code == 200
data = res.json()
- assert data["mcpServers"]["fs"]["command"] == "npx"
+ assert data["mcpServers"]["fs"]["command"] == sys.executable
assert data["mcpServers"]["remote"]["timeout"] == 60.0
res = client.get("/api/mcp/servers")
@@ -139,4 +145,4 @@ def test_tool_registry_mcp_tool():
# to ollama as a callable (ollama needs the dict definition only).
assert len(reg.ollama_tools) == 1
result = reg.execute("mcp__s__t", {})
- assert result == "ok" \ No newline at end of file
+ assert result == "ok"