Coverage for app / mcp / __init__.py: 100%
4 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-31 11:23 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-10-31 11:23 +0000
1"""
2MCP (Model Context Protocol) servers — not available in this release.
4``MCP_AVAILABLE`` is the kill switch for every path in svc-ai that would
5connect to an MCP server: loading a server's tools for an agent or skill node,
6and probing one. With it off, a descriptor is never parsed, no client is
7built and no subprocess is spawned, whatever svc-core forwards.
9It is a constant rather than a setting on purpose: no environment variable or
10dotenv file can turn it on, so enabling MCP is a reviewed code change. svc-core
11holds its own copy (``app/services/mcp.py``) and refuses every write that would
12configure a server, so neither service trusts the other to have switched off.
14Why it is off: as built, a stdio server runs as a subprocess *inside svc-ai*
15(the container holding the provider keys, on ``ai-network``), and every
16launcher it allows executes arbitrary code by design (``npx <any package>``,
17``python -c``); an http/sse URL is checked only for its scheme, so it can name
18an internal service; and connection credentials are stored as plaintext JSON.
19Before turning it on:
21* run stdio servers in an isolated sidecar, never in svc-ai;
22* refuse http/sse URLs that resolve to a private, loopback, link-local or
23 reserved address, as svc-core's feed fetcher does;
24* keep connection credentials in the secrets vault (roadmap Phase 4).
26``tests/mcp/test_unavailable.py`` pins it off.
27"""
29#: Off in every environment — see the module docstring before changing it.
30MCP_AVAILABLE: bool = False
32#: What a caller is told when it asks for something MCP would provide.
33UNAVAILABLE_MESSAGE = (
34 "MCP servers are coming soon — they are not available in this release."
35)
38def is_available() -> bool:
39 """Whether MCP servers may be connected to.
41 Read at call time, so a test can switch it on for the code paths kept
42 ready for when it ships.
43 """
44 return MCP_AVAILABLE