RD-Agent icon indicating copy to clipboard operation
RD-Agent copied to clipboard

fix: add mcp components

Open Hoder-zyf opened this issue 4 months ago • 0 comments

Description

This PR integrates a new MCP (Model Context Protocol) Context7 capability and wires it into the coder/data-science pipeline so the agent can search relevant documentation when encountering implementation errors.

Key changes

  • Introduce a new rdagent.components.mcp package with a dedicated context7 module, including client, prompts, examples, and README, enabling MCP-based doc search.
  • Add/modify pipeline hooks to surface error context and enable doc retrieval, notably in rdagent/components/coder/data_science/pipeline/eval.py and its prompts.yaml.
  • Update rdagent/app/data_science/conf.py to make Context7 usage configurable; control via the CONTEXT7_ENABLED environment variable. Also adjusts the hypothesis critique toggle default.
  • Touch related evaluator logic under rdagent/components/coder/CoSTEER/evaluators.py to align with the pipeline changes.
  • Minor housekeeping edits in .devcontainer/devcontainer.json and .gitignore.

Why it matters

  • Adds an opt-in documentation search path that improves error diagnosis and remediation during coding runs, reducing manual context switching and speeding iteration.

Configuration

  • To enable Context7 MCP at runtime, set:
    • CONTEXT7_ENABLED=1 and MCP_ENABLED=True

Motivation and Context

Agent runs often fail due to missing APIs, library nuances, or environment quirks. Integrating an MCP-driven doc search lets the system proactively fetch relevant references based on the current error, guiding the next fix step. The added config flag ensures teams can roll this out gradually and A/B the impact.

Types of changes

  • [x] Add new feature
  • [ ] Fix bugs
  • [x] Update documentation

Hoder-zyf avatar Jul 31 '25 15:07 Hoder-zyf