MCP server for code search - chunhualiao/public-docs GitHub Wiki

To integrate DeepWiki's QA interface (which provides AI-powered question-answering, wiki structure reading, and content retrieval for indexed GitHub repositories like rose-compiler/rose) into your Cline workflow in VS Code for generating ROSE API code, leverage the official DeepWiki MCP server.

This is a free, remote MCP-compatible service that gives programmatic access to DeepWiki's capabilities without requiring authentication for public repos like ROSE. Cline supports MCP servers natively, allowing it to call DeepWiki tools (e.g., ask_question for code examples) during code generation tasks.

Step 1: Configure DeepWiki MCP in VS Code for Cline

Cline uses the Model Context Protocol (MCP) to connect to external tools. Add the DeepWiki MCP server to your configuration:

  1. Open VS Code and go to Settings (Ctrl+, or Cmd+, on macOS).
  2. Search for "Cline" or "MCP" in the settings search bar.
  3. In the Cline extension settings, locate the MCP configuration section (it may be under "Cline: MCP Servers" or similar—refer to Cline's docs at cline.bot if needed). Edit the JSON to include the DeepWiki server. Your MCP config should look like this (add it to ~/.vscode/mcp.json or the equivalent file if Cline uses a dedicated one):
    {
      "mcpServers": {
        "deepwiki": {
          "serverUrl": "https://mcp.deepwiki.com/sse"
        }
      }
    }
    
    • This uses the SSE (Server-Sent Events) endpoint for compatibility with Cline.
    • If you encounter issues, try the alternative Streamable HTTP endpoint: "serverUrl": "https://mcp.deepwiki.com/mcp".
    • Restart VS Code or reload the Cline extension for changes to take effect.

No installation is needed since it's a remote service. For private repos, you'd need a Devin AI account and API key (sign up at devin.ai), but ROSE is public, so this isn't required.

Step 2: Use DeepWiki in Your Cline Workflow for ROSE API Code Generation

Once configured, Cline can access DeepWiki tools like:

  • ask_question: Query the repo for AI-grounded answers (e.g., code examples using SageInterface or SageBuilder).
  • read_wiki_contents: Fetch detailed wiki-style documentation.
  • read_wiki_structure: Get an overview of topics in the repo's indexed wiki.

Incorporate this into your workflow:

  1. Prompt Cline Explicitly: When generating code, phrase prompts to instruct Cline to use DeepWiki first. For example:

    • "Use the deepwiki ask_question tool to find examples of SageInterface::buildFunctionCall in the rose-compiler/rose repo, then generate similar C++ code to call a function in an AST."
    • Cline will:
      • Plan the task (in Plan Mode).
      • Call the ask_question tool on DeepWiki with a query like: {"repo": "rose-compiler/rose", "question": "Provide code examples using SageInterface::buildFunctionCall"}.
      • Receive a context-grounded response (e.g., code snippets from the indexed repo).
      • Incorporate those examples to generate accurate ROSE API code, reducing hallucinations.
  2. Automate in Complex Tasks: For multi-step tasks, enable Cline's autonomous mode and include DeepWiki in the prompt:

    • "Generate ROSE code to build an SgIfStmt using SageBuilder. First, search the rose-compiler/rose repo via deepwiki for best practices and examples."
    • Cline may automatically chain tools: e.g., use read_wiki_structure to find relevant sections, then ask_question for specifics.
  3. Handle Responses and Iteration:

    • DeepWiki responses are AI-powered and context-based (using vector search on the repo's code/docs), often in markdown with code blocks.
    • If the response includes links or diagrams, Cline can browse them via its built-in browser tool if prompted.
    • Review/edit the generated code in VS Code—approve steps as Cline proposes them.

Example Workflow in Action

  • Prompt: "Create a ROSE transformer that inserts a printf using SageInterface. Query deepwiki for examples from rose-compiler/rose first."
  • Cline's Steps (approximate):
    1. Analyzes your codebase.
    2. Calls DeepWiki's ask_question: Gets snippets like:
      // Example from ROSE source: Inserting a statement
      SgPrintfStmt* printfStmt = SageBuilder::buildPrintfStmt("Hello, world!");
      SageInterface::insertStatement(beforeStmt, printfStmt, true);
      
    3. Generates full code incorporating the example.
  • This ensures generated code uses best practices from ROSE's own sources.

Tips and Limitations

  • Performance: DeepWiki is fast for public repos, but complex queries may take seconds. Limit to 1-2 tools per prompt for efficiency.
  • ROSE-Specific: Since https://deepwiki.com/rose-compiler/rose is indexed, queries will pull from the full repo (code, docs, diagrams). If not loading in browser, it's still accessible via MCP.
  • Alternatives if Needed: For local/offline use, set up the open-source DeepWiki (github.com/AsyncFuncAI/deepwiki-open) as a custom MCP server:
    • Clone and run it locally (Docker or manual Python/JS setup with API keys like OpenAI).
    • Configure in Cline: "deepwiki-local": { "command": "docker-compose", "args": ["up"] }.
    • But the remote MCP is simpler for your use case.
  • Troubleshooting: Check Cline logs for MCP errors. If integration fails, verify in Cline docs or test with a general MCP client.
  • Enhancements: Combine with Cline's existing tools (e.g., browser for ROSE docs, internal code search).

This setup makes DeepWiki a seamless part of your ROSE code generation, improving accuracy with real examples.