github_search
Search GitHub repositories and commits, cross-reference with conversation history, and validate evidence through multiple search modes.
Instructions
Search GitHub repos, commits, and cross-reference with conversations.
Args:
query: Search query (used for code semantic search or as conversation_id for validate mode)
project: Project/repo name (used for timeline and conversations modes)
mode: Search mode:
- "timeline" (default): Project creation date, commits, activity windows
- "conversations": Find conversations mentioning a project
- "code": Semantic search across commits AND conversations
- "validate": Check conversation date validity via GitHub evidence.
Pass conversation_id as query.
limit: Max results (default 10)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | ||
| project | No | ||
| mode | No | timeline | |
| limit | No |
Implementation Reference
- brain_mcp/server/tools_github.py:25-127 (handler)The implementation of the github_search tool handler, which supports timeline, conversation, code, and validation modes.
def github_search( query: str = "", project: str = None, mode: str = "timeline", limit: int = 10, ) -> str: """ Search GitHub repos, commits, and cross-reference with conversations. Args: query: Search query (used for code semantic search or as conversation_id for validate mode) project: Project/repo name (used for timeline and conversations modes) mode: Search mode: - "timeline" (default): Project creation date, commits, activity windows - "conversations": Find conversations mentioning a project - "code": Semantic search across commits AND conversations - "validate": Check conversation date validity via GitHub evidence. Pass conversation_id as query. limit: Max results (default 10) """ cfg = get_config() if mode == "conversations": return _conversation_project_context(project or query, limit) elif mode == "code": return _code_to_conversation(query, limit) elif mode == "validate": return _validate_date_with_github(query) # Default: timeline mode project_name = project or query if not cfg.github_repos_parquet.exists(): return "GitHub data not imported. Add GitHub data and run ingest first." con = get_github_db() if not con: return "GitHub database not available." pattern = f"%{project_name.lower()}%" try: repos = con.execute(""" SELECT repo_name, created_at, pushed_at, description, language, is_private, stars, url FROM github_repos WHERE LOWER(repo_name) LIKE ? ORDER BY created_at DESC LIMIT 5 """, [pattern]).fetchall() except Exception as e: return f"Error querying GitHub repos: {e}" if not repos: return f"No GitHub project found matching '{project_name}'" output = [f"## GitHub Project Timeline: '{project_name}'\n"] for repo in repos: name, created, pushed, desc, lang, private, stars, url = repo output.append(f"### {name}") output.append(f"**Created**: {str(created)[:10]}") output.append(f"**Last pushed**: {str(pushed)[:10] if pushed else 'N/A'}") output.append(f"**Language**: {lang or 'N/A'}") output.append(f"**Private**: {'Yes' if private else 'No'}") output.append(f"**Stars**: {stars}") if desc: output.append(f"**Description**: {desc[:100]}") output.append(f"**URL**: {url}\n") # Get commits for this repo if cfg.github_commits_parquet.exists(): try: commits = con.execute(""" SELECT timestamp, message, author FROM github_commits WHERE repo_name = ? ORDER BY timestamp DESC LIMIT 10 """, [name]).fetchall() if commits: output.append("**Recent Commits**:") for ts, msg, _ in commits: msg_preview = msg.split('\n')[0][:60] output.append(f" - [{str(ts)[:10]}] {msg_preview}...") monthly = con.execute(""" SELECT strftime(timestamp, '%Y-%m') as month, COUNT(*) as count FROM github_commits WHERE repo_name = ? GROUP BY 1 ORDER BY 1 """, [name]).fetchall() if monthly: output.append("\n**Activity by Month**:") for month, count in monthly[-6:]: bar = "█" * min(count, 20) output.append(f" {month}: {bar} ({count})") except Exception: pass return "\n".join(output)