Skip to content

[Infra][Agent] Implement MCP Server & Codex Skill Definition #12

@copparihollmann

Description

@copparihollmann

Context

To enable autonomous agents (like Claude Desktop or Codex) to interact with our compiler tooling, we need a standardized interface. The Model Context Protocol (MCP) provides this bridge, converting our Python functions into agent-callable tools. Additionally, defining a "Skill" with documentation references allows the agent to understand how and when to use these tools effectively.

Objective

Implement the mlirAgent MCP server, a unified CLI, and the .codex skill definition to expose our deterministic tools (build, compile, trace) to AI agents.

Scope of Work

  1. Unified CLI (src/mlirAgent/cli.py): * Implement a central argparse entry point wrapping run_build, run_compile, verify_output, and trace_provenance.
    • Ensure it supports both direct shell usage and library import.
  2. Configuration (src/mlirAgent/config.py): * Implement Config class to load paths from .env.
    • Add a validate() method to warn if IREE_SRC_PATH or ninja are missing.
  3. MCP Server (src/mlirAgent/mcp_server.py): * Implement FastMCP("mlirEvolve").
    • Expose tools: build, compile_mlir, verify_ir, provenance_trace.
    • Ensure error handling returns structured JSON, not Python stack traces.
  4. Codex Skill Definition (.codex/skills/mlir-evolve/):
    • SKILL.md: Define the persona and capabilities (Build, Dialect, Provenance).
    • references/*.md: Add repo-map.md, infra.md, and tool-conventions.md to guide the agent's reasoning.

Acceptance Criteria

  • Test 1 (CLI): python src/mlirAgent/cli.py compile --help returns valid help text.
  • Test 2 (Config): Config.validate() correctly identifies if IREE_SRC_PATH is invalid.
  • Test 3 (MCP): Starting the MCP server exposes the provenance_trace tool with the correct argument schema (artifacts_root, source_filename, line).
  • Test 4 (Documentation): The .codex directory structure is populated, and SKILL.md correctly references the src/mlirAgent/tools/ layout.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions