A GitHub gent built using Google's Agent Development Kit (ADK) and OpenAPI Specification tools that provides a natural language interface to GitHub's REST API using Google Gemini 2.5 Pro
- Introduction
- Demo
- Architecture
- How OpenAPI Tools Work in ADK
- Implementation Guide
- Resources
- Usage Examples
- GitHub Repository
This project demonstrates how to build an GitHub agent using Google's Agent Development Kit (ADK) and OpenAPI integration. The agent leverages the GitHub REST API through an OpenAPI specification to perform various GitHub operations via natural language commands.
Agent Development Kit (ADK) supports a wide range of tool integrations for building agents, including Function tools, Built-in tools, Third party tools, Google Cloud Tools, MCP Tools, and OpenAPI tools with support for Authentication. This project focuses on how to integrate REST APIs using OpenAPI specification, eliminating the need to manually define individual function tools for each API endpoint.
- Google ADK — Provides the agent framework and infrastructure (Agent class)
- OpenAPI Tools — Transforms API specifications into executable tools
- OpenAPI Specification — GitHub's v3 API defined in JSON format
- Authentication Handler — Manages GitHub personal access tokens
- Gemini 2.5 Pro — Powers the language understanding & generation
- OpenAPIToolset — Dynamically generates API tools from the spec
- Query Input: User enters a natural language request (e.g., "show my repositories")
- Initial Processing:
- The query is routed to the GitHub agent
- ADK prepares the context including the API spec and auth token
- LLM Processing:
- Gemini 2.5 Pro interprets the user's intent
- The query is mapped to potential GitHub API operations
- Tool Discovery:
- OpenAPIToolset identifies relevant API endpoints
- Parameters are extracted or requested if missing
- API Execution:
- The selected GitHub API is called with proper authentication
- The operation executes against GitHub's servers
- Response Handling:
- API response is formatted for readability
- Results are presented back to the user
The OpenAPI Tools in ADK provide a powerful way to integrate REST APIs with your agent:
-
OpenAPIToolset: The primary class that handles parsing an OpenAPI specification and generating tools from it. You initialize it with your OpenAPI specification, and it takes care of turning API operations into callable tools. -
RestApiTool: Represents a single API operation (likeGET /repos/{owner}/{repo}orPOST /repos). TheOpenAPIToolsetcreates oneRestApiToolfor each operation defined in your spec.
The process follows these main steps:
-
Initialization & Parsing:
- You provide the GitHub API OpenAPI specification to
OpenAPIToolset(as JSON in our case) - The toolset parses the spec, resolving any internal references to understand the complete API structure
- You provide the GitHub API OpenAPI specification to
-
Operation Discovery:
- It identifies all valid API operations (GET, POST, PUT, DELETE) defined within the
pathssection
- It identifies all valid API operations (GET, POST, PUT, DELETE) defined within the
-
Tool Generation:
- For each discovered operation, a corresponding
RestApiToolis created - Tool names are derived from the
operationIdin the spec (converted to snake_case) - Tool descriptions come from the
summaryordescriptionfields to help the LLM understand - API details (method, path, parameters, request body schema) are stored internally
- For each discovered operation, a corresponding
-
Tool Functionality:
- Each tool dynamically creates a function schema based on the operation's parameters
- When called by the LLM, it constructs the correct HTTP request using the provided arguments
- It handles authentication and executes the API call to GitHub
- Returns the API response back to the agent
-
Authentication:
- The GitHub token is configured during toolset initialization
- Authentication is automatically applied to all generated tools
This section provides a step-by-step guide to setting up and using the GitHub agent.
- Python 3.11+ installed
- Google Gemini Generative AI access via API key
- GitHub account and personal access token
- GitHub OpenAPI Spec: GitHub REST API Description
github-agent/agent.py: Main agent implementationgithub-agent/api.github.com.fixed.json: GitHub API OpenAPI specification
- Interact with GitHub's REST API using natural language
- Perform GitHub operations without knowing the specific API endpoints
- Authenticated access to GitHub repositories and resources
- AI-powered interface using Gemini 2.5 Pro
- Python 3.11 or higher
- A GitHub personal access token
-
Clone this repository:
git clone https://github.com/arjunprabhulal/adk-github-agent.git cd adk-github-agent -
Set up a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install google-adk
-
Obtain a GitHub API token:
- Go to GitHub → Settings → Developer settings → Personal access tokens
- Generate a new token with appropriate permissions
- Save the token securely for use in your application
-
Set your GitHub token as an environment variable:
export GITHUB_TOKEN=your_github_token_here -
Run the agent:
adk web
Run the agent from the github-agent directory:
adk web- "Create a new repository named 'my-project'"
- "List all my repositories"
- "Create an issue in repo X with title Y"
- "Add a comment to issue #123"
MIT
Built with Google Agent Development Kit (ADK)
The GitHub agent is built using the following key components from ADK:
-
Agent: The core building block of ADK that provides LLM integration, conversation management, tool orchestration, and prompt management.
-
OpenAPIToolset: Transforms API specifications into executable tools:
- Reads and interprets GitHub's OpenAPI specification JSON
- Automatically creates tools for each API endpoint (over 1000+ GitHub operations)
- Manages required/optional parameters for API calls
- Formats API responses for user consumption
-
Authentication: Uses the
token_to_scheme_credentialfunction to:- Convert raw GitHub token to proper authorization format
- Configure header-based API key authentication
- Create credentials object used by the OpenAPIToolset
- Format token with "token" prefix required by GitHub
Try interacting with the agent using natural language commands like:
- "List my repositories"
- "Create a new repository named adk-test-repo as private"
- "Create a new issue in repository X titled 'Feature request'"
- "What are the open pull requests in my repositories?"
You can access all the code used in this project at: github.com/arjunprabhulal/adk-github-agent


