-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add GitHub Wizard Agent #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # GitHub Wizard Agent | ||
|
|
||
| The **GitHub Wizard** is a specialized agent designed to assist with GitHub-related tasks using the Model Context Protocol (MCP). | ||
|
|
||
| ## Features | ||
|
|
||
| - **GitHub Integration**: Connects to GitHub using the GitHub Copilot MCP server. | ||
| - **Task Assistance**: Helps answer questions and perform actions related to GitHub repositories, issues, and pull requests. | ||
|
|
||
| ## Configuration | ||
|
|
||
| To use this agent, you must provide a valid GitHub token. | ||
|
|
||
| 1. Obtain a GitHub Personal Access Token (PAT) with appropriate permissions. | ||
| 2. Set the `GITHUB_TOKEN` environment variable in your `.env` file or environment. | ||
|
|
||
| ```env | ||
| GITHUB_TOKEN=your_github_token_here | ||
| ``` | ||
|
|
||
| ## Tools | ||
|
|
||
| - **GitHub MCP Tools**: Automatically loaded if `GITHUB_TOKEN` is present. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import os | ||
| from google.adk.agents.llm_agent import Agent | ||
| from google.adk.models.lite_llm import LiteLlm | ||
|
|
||
| # Import tools | ||
| from .tools.github_mcp import github_mcp_tools | ||
|
|
||
| api_base_url = "https://openrouter.ai/api/v1" | ||
|
|
||
| root_agent = Agent( | ||
| model=LiteLlm( | ||
| model="openrouter/openai/gpt-oss-120b", | ||
| api_base=api_base_url, | ||
| api_key=os.getenv("OPENROUTER_API_KEY"), | ||
| ), | ||
| name="github_wizard", | ||
| description="A helpful assistant for GitHub related tasks.", | ||
| instruction=""" | ||
| Answer user questions to the best of your knowledge using the provided GitHub tools. | ||
| """, | ||
| # Give the agent tools to do its job | ||
| tools=github_mcp_tools, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import os | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from google.adk.tools.mcp_tool.mcp_toolset import McpToolset, StreamableHTTPConnectionParams | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _get_github_mcp_tools(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| github_token = os.getenv("GITHUB_TOKEN") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tools = [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if github_token: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tools = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| McpToolset( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| connection_params=StreamableHTTPConnectionParams( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| url="https://api.githubcopilot.com/mcp/", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headers={"Authorization": f"Bearer {github_token}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("Warning: GITHUB_TOKEN not found. GitHub MCP tools will not be available.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file can be improved in a few ways for better maintainability and adherence to best practices:
The suggested code applies these improvements.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| github_mcp_tools = _get_github_mcp_tools() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
api_base_urlis hardcoded. It's better to make this configurable via an environment variable, with the current value as a default. This improves flexibility for different environments (e.g., testing, staging) and aligns with howOPENROUTER_API_KEYis handled.