Skip to content

Conversation

Neilblaze
Copy link
Member

@Neilblaze Neilblaze commented Sep 26, 2025

Description

This Pull Request (PR) delivers the OpenDigger MCP Server with complete integration of OpenDigger metrics and full MCP support, enabling seamless interaction between LLM clients and OpenDigger’s analytics ecosystem.

The implementation focuses on robustness, real-time streaming, and developer usability. It introduces a caching layer, supports Server-Sent Events (SSE), and provides advanced prompts for improved output quality. Documentation, setup guides, and performance validation have been added to ensure smooth adoption across different MCP clients (Cursor, VS Code, Claude, MCP Inspector, etc.).

💡 This work is done as a part of OSPP '25.

image

✅ Expected Deliverables (Completed)

  • 🟢 Enhanced MCP Server with most (if not all) OpenDigger metrics support.
  • 🟢 Server-Sent Events (SSE) support for real-time data streaming
  • 🟢 Advanced Prompts for robust and context-aware outputs
  • 🟢 Complete Documentation (API reference, tutorials, usage examples)

🔄 Future Work (TBD)

Once the check is complete by @birdflyi, we can start working on setting up a test suite (if required), and for the same, it needs some discussion with @frank-zsy. Besides, the same shall also allow us to perform a marketplace publication on major MCP platforms (specifically on npm and modelcontextprotocol/servers), but that has to be done via creating a PR from the main repository by the code-owner i.e. @frank-zsy once this PR gets merged with main.


High-Level System Architecture

flowchart LR
    LLMClient["LLM Client"] --> MCPServer["OpenDigger<br>MCP Server"]
    MCPServer <--> OpenDigger["OpenDigger<br>(API Layer)"]
    MCPServer --> CacheLayer["Cache Layer<br>(In-Memory)"]
Loading

🟦 Data Flow Diagram (Cache)

flowchart TD
    subgraph Client
        LLMClient["👨‍💻 LLM Client<br>(e.g., Cursor IDE)"]
    end

    subgraph "OpenDigger MCP Server"
        direction LR
        
        subgraph "1. Request Handling"
            Validate["✅ Validate Input"]
            CheckCache{"💾 Check Cache?"}
        end

        subgraph "2. Data Fetching"
            FetchAPI["📡 Fetch from API"]
            UpdateCache["📝 Update Cache"]
        end
        
        subgraph "3. Response Generation"
            ProcessData["⚙️ Process & Format Data"]
            SendResponse["📤 Stream (SSE) or<br>Return Complete Response"]
        end
        
        Validate --> CheckCache
        CheckCache -- Cache Miss --> FetchAPI
        FetchAPI --> UpdateCache
        UpdateCache --> ProcessData
        CheckCache -- Cache Hit --> ProcessData
        ProcessData --> SendResponse
    end

    subgraph "External Services"
        OpenDigger["🌐 OpenDigger API"]
        Cache["💾 In-Memory Cache"]
    end

    LLMClient -- "1. MCP Request" --> Validate
    FetchAPI <--> OpenDigger
    CheckCache <--> Cache
    UpdateCache --> Cache
    SendResponse -- "4. Formatted Data" --> LLMClient

    class LLMClient client;
    class OpenDigger,Cache external;
    class Validate,CheckCache,FetchAPI,UpdateCache,ProcessData,SendResponse server;
Loading

📌 Resolves #1698
🦄 Tested on local, build running successfully!

cc: @birdflyi, @frank-zsy


Before submitting the PR, please take the following into consideration

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. If you don't have an issue, please create one.
  • The description should clearly illustrate what problems it solves.
  • Ensure that the commit messages follow our guidelines.
  • Resolve merge conflicts (if any).

"clean": "rm -rf dist",
"prepare": "npm run build",
"sse:test": "SSE_PORT=3001 npm start",
"debug": "NODE_OPTIONS='--inspect' npm start"

Choose a reason for hiding this comment

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

npm start NODE_OPTIONS='--inspect'

Copy link
Member Author

@Neilblaze Neilblaze Sep 27, 2025

Choose a reason for hiding this comment

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

Similar to this, but here,

"sse:test": "SSE_PORT=3001 npm start"

This actually sets the environment variable SSE_PORT=3001 first, and then runs npm start (sequentially) with that variable available in the environment, which is exactly what we intend to do.

Choose a reason for hiding this comment

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

You're right. The solution is the same as above.

Choose a reason for hiding this comment

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

The command here needs to be replaced with "NODE_OPTIONS='--inspect' npm start".

Copy link
Member Author

Choose a reason for hiding this comment

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

@birdflyi Fixed via 2997217 🚀

case 'repo_health_analysis': {
const { platform, owner, repo, timeframe = 'auto' } = args || {};

// TODO: We need to finetune the `VISUALIZATION REQUIREMENTS` section further based on feedback | cc: @birdflyi, @frank-zsy

Choose a reason for hiding this comment

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

Agree~

Copy link
Member Author

Choose a reason for hiding this comment

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

@birdflyi I was playing around with Ant Design's Charts or something simple as Chart.js, but for this iteration, I thought it might be overkill 😅. So I added a note that, if things go well, I can probably spend some time later integrating it directly into our MCP server.

To be honest, I actually tried it out a couple of days ago. The only catch is that I need to craft an efficient prompt (which is quite challenging, since I'll have to do some benchmarking stuff as output data varies with input queries) that, given the data (basically JSON structured in a specific way), can render the diagrams, and ideally save them as PNG or JPEG. 🤔

Choose a reason for hiding this comment

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

That's nice. It could be opened as another issue or repository. Visualization is always important for user experience. Both generic chart.exe packages and SVG rendering tailored to specific needs are highly recommended~

Copy link

@birdflyi birdflyi left a comment

Choose a reason for hiding this comment

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

Very well implemented and supported by batch metrics, cache, and platform deployment. As an initial version, it should be sufficient.
My main concern is the license change. If there are no conflicts, changing to Apache 2.0 would also be good, as it is consistent with open finger.

@Neilblaze
Copy link
Member Author

@birdflyi It's now ready to be merged! 🚀

Copy link

@birdflyi birdflyi left a comment

Choose a reason for hiding this comment

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

All clear! These functions have been tested on the Cursor~

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.

[Feature] Develop full MCP server for OpenDigger
2 participants