Skip to main content

Overview

The GitHub MCP Agent is a powerful Streamlit application that enables natural language interaction with GitHub repositories. Built with Agno framework and the Model Context Protocol, it allows you to query repository information, issues, pull requests, and code quality trends without writing GitHub API calls.

Features

  • 🔍 Natural Language Queries - Ask questions in plain English
  • 📊 Multiple Query Types - Info, Issues, PRs, Repository Activity, Custom
  • 🎯 Interactive UI - Streamlit-based web interface
  • 🔐 Secure Authentication - GitHub token management
  • 📈 Data Visualization - Results in organized tables with markdown
  • 🔗 Direct Links - Quick access to GitHub resources

Architecture

Prerequisites

  • Python 3.10 or higher
  • Docker installed and running
  • GitHub Personal Access Token
  • Nebius API Key

Installation

1

Clone Repository

git clone https://github.com/Arindam200/awesome-ai-apps.git
cd mcp_ai_agents/github_mcp_agent
2

Install Dependencies

Using pip:
pip install -r requirements.txt
Or using uv (recommended):
uv sync
3

Configure Environment

Create a .env file:
NEBIUS_API_KEY=your_nebius_api_key
GITHUB_PERSONAL_ACCESS_TOKEN=your_github_token

Usage

Start the Application

streamlit run main.py
Open your browser at http://localhost:8501

Configure Authentication

  1. In the sidebar:
    • Enter your Nebius API key
    • Enter your GitHub Personal Access Token
    • Click “Save Configuration”

Query Repository

  1. Enter repository name (format: owner/repo)
  2. Select query type:
    • Info: Repository details from README.md
    • Issues: Recent issues analysis
    • Pull Requests: Recent merged PRs
    • Repository Activity: Code quality trends
    • Custom: Ask anything specific
  3. Enter or modify the query
  4. Click “Run Query”

MCP Integration

GitHub MCP Server Setup

The agent uses GitHub’s official MCP server via Docker:
import os
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(
    command="docker",
    args=[
        "run",
        "-i",
        "--rm",
        "-e",
        "GITHUB_PERSONAL_ACCESS_TOKEN",
        "ghcr.io/github/github-mcp-server"
    ],
    env={
        "GITHUB_PERSONAL_ACCESS_TOKEN": os.getenv("GITHUB_PERSONAL_ACCESS_TOKEN")
    }
)

Connecting to MCP Server

from agno.tools.mcp import MCPTools

# Create client session
async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        # Initialize MCP toolkit
        mcp_tools = MCPTools(session=session)
        await mcp_tools.initialize()
        
        # Now use mcp_tools with agent

Agent Configuration

from agno.agent import Agent
from agno.models.nebius import Nebius
from textwrap import dedent

agent = Agent(
    tools=[mcp_tools],
    instructions=dedent("""\
        You are a GitHub assistant. Help users explore repositories and their activity.
        - Provide organized, concise insights about the repository
        - For Info, Provide Details from the Repository's README.md file
        - For Issues, Provide Details from the Issues section
        - For Pull Requests, Provide Details from the PRs section
        - Focus on facts and data from the GitHub API
        - Use markdown formatting for better readability
        - Present numerical data in tables when appropriate
        - Include links to relevant GitHub pages
        - IMPORTANT: When using MCP tools that require numeric parameters,
          ensure they are passed as float64 values
        - For date-related parameters (like 'since' in list_issues),
          always provide a valid ISO 8601 formatted date string
    """),
    markdown=True,
    show_tool_calls=True,
    model=Nebius(
        id="Qwen/Qwen3-30B-A3B",
        api_key=api_key
    )
)

Running the Agent

