Skip to content

Add structkit lint command and MCP tool#146

Merged
httpdss merged 1 commit intomainfrom
codex/add-feature-to-mcp-from-issue-137
May 9, 2026
Merged

Add structkit lint command and MCP tool#146
httpdss merged 1 commit intomainfrom
codex/add-feature-to-mcp-from-issue-137

Conversation

@httpdss
Copy link
Copy Markdown
Owner

@httpdss httpdss commented May 9, 2026

Motivation

  • Provide a stricter static quality/safety checker for StructKit YAML definitions to catch risky patterns that validate does not (duplicate entries, undefined template variables, unsafe hooks, unpinned remote URLs, etc.).
  • Expose lint functionality over MCP so external tools and automation (including AI workflows) can run lint checks programmatically.

Description

  • Add a new CLI command implemented in structkit/commands/lint.py (LintCommand) that lints YAML files or structure names with options --all and --json, and exits non-zero on lint errors.
  • Register the new lint subcommand in the main parser via structkit/main.py and update docs in docs/cli-reference.md and docs/mcp-integration.md.
  • Add an MCP tool lint_structure in structkit/mcp_server.py with transport-agnostic logic _lint_structure_logic and a compatibility handler _handle_lint_structure that return results in text or JSON.
  • Lint rules include: missing top-level description, undefined/unused variables, duplicate files/folders/variables, template syntax errors, invalid YAML, invalid hook shapes, suspicious/unsafe hooks (e.g., piping remote script to shell, rm /), unpinned GitHub raw/blob references, and variable naming conventions; Jinja filters/globals are stubbed for safe static parsing.

Testing

  • Ran the full test suite with pytest and all tests passed (170 passed).
  • Added unit tests for the CLI and MCP integration: tests exercising lint JSON output, error exit behavior, CLI parser registration, MCP tool registration, _lint_structure_logic and its compatibility handler; these tests passed under CI runs.
  • Manually exercised the command with python -m structkit.main lint structkit/contribs/terraform/modules/generic.yaml --json and python -m structkit.main lint --all --json to validate JSON/text output and summary counts, which produced expected results.

Codex Task

@httpdss httpdss merged commit 9a9497f into main May 9, 2026
3 checks passed
@httpdss httpdss deleted the codex/add-feature-to-mcp-from-issue-137 branch May 9, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant