adk agent integration using github tool
In Google ADK integration there is a tool call "github code" that allow us to do quite a bit of things with github if you provide it work your github token.
So we will do this integration and then test it out by asking it to list branches. I tried with PR but not successful.
Here is the code and the docs can be found here:-
https://google.github.io/adk-docs/integrations/github/#available-tools
import datetime
from zoneinfo import ZoneInfo
from google.adk.agents import Agent
from google.adk.apps import App
from google.adk.models import Gemini
from google.genai import types
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPServerParams
import os
import google.auth
_, project_id = google.auth.default()
os.environ["GOOGLE_CLOUD_PROJECT"] = "project-00e3e1b1-5433-464c-b5e"
os.environ["GOOGLE_CLOUD_LOCATION"] = "global"
os.environ["GOOGLE_GENAI_USE_VERTEXAI"] = "True"
GITHUB_TOKEN = "YOUR-GITHUB-TOKEN"
github_toolset = McpToolset(
connection_params=StreamableHTTPServerParams(
url="https://api.githubcopilot.com/mcp/",
headers={
"Authorization": f"Bearer {GITHUB_TOKEN}",
"X-MCP-Toolsets": "pull_requests,repos",
"X-MCP-Readonly": "false"
},
),
)
root_agent = Agent(
name="code_agent_github_capabilities",
model=Gemini(
model="gemini-2.5-flash-lite",
retry_options=types.HttpRetryOptions(attempts=3),
),
instruction="You are a helpful AI assistant with access to GitHub information with expertise in software development. You are meticulous in review code and able to assist in raising pull request and obtaining information on repositories, commits, and issues. You have the ability to reach code in the repo and provide summary of the code such as what it does, what language is it written on. You are equip with tools that allow you to obtain information on GitHub repositories, commits, issues, and pull requests. You can also review code and provide feedback on it.",
tools=[github_toolset],
)
app = App(
root_agent=root_agent,
name="code_agent",
)
And then you can bootstrap everything using this code here.
import logging
import os
from typing import Any
import vertexai
from dotenv import load_dotenv
from google.adk.artifacts import GcsArtifactService, InMemoryArtifactService
from google.cloud import logging as google_cloud_logging
from vertexai.agent_engines.templates.adk import AdkApp
from code_agent.agent import app as adk_app
from agent_skills_tutorial.app_utils.telemetry import setup_telemetry
from agent_skills_tutorial.app_utils.typing import Feedback
# Load environment variables from .env file at runtime
load_dotenv()
class AgentEngineApp(AdkApp):
def set_up(self) -> None:
"""Initialize the agent engine app with logging and telemetry."""
vertexai.init()
setup_telemetry()
super().set_up()
logging.basicConfig(level=logging.INFO)
logging_client = google_cloud_logging.Client()
self.logger = logging_client.logger(__name__)
if gemini_location:
os.environ["GOOGLE_CLOUD_LOCATION"] = gemini_location
def register_feedback(self, feedback: dict[str, Any]) -> None:
"""Collect and log feedback."""
feedback_obj = Feedback.model_validate(feedback)
self.logger.log_struct(feedback_obj.model_dump(), severity="INFO")
def register_operations(self) -> dict[str, list[str]]:
"""Registers the operations of the Agent."""
operations = super().register_operations()
operations[""] = operations.get("", []) + ["register_feedback"]
return operations
gemini_location = os.environ.get("GOOGLE_CLOUD_LOCATION")
logs_bucket_name = os.environ.get("LOGS_BUCKET_NAME")
agent_engine = AgentEngineApp(
app=adk_app,
artifact_service_builder=lambda: (
GcsArtifactService(bucket_name=logs_bucket_name)
if logs_bucket_name
else InMemoryArtifactService()
),
)
Here are a sample of the integrations
And in the event tab, you can see "list_branches" is called to accomplished this.
Comments