Github
GithubTools enables an Agent to access Github repositories and perform tasks such as listing open pull requests, issues and more.
Prerequisites
The following examples requires the PyGithub library and a Github access token which can be obtained from here.
1uv pip install -U PyGithub1export GITHUB_ACCESS_TOKEN=***Example
The following agent will search Google for the latest news about "Mistral AI":
1from kern.agent import Agent2from kern.tools.github import GithubTools34agent = Agent(5 instructions=[6 "Use your tools to answer questions about the repo: kern-agi/kern",7 "Do not create any issues or pull requests unless explicitly asked to do so",8 ],9 tools=[GithubTools()],10 )1112agent.print_response("List open pull requests", markdown=True)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
access_token | Optional[str] | None | GitHub access token for authentication. If not provided, will use GITHUB_ACCESS_TOKEN environment variable. |
base_url | Optional[str] | None | Optional base URL for GitHub Enterprise installations. |
Toolkit Functions
| Function | Description |
|---|---|
search_repositories | Searches Github repositories based on a query. |
list_repositories | Lists repositories for a given user or organization. |
get_repository | Gets details about a specific repository. |
list_pull_requests | Lists pull requests for a repository. |
get_pull_request | Gets details about a specific pull request. |
get_pull_request_changes | Gets the file changes in a pull request. |
create_issue | Creates a new issue in a repository. |
You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.
Developer Resources
- View Tools