Skip to content

Latest commit

 

History

History
255 lines (209 loc) · 5.38 KB

File metadata and controls

255 lines (209 loc) · 5.38 KB

GitHub Integration for Learning MCP

Overview

GitHub tools are now integrated directly into Learning MCP! No separate service needed.

Key Feature: GitHub searches are automatically scoped to your profile's configured username, making queries simpler and more intuitive.

New Tools Available

1. search_github_repos

Search GitHub repositories by keywords (auto-scoped to your profile's GitHub user).

Simple Example (Recommended):

{
  "tool": "search_github_repos",
  "arguments": {
    "query": "RAG",
    "profile": "avi-cohen",
    "limit": 10
  }
}

This automatically searches "RAG user:aviciot" because avi-cohen profile has github.username: aviciot

Override with explicit user:

{
  "query": "RAG user:microsoft",
  "profile": "avi-cohen"
}

Searches Microsoft's repos instead

Response:

{
  "query": "RAG user:aviciot",
  "profile": "avi-cohen",
  "count": 3,
  "repositories": [
    {
      "name": "learning-mcp",
      "description": "RAG system with MCP integration",
      "url": "https://github.com/aviciot/learning-mcp",
      "stars": 15,
      "language": "Python",
      "topics": ["rag", "mcp", "qdrant"]
    }
  ]
}

2. get_github_file

Read any file from a GitHub repository.

Example:

{
  "tool": "get_github_file",
  "arguments": {
    "owner": "aviciot",
    "repo": "learning-mcp",
    "path": "README.md"
  }
}

Response:

{
  "name": "README.md",
  "content": "# Learning MCP\n\n...",
  "size": 5420,
  "url": "https://github.com/aviciot/learning-mcp/blob/main/README.md"
}

3. list_user_github_repos

List all repositories for the profile's GitHub user.

Simple Example (Recommended):

{
  "tool": "list_user_github_repos",
  "arguments": {
    "profile": "avi-cohen",
    "limit": 30
  }
}

Automatically lists repos for aviciot (from profile config)

Response:

{
  "username": "aviciot",
  "profile": "avi-cohen",
  "count": 15,
  "repositories": [...]
}

Setup

1. Configure GitHub Username in Profile

Edit config/learning.yaml:

avi-cohen:
  github:
    username: aviciot  # Your GitHub username
  
  documents:
    - type: json
      path: /app/data/persons/avi_profile.json
  
  # ... rest of profile config

2. Get GitHub Personal Access Token

  1. Go to: https://github.com/settings/tokens
  2. Click "Generate new token (classic)"
  3. Select scopes:
    • public_repo (for public repos)
    • repo (for private repos - optional)
  4. Copy the token: ghp_xxxxxxxxxxxxx

3. Add to .env File

# Add this line to your .env file
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_your_token_here

4. Restart Docker

docker compose restart learning-mcp

Testing

# Test GitHub search
curl -X POST http://localhost:8013/mcp `
  -H "Content-Type: application/json" `
  -d '{
    "method": "tools/call",
    "params": {
      "name": "search_github_repos",
      "arguments": {
        "query": "RAG user:aviciot",
        "limit": 5
      }
    }
  }'

Usage in Your Omni API

import httpx

async def search_user_content(query: str):
    """Search both documents AND GitHub repos"""
    
    async with httpx.AsyncClient() as client:
        # Search your documents
        docs = await client.post(
            "http://localhost:8013/mcp",
            json={
                "method": "tools/call",
                "params": {
                    "name": "search_docs",
                    "arguments": {
                        "query": query,
                        "profile": "avi-cohen",
                        "top_k": 5
                    }
                }
            }
        )
        
        # Search GitHub repos
        repos = await client.post(
            "http://localhost:8013/mcp",
            json={
                "method": "tools/call",
                "params": {
                    "name": "search_github_repos",
                    "arguments": {
                        "query": f"{query} user:aviciot",
                        "limit": 5
                    }
                }
            }
        )
        
        # Combine results
        return {
            "documents": docs.json(),
            "repositories": repos.json()
        }

Benefits

Single service - No separate GitHub MCP needed
Same endpoint - All tools at http://localhost:8013/mcp
Simple config - Just add GitHub token to .env
Fast - Direct GitHub API calls, no intermediate service
Integrated - Use alongside your existing search_docs and plan_api_call tools

Rate Limits

  • With token: 5,000 requests/hour
  • Without token: 60 requests/hour (not recommended)

Always provide a token for production use!

Examples

Find RAG Projects

Query: "Show me RAG projects"
→ Calls: search_github_repos("RAG user:aviciot")
→ Returns: learning-mcp, other-rag-project, etc.

Get README

Query: "What's in the learning-mcp README?"
→ Calls: get_github_file("aviciot", "learning-mcp", "README.md")
→ Returns: Full README content

List All Repos

Query: "List all my repositories"
→ Calls: list_user_github_repos("aviciot")
→ Returns: All your repos sorted by update date

Next Steps

  1. Add GitHub token to .env
  2. Restart Docker
  3. Test the tools
  4. Integrate into your Omni API!

🚀 Now you have ONE MCP server with everything!