Cover image
Try Now
2025-04-14

使用MCP自动化GitHub任务的HAYSTACK代理

3 years

Works with Finder

0

Github Watches

0

Github Forks

0

Github Stars

Haystack MCP Agent for GitHub Issue Automation

Project Description

This project demonstrates how to use an agent to automate routine GitHub repository maintenance tasks. The agent is built with the NLP framework Haystack and leverages GitHub's MCP Server to scan repository files for common spelling mistakes and automatically create an GitHub issue to track and resolve these errors. The project highlights the integration of AI-driven tools into developer workflows, streamlining quality assurance and project management processes.

The agent is powered by the Model Context Protocol (MCP), an open standard specifically designed to streamline how large language models (LLMs) and AI agents interact with external tools, data sources, and APIs. This standard enables greater interoperability, scalability, and maintainability for AI-driven applications, making it much easier for developers to build agents that can perform complex, context-aware tasks across different platforms and environments.

The agent itself utilizes OpenAI's GPT-4o, a state-of-the-art multimodal language model capable of advanced text analysis and reasoning. GPT-4o enables the agent to accurately identify spelling issues and generate actionable issue reports, enhancing the quality assurance process.

Motivation

This project was initiated as part of the "Spring into Haystack" coding challenge. The motivation is to showcase how modern AI agents, using open standards like MCP, can automate and enhance software development workflows. By enabling an agent to identify and report spelling errors in code repositories, developers can maintain higher code quality with less manual effort—demonstrating a practical, real-world use case for LLM-powered automation.

This project serves as a showcase for leveraging MCP and intelligent NLP agents to automate repository maintenance workflows on GitHub. In practical terms, the approach demonstrated here could be expanded to automate a variety of other development tasks, such as code review, dependency monitoring, documentation generation, or integration testing. By connecting additional tools and services through MCP, teams can build more sophisticated agents that proactively manage project health, streamline collaboration, and reduce manual effort across the entire software development lifecycle.

Useful Links

Expected Outcomes

  • The script uses the OpenAI API to scan the README.md file in the forked repo for common typos.
  • If typos are found, it automatically creates a GitHub issue in your fork with details about the errors and how to fix them.

Shell Script

  • The script will either:
    1. Create an issue in your repo if typos are detected.
    2. Do nothing if no typos are found.
  • Check the Issues tab of your forked repo to see results.

GH Issue

Setup Instructions

To replicate this project and run the Haystack MCP Agent for GitHub Issue Automation on your own fork of the "Spring into Haystack" project, follow these steps:

1. Fork the Repository

  • Navigate to deepset-ai/spring-into-haystack.
  • Click Fork (top-right corner) to create a copy in your GitHub account.
  • Do not rename the forked repository—the script expects the original repo name.

2. Create a GitHub Personal Access Token (PAT)

  • Go to GitHub Settings → Developer Settings → Personal Access Tokens (Fine-grained).

  • Create a new PAT with:

    • Repository access: Select your forked repo (your-username/spring-into-haystack).
    • Permissions:
      • Repository permissions → Contents: Read and Write
      • Repository permissions → Issues: Read and Write
      • All other permissions: No access.
  • Save the token securely — you’ll add it to your environment later.

3. Set Up Python Virtual Environment

  • Check your current Python version:

    python --version
    

    Ensure the output is at least Python 3.9.x. If you see a lower version, you need to install a newer one.

  • Create a virtual environment .venv with Python:

    python -m venv .venv         # Create virtual environment
    source .venv/bin/activate    # macOS/Linux
    .venv\Scripts\activate       # Windows
    
  • Install the required packages defined in the requirements.txt file:

    pip install -r requirements.txt  # Install packages
    

4. Configure Environment Variables

  • Create a .env file in the root directory:

    GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here
    OPENAI_API_KEY=your_openai_key_here
    

Never commit this file to GitHub — add .env to your .gitignore.

