cfg_dry_run
Dry-run OpenSIPS configuration preprocessing and validation. Safely test config edits by running M4 preprocessing and syntax checks without writing changes, ensuring correctness before saving.
Instructions
Safely iterate on a config: preprocess + validate, write nothing.
Intended as the LLM's tight feedback loop while building or editing a config — call this between successive renders to verify correctness before asking the user to save.
Parameters
main_m4:
Contents of opensips.cfg.m4.
local_m4:
Contents of local.cfg.m4.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| main_m4 | Yes | ||
| local_m4 | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The `cfg_dry_run` tool handler function. It runs m4 preprocessing on the two m4 strings (main_m4 and local_m4), optionally validates the output using opensips -C -f if the binary is available, and returns the rendered configuration, validation results, and an overall 'ok' status. This is intended as a safe, write-nothing feedback loop for LLMs iterating on configs.
@mcp.tool() @require_permission("config.read") async def cfg_dry_run( ctx: Context, main_m4: str, local_m4: str, ) -> dict[str, Any]: """Safely iterate on a config: preprocess + validate, write nothing. Intended as the LLM's tight feedback loop while building or editing a config — call this between successive renders to verify correctness before asking the user to save. Parameters ---------- main_m4: Contents of ``opensips.cfg.m4``. local_m4: Contents of ``local.cfg.m4``. """ pre = await run_m4(main_m4, local_m4) validation = ( await _validate_if_available(pre.output_cfg) if pre.success else { "valid": False, "errors": ["m4 preprocessing failed; skipping opensips validation."], "warnings": [], "raw_output": "", } ) overall_ok = pre.success and validation.get("valid") in (True, None) return { "output_cfg": pre.output_cfg, "m4_stderr": pre.m4_stderr, "m4_returncode": pre.m4_returncode, "m4_success": pre.success, "validation": validation, "ok": overall_ok, "lines_rendered": len(pre.output_cfg.splitlines()), } - src/opensips_mcp/tools/cfg_tools.py:843-844 (registration)The tool is registered with `@mcp.tool()` decorator at line 843, making it available as an MCP tool named 'cfg_dry_run'.
@mcp.tool() @require_permission("config.read") - src/opensips_mcp/tools/cfg_tools.py:844-844 (registration)The tool has the `@require_permission('config.read')` permission decorator, allowing read-only access (no audit log).
@require_permission("config.read")