Skip to content

feat: integrate Context7 MCP documentation search functionality in coder #1141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

Hoder-zyf
Copy link
Collaborator

@Hoder-zyf Hoder-zyf commented Jul 31, 2025

Description:

This PR introduces the Context7 MCP (Model Context Protocol) documentation search functionality to the RD-Agent project. The key improvements include comprehensive configuration management, intelligent caching mechanisms, and enhanced error handling capabilities. Below are the new feature modules and technical improvements:

New Feature Modules:

  1. Context7 MCP Integration (rdagent/components/mcp/)

    • context7.py: Core documentation search functionality with async querying and intelligent caching.
    • cache.py: SQLite-based cache management system, reusing RD-Agent's existing cache architecture.
    • util.py: Pydantic-based configuration management supporting environment variables and config files.
    • __init__.py: Module export interface.
  2. Pipeline Evaluation Integration (rdagent/components/coder/data_science/pipeline/eval.py)

    • Integrated Context7 documentation search into the PipelineSingleFeedback evaluation workflow.
    • Added enable_context7 switch and wfb.requires_documentation_search conditional logic.
    • Supports async querying and result appending to execution context.

Motivation and Context:

During the data science pipeline evaluation, the existing system lacked the ability to query relevant documentation when encountering complex technical errors. The Context7 MCP integration solves this problem by providing intelligent documentation search capabilities to aid in error diagnosis and solution finding, enhancing the system's autonomous problem-solving capabilities.

Types of changes:

  • Fix bugs
  • Add new feature
  • Update documentation

📚 Documentation preview 📚: https://RDAgent--1141.org.readthedocs.build/en/1141/

Hoder-zyf and others added 8 commits July 29, 2025 14:45
…age and mcp to be discussed; the extraction logic not done yet; the config load is ugly) init commit 2
- Refine context7.py prompt
- Handle/pause on timeout
- Optimize context7 logic
- Pass content downstream when enabled
- Add PyTorch Image Models (timm) search to index.ts
@Hoder-zyf Hoder-zyf changed the title feat: integrate Context7 MCP documentation search functionality in runner feat: integrate Context7 MCP documentation search functionality in coder Aug 1, 2025
@Hoder-zyf Hoder-zyf marked this pull request as ready for review August 1, 2025 15:28
- If the code execute successfully:
- Proceed to Step 2.
- Proceed to Step 2 and overlook the remaining steps in Step 1.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Step 2 and Step 1 is missing

from rdagent.oai.llm_conf import LLM_SETTINGS


class MCPCache:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not reuse SQliteLazyCache and enhance it?

@@ -0,0 +1,452 @@
"""Example usage of Context7 MCP integration."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not confuse the concept of mcp and A2A
I didn't see any mcp implementation here. I only see an Agent based on context7 mcp

I think we can reorgnize the files to make it more extentable and understandable in the future.

import time
from typing import Optional

from llama_index.core.agent.workflow import ReActAgent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you just want to build a Agent based on MCP
Why you prefer llama_index than pydantic-ai?
https://www.reddit.com/r/PydanticAI/comments/1jcx9ij/llamaindex_vs_pydantic_ai_understanding_the/

@@ -140,6 +140,10 @@ class DataScienceBasePropSetting(KaggleBasePropSetting):
"""Enable hypothesis critique and rewrite stages for improving hypothesis quality"""
enable_scale_check: bool = False

#### mcp in coder
enable_context7: bool = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would enable_api_doc_agent be a more understandable and general name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants