|
Option C Tools
|
Classes | |
| class | McpConfig |
Functions | |
| None | _dbg (*args, **kwargs) |
| McpConfig | load_config (Path|None path=None) |
| McpConfig | _apply_json (McpConfig base, dict data) |
Variables | |
| int | _CONFIG_MAX_BYTES = 64 * 1024 |
| Path | _DEFAULT_CONFIG_PATH = Path.home() / ".oct-mcp" / "config.json" |
| tuple | VALID_MCP_PROFILES = ("default", "strict", "airgapped") |
| int | _RATE_LIMIT_MIN = 1 |
| int | _RATE_LIMIT_MAX = 1000 |
| int | _TIMEOUT_MIN = 5 |
| int | _TIMEOUT_MAX = 300 |
| int | _TIMEOUT_TEST_MAX = 600 |
| int | _MAX_OUTPUT_MIN = 1024 |
| int | _MAX_OUTPUT_MAX = 10 * 1024 * 1024 |
| int | _MAX_JOBS_MIN = 1 |
| int | _MAX_JOBS_MAX = 16 |
| int | _MEMORY_LIMIT_MIN = 0 |
| int | _MEMORY_LIMIT_MAX = 8192 |
| int | _METRICS_PORT_MIN = 1 |
| int | _METRICS_PORT_MAX = 65535 |
| tuple | VALID_SANDBOX_BACKENDS = ("auto", "native", "bubblewrap", "sandbox_exec") |
Purpose
-------
Configuration loader for the ``oct-mcp`` server. Reads
``~/.oct-mcp/config.json`` (user-level trusted config), merges with
environment variable overrides, and exposes a :class:`McpConfig`
dataclass consumed by every layer of the six-layer pipeline.
Responsibilities
----------------
- Define the canonical :class:`McpConfig` schema with safe defaults.
- Implement :func:`load_config` which locates, validates, and returns a
populated ``McpConfig``.
- Honour ``OCT_MCP_SAFE_MODE`` and ``OCT_TRUST_REPO_CONFIG`` env vars.
- Never read or trust project-level config (``debug_config.json``,
``.octrc.json``) unless ``trust_repo_config`` is explicitly enabled.
- Apply a 64 KB file-size guard (matching OI-414) to the user config.
Diagnostics
-----------
Domain: MCP
Levels:
L1 — errors: config file read failures, schema errors
L2 — lifecycle: config loaded, safe-mode active
L4 — deep trace: resolved field values
Contracts
---------
- This module does not import ``click``, the MCP SDK, or any other
``oct.mcp.*`` module (no cycles).
- :func:`load_config` always returns a fully-populated ``McpConfig``
even if the file is missing — defaults are safe.
- Config values coming from JSON are validated and clamped so callers
never receive out-of-range integers.
Return a new :class:`McpConfig` with fields from *data* merged in. Only known fields are applied; unknown keys are silently ignored (the config file is user-controlled but we don't crash on new keys). Field values are clamped to the valid ranges defined by the module constants. Booleans must be actual JSON booleans, not strings.
Definition at line 248 of file config.py.
|
protected |
| McpConfig oct.mcp.config.load_config | ( | Path | None | path = None | ) |
Load and return a :class:`McpConfig`. Resolution order: 1. Read ``~/.oct-mcp/config.json`` (or *path* if supplied). 2. Validate and clamp JSON field values. 3. Apply environment variable overrides: - ``OCT_MCP_SAFE_MODE=1`` → ``safe_mode = True`` - ``OCT_TRUST_REPO_CONFIG=1`` → ``trust_repo_config = True`` - ``OCT_MCP_PROFILE=<name>`` → ``profile = <name>`` 4. Return a fully-populated ``McpConfig``. Never raises. Any read or parse failure falls back to the default config and logs an error at level 1.
Definition at line 180 of file config.py.
|
protected |
|
protected |
| tuple oct.mcp.config.VALID_MCP_PROFILES = ("default", "strict", "airgapped") |