Skip to main content
Glama

CodeForgeX: Deterministic AI-Agent Evaluation Environment & MCP Software Engineering Harness

Python 3.10+ MCP SDK v2 Tests Passing Benchmark Score Docker Hardened License: MIT

CodeForgeX is an enterprise-grade, deterministic AI-agent software engineering evaluation environment and tool-calling execution harness. Built on the official Model Context Protocol (MCP Python SDK v2), it provides an isolated, uncheatable sandbox where AI agents explore repositories, reproduce failures, formulate hypotheses, apply unified diff patches, and verify solutions against public and hidden test suites.

Unlike subjective "LLM-as-a-judge" grading, CodeForgeX employs deterministic, multi-criteria verification with cryptographic test tampering detection, regression guards, and wall-clock execution limits.


Architecture Topology

flowchart TD
    subgraph ControlPlane["CLI & Orchestration (scripts/run_evaluation.py)"]
        CLI["CLI Runner"] --> Runner["EvaluationRunner"]
        CLI --> Loop["AgentExecutionLoop"]
    end

    subgraph AgentLayer["Autonomous Agent & Planning (src/agent/)"]
        Loop --> Planner["SystematicSWEPlanner / LLMPlanner"]
        Planner -->|AgentAction| Loop
        Loop -->|call_tool| Client["MCPClient (Async stdio)"]
    end

    subgraph ProtocolBoundary["Model Context Protocol Boundary"]
        Client <==>|Anonymous OS Pipes (stdio JSON-RPC)| Server["MCPServer (Subprocess)"]
    end

    subgraph ToolSurface["Sandboxed Tool Surface (src/mcp_server/)"]
        Server --> T1["list_files"]
        Server --> T2["read_file"]
        Server --> T3["search_code"]
        Server --> T4["apply_patch"]
        Server --> T5["get_git_diff"]
        Server --> T6["run_tests"]
        Server --> T7["get_test_output"]
        Server --> T8["get_repository_status"]
    end

    subgraph SecurityBoundary["Security & Anti-Cheat Sandbox (src/mcp_server/security/)"]
        T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 --> Sandbox["SecurityPolicy Engine"]
        Sandbox --> Guard1["Path Traversal Containment"]
        Sandbox --> Guard2["Anti-Cheat (Hidden Tests Isolated)"]
        Sandbox --> Guard3["Command Whitelisting & Injection Defense"]
    end

    subgraph TaskWorkspaces["Ephemeral Sandboxes (tasks/)"]
        Guard1 & Guard2 & Guard3 --> TargetRepo["Ephemeral Workspace (.git)"]
    end

    subgraph Evaluator["Deterministic Evaluator Engine (src/evaluator/)"]
        TargetRepo --> Verifier["TaskVerifier"]
        Verifier --> ShaCheck["SHA-256 Digest Tamper Check"]
        Verifier --> PublicRun["Public Test Execution"]
        Verifier --> HiddenRun["Privileged Hidden Test Suite"]
        Verifier --> DiffAnalysis["Git Diff & Line Metrics"]
        ShaCheck & PublicRun & HiddenRun & DiffAnalysis --> Scorer["ScoringEngine (100 Pt Model)"]
        Scorer --> Artifacts["Telemetry Artifacts (results/eval_*.json, .md)"]
    end

Related MCP server: MCP Software-Engineering RL Environment

Key System Capabilities

  • Official Model Context Protocol (SDK v2): Real-time tool discovery and execution over standard I/O (stdio), eliminating TCP port exhaustion and network race conditions.

  • Multi-Provider Schema Reflection: Dynamic tool schema conversion supporting OpenAI function calling, Anthropic Claude, and Google Gemini function declarations.

  • Multi-Dimensional Scoring (0 - 100 Points):

    • Task Completion (40 pts)

    • Hidden Verification Tests (25 pts)

    • Public Baseline Tests (15 pts)

    • Regression Safety (10 pts)

    • Tool Efficiency & Token Conservation (5 pts)

    • Patch Conciseness & Quality (5 pts)

  • Anti-Cheat & Anti-Tampering Protection: Dual-layer defense with cryptographic SHA-256 test file digest verification. Modifying or deleting test assertions forces an immediate 0.0 / 100.0 disqualification score.

  • Systematic SWE Reasoning Workflow: Enforces Test-Driven Software Engineering: EXPLORE $\rightarrow$ REPRODUCE $\rightarrow$ ANALYZE $\rightarrow$ PATCH $\rightarrow$ VERIFY $\rightarrow$ FINISH.

  • Fault-Tolerant Circuit Breakers: Active consecutive-failure guards prevent runaway token expenditure and model hallucination loops.

  • Hardened Docker Isolation: Non-root user execution (uid=1000), cap_drop: [ALL], no-new-privileges:true, and RAM-backed in-memory tmpfs mounts.

  • Unified Benchmark Dashboard: Terminal dashboard with JSON and Markdown artifact generation.


Benchmark Suite Catalog

CodeForgeX includes 6 diverse benchmark tasks spanning core software engineering modalities:

Task ID

Category

Difficulty

Problem Domain

Baseline Defect

Golden Score

bug_fix_001

bug_fix

Easy

E-Commerce Pricing Engine

Flat rate subtraction instead of % calculation; no bound checks

100.0 / 100.0

bug_fix_002

bug_fix

Medium

Concurrent LRU Cache with TTL

Expired nodes not purged on access; evicts MRU instead of LRU

