An AI-powered DevOps assistant that interacts with GitHub using natural language.
Built using:
- LangChain + LangGraph
- Google Gemini API
- Model Context Protocol (MCP)
- Custom GitHub tools
- 🧠 Supports natural language prompts (English)
- 📦 Create public/private repositories
- 🌿 Create branches
- 📄 Create/update files (README, etc.)
- 🔍 List repositories, branches, commits
- 🐛 Create issues & PRs
- 💬 Comment on issues
- 🗑️ Delete repositories (custom tool with safety confirmation)
- 🔁 Retry & fallback logic
- 🔐 Safe execution for destructive actions
Control GitHub like this:
"Create a branch named feat/aiagent-test in your repository (replace <reponame> with your repo name)"
Example:
Create a branch named feat/aiagent-test in ai-devops-demo
The agent will:
- Understand your intent
- Select the correct GitHub tool
- Execute it automatically
No GitHub API knowledge required.
User Input
↓
AI Agent (LangGraph ReAct)
↓
Gemini (LLM - reasoning & decision making)
↓
Tools Layer
├── MCP GitHub Server (@modelcontextprotocol/server-github)
└── Custom Tools (delete_repository)
↓
GitHub API
Follow these steps exactly — after this, the project will run without issues.
python --versionIf not installed → https://python.org
Download: https://nodejs.org
node -v
npm -vgit --version- https://aistudio.google.com → Create API key
Scopes required:
- repo
- workflow
- read:org
Example:
iam-pavanpachuru
git clone https://github.com/iam-pavanpachuru/github-ai-agent
cd github-ai-agentpython -m venv venvActivate:
Linux / Mac
source venv/bin/activateWindows
venv\\Scripts\\activatepip install --upgrade pip
pip install -r requirements.txtmkdir -p ~/.npm-global
npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrcnpm install -g @modelcontextprotocol/server-githubnpx @modelcontextprotocol/server-githubExpected:
GitHub MCP Server running on stdio
Create .env file:
GOOGLE_API_KEY=your_gemini_api_key
GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token
GITHUB_USERNAME=your_github_username # e.g., iam-pavanpachuruProtect it:
echo ".env" >> .gitignore- Python reads
.env - Passes token to MCP internally
- No manual setup required
export GITHUB_PERSONAL_ACCESS_TOKEN=your_token
npx @modelcontextprotocol/server-githubpython github_ai_agent.pyType your task and press ENTER twice.
Before running real tasks, verify everything is working correctly.
python test_mcp_client.pyExpected:
- MCP connects successfully
- GitHub authentication works
python inspect_mcp_tools.pyExpected:
- List of available GitHub tools
- Confirms MCP server is working
Run the agent and try:
List all repositories for my GitHub account
If this works → your setup is fully correct ✅
Here are some example prompts demonstrating how the agent interacts with GitHub using MCP tools:
Create a new private repository called ai-devops-demo
If empty, create a README.md with content "# AI DevOps"
Create a README.md file in ai-devops-demo with content "# AI DevOps Project"
Create a new branch called feat/auth in repository ai-devops-demo
Search for repositories related to "devops automation"
Create an issue in ai-devops-demo with title "Bug: Fix login error" and description "Login fails on invalid credentials"
Create a pull request from branch feat/auth to main in ai-devops-demo with title "Add authentication feature"
Add a comment to issue #1 in ai-devops-demo saying "Working on this issue"
List all commits from the main branch in ai-devops-demo
Delete the repository ai-devops-demo
The MCP GitHub server does not support repository deletion.
So we added a custom tool:
def delete_github_repo(repo_name: str):This directly calls GitHub REST API:
DELETE /repos/{owner}/{repo}
.
├── github_ai_agent.py # Main AI agent
├── inspect_mcp_tools.py # Utility to inspect MCP tools
├── test_mcp_client.py # MCP connection testing
├── .env # Environment variables
├── .gitignore
└── venv/
Main application:
- Handles user input
- Connects to MCP server
- Loads tools
- Runs AI agent
- Executes GitHub operations
Purpose: Tool discovery & debugging
Run:
python inspect_mcp_tools.pyHelps you:
- See all available MCP tools
- Understand system capabilities
- Debug why certain prompts fail
Purpose: Testing & validation
Used for:
- Verifying MCP connection
- Testing GitHub authentication
- Running quick experiments
- Gemini free tier has strict rate limits (429 errors)
- Some MCP tools may be missing (e.g., delete repo)
- Model availability may change (503 errors)
- LLMs don’t execute actions — tools do
- MCP acts as a bridge between AI and real systems
- Safety checks are critical for destructive operations
- Prompt clarity improves tool usage
- Will be updated with more features and enhancements soon 🚀
Feel free to fork, improve, and share!
Give it a star ⭐ and share on LinkedIn 🚀
Pavan Kalyan Pachuru