5. Modify the Python Script

  • Open github-agent.py in a code editor (e.g., VS Code).
  • Locate the owner variable (e.g., owner = "d-kleine").
  • Replace d-kleine with your GitHub username.
  • Do not change repo or path variables unless you’ve modified the repo/file name.

6. Install Docker

The GitHub MCP Agent requires the GitHub MCP Server to be running as a Docker container. If you do not have Docker installed, install it.

  • Verify your Docker installation:

    docker --version
    
  • Pull and run the GitHub MCP Server Docker image:

    docker pull ghcr.io/github/github-mcp-server
    

7. Run the Typo Detection Agent

  • Ensure your virtual environment is active:

    source .venv/bin/activate    # macOS/Linux
    .venv\Scripts\activate       # Windows
    
  • Execute the script:

    python github-agent.py
    

相关推荐

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • sigoden
  • 使用普通的bash/javascript/python函数轻松创建LLM工具和代理。

  • hkr04
  • 轻巧的C ++ MCP(模型上下文协议)SDK

  • rulego
  • ⛓️Rulego是一种轻巧,高性能,嵌入式,下一代组件编排规则引擎框架。

  • RockChinQ
  • 😎简单易用、🧩丰富生态 -大模型原生即时通信机器人平台| 适配QQ / 微信(企业微信、个人微信) /飞书 /钉钉 / discord / telegram / slack等平台| 支持chatgpt,deepseek,dify,claude,基于LLM的即时消息机器人平台,支持Discord,Telegram,微信,Lark,Dingtalk,QQ,Slack

  • dmayboroda
  • 带有可配置容器的本地对话抹布

  • paulwing
  • 使用MCP服务创建的测试存储库

    Reviews

    3.7 (6)
    Avatar
    user_jNCf1D6j
    2025-04-24

    As a dedicated user of mcp_github_agent, I can confidently say it's an indispensable tool for managing GitHub projects. Created by d-kleine, this agent seamlessly integrates with GitHub, making repository management and workflow automation a breeze. The user interface is intuitive, and the efficiency it brings to my development process is unparalleled. Highly recommended for any developer looking to streamline their GitHub tasks!

    Avatar
    user_xJEbkkm9
    2025-04-24

    The mcp_github_agent created by d-kleine is an incredible tool for integrating MCP applications with GitHub seamlessly. As a developer, I found it to be extremely efficient and user-friendly. It has significantly improved my workflow by automating various tasks and providing a smooth experience. Highly recommend it to anyone looking to streamline their GitHub operations!

    Avatar
    user_hF8X2Pif
    2025-04-24

    As a dedicated user of the mcp_github_agent developed by d-kleine, I am thoroughly impressed. This tool has seamlessly integrated into my workflow, enhancing my productivity with GitHub tasks. It's well-designed, user-friendly, and has significantly optimized my project management. Highly recommend it to those who rely on GitHub for their development processes!

    Avatar
    user_MgMvwNO4
    2025-04-24

    As an avid user of mcp_github_agent, I am genuinely impressed with its seamless integration and efficiency. Developed by the talented d-kleine, this tool streamlines my workflow by automating repetitive tasks on GitHub. Easy to install and intuitive to use, it has become an indispensable part of my daily operations. Highly recommended for developers looking to optimize their GitHub interactions!

    Avatar
    user_8vHQyocb
    2025-04-24

    I have been using the mcp_github_agent created by d-kleine and it has significantly streamlined my GitHub management. The tool is highly efficient and has been a game-changer for keeping track of various repositories. The user-friendly interface and reliable performance make it an essential tool for any developer. Highly recommended!

    Avatar
    user_0JcEuAng
    2025-04-24

    As a devoted user of the mcp_github_agent, I must say this tool is incredibly efficient. Created by d-kleine, it seamlessly integrates with GitHub, saving me a lot of time on project management. The setup is straightforward, and the welcome information is very helpful for newcomers. Highly recommended for developers!