async def run_github_agent(message):
    """Run agent with proper error handling."""
    try:
        async with stdio_client(server_params) as (read, write):
            async with ClientSession(read, write) as session:
                mcp_tools = MCPTools(session=session)
                await mcp_tools.initialize()
                
                agent = Agent(
                    tools=[mcp_tools],
                    instructions="...",
                    model=Nebius(id="Qwen/Qwen3-30B-A3B", api_key=api_key)
                )
                
                response = await agent.arun(message)
                return response.content
    except Exception as e:
        return f"Error: {str(e)}"

Query Examples

Tell me about Arindam200/awesome-ai-apps
Returns: Comprehensive repository information from README.md

Streamlit UI Components

Page Configuration

import streamlit as st
import base64

st.set_page_config(
    page_title="GitHub MCP Agent", 
    page_icon="🦑", 
    layout="wide"
)

# Load and display logo
try:
    with open("./assets/agno.png", "rb") as agno_file:
        agno_base64 = base64.b64encode(agno_file.read()).decode()
except FileNotFoundError:
    st.error("Logo file not found.")
    agno_base64 = ""
with st.sidebar:
    st.image("./assets/Nebius.png", width=150)
    
    st.header("🔑 Authentication")
    api_key = st.text_input(
        "Enter your Nebius API key", 
        type="password"
    )
    
    if api_key:
        os.environ["NEBIUS_API_KEY"] = api_key
    
    github_token = st.text_input(
        "GitHub Token", 
        type="password",
        help="Create token at github.com/settings/tokens"
    )
    
    if github_token:
        os.environ["GITHUB_PERSONAL_ACCESS_TOKEN"] = github_token

Query Input Interface

col1, col2 = st.columns([3, 1])

with col1:
    repo = st.text_input(
        "Repository", 
        value="Arindam200/awesome-ai-apps",
        help="Format: owner/repo"
    )

with col2:
    query_type = st.selectbox(
        "Query Type", 
        ["Info", "Issues", "Pull Requests", "Repository Activity", "Custom"]
    )

query = st.text_area(
    "Your Query", 
    value=query_template,
    placeholder="What would you like to know about this repository?"
)

Security Best Practices

Never commit API keys or GitHub tokens to version control. Always use environment variables or .env files.
  • Session Storage: API keys stored in Streamlit session state
  • Docker Isolation: GitHub token passed securely to container
  • No Persistence: Sensitive data not stored permanently
  • Environment Variables: Credentials managed through .env

Troubleshooting

If you get errors on pull, you may have an expired token:
docker logout ghcr.io
docker pull ghcr.io/github/github-mcp-server
Ensure Docker is running:
docker ps
Check GitHub token permissions (requires repo scope)
GitHub API rate limits:
  • Authenticated: 5,000 requests/hour
  • Unauthenticated: 60 requests/hour
Always use a personal access token for higher limits.
The agent instructions include handling for numeric parameters:
# Convert string numbers to float64
# Use ISO 8601 format for dates
# Never pass nil/null for required parameters

Advanced Usage

Custom MCP Tools

Extend the agent with custom MCP tools:
from agno.tools.mcp import MCPTools

# Add custom tool implementation
class CustomGitHubTools(MCPTools):
    async def get_custom_metrics(self, repo: str):
        # Custom implementation
        pass

Multi-Agent Pattern

Combine multiple specialized agents:
from agno.agent import Agent

# Specialized agents
code_analyzer = Agent(name="Code Analyzer", ...)
issue_tracker = Agent(name="Issue Tracker", ...)
pr_reviewer = Agent(name="PR Reviewer", ...)

# Orchestrator agent
orchestrator = Agent(
    name="GitHub Orchestrator",
    agents=[code_analyzer, issue_tracker, pr_reviewer],
    ...
)

Source Code

View the complete source at: ~/workspace/source/mcp_ai_agents/github_mcp_agent/

Agno Framework

Learn more about Agno

GitHub MCP Server

Official GitHub MCP server

Doc-MCP

Documentation RAG with MCP

Database MCP Agent

Database management with Agno

Build docs developers (and LLMs) love