98.0 / 100.0

feature_001

feature

Medium

Thread-Safe Token Bucket Limiter

Class raises NotImplementedError across all methods

98.0 / 100.0

refactor_001

refactor

Medium

Request Dispatcher to Strategy

Monolithic if/elif/else router; lacks BaseRequestHandler registry

98.0 / 100.0

perf_001

performance

Medium

Log Stream Deduplication ($O(N^2) \rightarrow O(N)$)

$O(N \times W)$ quadratic nested search takes > 1.5s and times out

100.0 / 100.0

algo_001

algorithm

Medium

Topological Build Dependency Sorter

Lacks topological sort and Tarjan/DFS cycle path detection

100.0 / 100.0


Quickstart Guide

1. Installation & Environment Setup

# Clone the repository
git clone https://github.com/kirubesh/CodeForgeX.git
cd CodeForgeX

# Install virtual environment and dependencies using uv or pip
pip install -e .

2. Run the Full Test Suite (91 Tests)

pytest -v

3. Run Benchmark Evaluations via CLI

# Run the entire benchmark suite in golden reference mode
python scripts/run_evaluation.py --all

# Run a specific task in autonomous agent mode (MCP stdio tool-calling loop)
python scripts/run_evaluation.py --task bug_fix_001 --mode agent-systematic

# Filter benchmarks by category or difficulty
python scripts/run_evaluation.py --category algorithm
python scripts/run_evaluation.py --difficulty medium

4. Containerized Execution with Docker

# Build the security-hardened container
docker build -t codeforge-x:latest .

# Run full evaluation across all tasks inside Docker
docker run --rm codeforge-x:latest --evaluate-all

# Or run using Docker Compose with cgroups limits and tmpfs in-memory sandboxes
docker compose up codeforge-eval

Technical Documentation & Interview Defenses


License

MIT License. See LICENSE for details.

Available Tools

8 tools
apply_patchA

Atomically apply a unified diff patch to repository files.

Args: patch: The unified diff content (e.g., standard 'diff --git' or '--- / +++' format). file_path: Optional relative target path if targeting a single file.

Returns: JSON string with success status, list of changed files, and status message.

Inputs: patch (required), file_path. Returns: result

get_git_diffA

Retrieve the deterministic Git diff of changes made in the repository.

Args: path: Optional relative file or directory path to scope the diff. cached: If True, inspects staged changes (git diff --cached) (default: False).

Returns: JSON string containing diff string, has_changes boolean, and changed_files list.

Inputs: path, cached. Returns: result

get_repository_statusA

Inspect the current Git repository status (modified, staged, untracked files).

Returns: JSON string with branch, clean flag, and lists of modified/staged/untracked files.

Inputs: no named parameters. Returns: result

get_test_outputA

Retrieve test execution output and logs from a previous test run.

Args: run_id: Specific test run identifier (empty string defaults to most recent run). full: If True, returns full untruncated stdout and stderr (default: False).

Returns: JSON string containing logs, exit code, duration, and pass/fail counts.

Inputs: full, run_id. Returns: result

list_filesA

List files and directories in the repository.

Args: directory: Relative subfolder inside the repository (empty string for root). recursive: Whether to list recursively through child directories (default: True). max_depth: Maximum directory recursion depth (default: 10).

Returns: JSON string containing total_entries and a structured list of files with sizes.

Inputs: directory, max_depth, recursive. Returns: result

read_fileA

Read text content from a file inside the repository with line windowing.

Args: path: Relative path to the file inside the repository. start_line: 1-indexed starting line number (default: 1). end_line: 1-indexed ending line number (default: None, reads up to 1000 lines).

Returns: JSON string containing path, line numbers, content, and truncation status.

Inputs: path (required), end_line, start_line. Returns: result

run_testsA

Execute automated pytest tests within the repository sandbox.

Args: test_target: Optional relative test file or test node (e.g. 'tests/test_math.py::test_add'). timeout_seconds: Maximum time allowed before terminating process (default: 30s).

Returns: JSON string with exit code, passed/failed counts, duration, and output summary.

Inputs: test_target, timeout_seconds. Returns: result

search_codeA

Search for literal text or regular expressions across repository files.

Args: query: The substring or regex to search for. path: Optional relative directory or file to constrain search scope. is_regex: Whether query is a regular expression (default: False). case_sensitive: Whether match should be case-sensitive (default: False). max_results: Maximum matching lines to return (default: 50).

Returns: JSON string with matched lines, line numbers, and file paths.

Inputs: query (required), path, is_regex, max_results, +1 more. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a distinct concern: file listing, status inspection, content reading, search, test execution, test output retrieval, patching, and diff viewing. The only related pair is run_tests/get_test_output, but their roles are clearly sequential rather than interchangeable.

    Naming Consistency4/5

    Most tools follow a clear verb_noun pattern like list_files, read_file, search_code, run_tests, and apply_patch. The get_* variants are slightly different in style but still predictable and consistent with common Git-related naming.

    Tool Count5/5

    Eight tools is a well-scoped size for a repository coding assistant. Each tool covers a necessary operation without redundancy or bloat, and the set is small enough for an agent to navigate easily.

    Completeness4/5

    The toolset covers the core inspect-modify-test loop well: reading, searching, patching, diffing, and running tests. Missing commit/branch management tools are a minor gap for full repository lifecycle coverage, but agents can still complete most coding workflows.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers