|
| 1 | +--- |
| 2 | +title: API Reference |
| 3 | +description: "agnix CLI flags, output formats, MCP server tools, and LSP capabilities." |
| 4 | +--- |
| 5 | + |
| 6 | +# API Reference |
| 7 | + |
| 8 | +## CLI |
| 9 | + |
| 10 | +```bash |
| 11 | +agnix [OPTIONS] [PATH] |
| 12 | +``` |
| 13 | + |
| 14 | +### Options |
| 15 | + |
| 16 | +| Flag | Description | |
| 17 | +|------|-------------| |
| 18 | +| `[PATH]` | Directory or file to validate (default: `.`) | |
| 19 | +| `--target <TOOL>` | Single tool focus (`generic`, `claude-code`, `cursor`, `codex`, `kiro`) | |
| 20 | +| `--fix` | Apply HIGH and MEDIUM confidence fixes | |
| 21 | +| `--dry-run` | Preview fixes without modifying files | |
| 22 | +| `--fix-safe` | Apply only HIGH confidence fixes | |
| 23 | +| `--fix-unsafe` | Apply all fixes, including LOW confidence fixes | |
| 24 | +| `--show-fixes` | Show proposed fix diffs in text output | |
| 25 | +| `--format <FMT>` | Output format: `text` (default), `json`, `sarif` | |
| 26 | +| `--strict` | Treat warnings as errors (exit code 1) | |
| 27 | +| `--config <PATH>` | Config file path (default: `.agnix.toml`) | |
| 28 | +| `--watch`, `-w` | Watch mode - re-validate on file changes | |
| 29 | +| `--locale <LOCALE>` | Set output locale, e.g. `en`, `es`, `zh-CN` | |
| 30 | +| `--list-locales` | List supported locales and exit | |
| 31 | +| `--max-files <N>` | Maximum number of files to validate | |
| 32 | +| `--verbose`, `-v` | Verbose output | |
| 33 | +| `--version` | Print version | |
| 34 | +| `--help` | Print help | |
| 35 | + |
| 36 | +### Subcommands |
| 37 | + |
| 38 | +| Command | Description | |
| 39 | +|---------|-------------| |
| 40 | +| `agnix validate [PATH]` | Validate agent configs explicitly | |
| 41 | +| `agnix init` | Initialize a config file | |
| 42 | +| `agnix eval <FILE>` | Evaluate rule efficacy against labeled test cases | |
| 43 | +| `agnix schema [--output FILE] [--fix]` | Output or regenerate JSON Schema for `.agnix.toml` | |
| 44 | +| `agnix tools check` | Check configured tool versions | |
| 45 | +| `agnix tools detect` | Detect installed tool versions | |
| 46 | +| `agnix telemetry <status\|enable\|disable>` | Manage telemetry settings | |
| 47 | + |
| 48 | +### Output formats |
| 49 | + |
| 50 | +- **text** - Human-readable terminal output with colors |
| 51 | +- **json** - Machine-readable JSON object with diagnostics and summary metadata (e.g. version, files_checked, diagnostics, summary, category, rule_severity, applies_to_tool) |
| 52 | +- **sarif** - SARIF format for GitHub Code Scanning integration |
| 53 | + |
| 54 | +## MCP server |
| 55 | + |
| 56 | +```bash |
| 57 | +cargo install agnix-mcp |
| 58 | +agnix-mcp |
| 59 | +``` |
| 60 | + |
| 61 | +The MCP server exposes these tools: |
| 62 | + |
| 63 | +| Tool | Description | |
| 64 | +|------|-------------| |
| 65 | +| `validate_file` | Validate a single configuration file | |
| 66 | +| `validate_project` | Validate all config files in a project | |
| 67 | +| `get_rules` | List all available validation rules | |
| 68 | +| `get_rule_docs` | Get documentation for a specific rule | |
| 69 | + |
| 70 | +## LSP server |
| 71 | + |
| 72 | +```bash |
| 73 | +cargo install agnix-lsp |
| 74 | +agnix-lsp |
| 75 | +``` |
| 76 | + |
| 77 | +Supported LSP capabilities: |
| 78 | + |
| 79 | +- `textDocument/publishDiagnostics` - real-time validation |
| 80 | +- `textDocument/codeAction` - auto-fix suggestions |
| 81 | +- `textDocument/hover` - rule documentation on hover |
| 82 | +- `workspace/didChangeConfiguration` - runtime config updates |
| 83 | +- `workspace/executeCommand` - project-level validation (`agnix.validateProjectRules` command) |
| 84 | + |
| 85 | +## References |
| 86 | + |
| 87 | +- [SPEC.md](https://github.com/agent-sh/agnix/blob/main/SPEC.md) - full technical specification |
| 88 | +- [MCP Protocol](https://modelcontextprotocol.io) - MCP specification |
0 commit comments