Skip to main content
The GitHub toolkit contains tools that enable an LLM agent to interact with a github repository. The tool is a wrapper for the PyGitHub library. For detailed documentation of all GithubToolkit features and configurations head to the API reference.

Setup

At a high-level, we will:
  1. Install the pygithub library
  2. Create a GitHub app
  3. Set your environmental variables
  4. Pass the tools to your agent with toolkit.get_tools()
To enable automated tracing of individual tools, set your LangSmith API key:

Installation

1. Install dependencies

This integration is implemented in langchain-community. We will also need the pygithub dependency:

2. Create a GitHub app

Follow the instructions here to create and register a GitHub app. Make sure your app has the following repository permissions:
  • Commit statuses (read only)
  • Contents (read and write)
  • Issues (read and write)
  • Metadata (read only)
  • Pull requests (read and write)
Once the app has been registered, you must give your app permission to access each of the repositories you whish it to act upon. Use the App settings on github.com here.

3. Set environment variables

Before initializing your agent, the following environment variables need to be set:
  • GITHUB_APP_ID- A six digit number found in your app’s general settings
  • GITHUB_APP_PRIVATE_KEY- The location of your app’s private key .pem file, or the full text of that file as a string.
  • GITHUB_REPOSITORY- The name of the GitHub repository you want your bot to act upon. Must follow the format {username}/{repo-name}. Make sure the app has been added to this repository first!
  • Optional: GITHUB_BRANCH- The branch where the bot will make its commits. Defaults to repo.default_branch.
  • Optional: GITHUB_BASE_BRANCH- The base branch of your repo upon which PRs will based from. Defaults to repo.default_branch.

Instantiation

Now we can instantiate our toolkit:

Tools

View available tools:
The purpose of these tools is as follows: Each of these steps will be explained in great detail below.
  1. Get Issues- fetches issues from the repository.
  2. Get Issue- fetches details about a specific issue.
  3. Comment on Issue- posts a comment on a specific issue.
  4. Create Pull Request- creates a pull request from the bot’s working branch to the base branch.
  5. Create File- creates a new file in the repository.
  6. Read File- reads a file from the repository.
  7. Update File- updates a file in the repository.
  8. Delete File- deletes a file from the repository.

Include release tools

By default, the toolkit does not include release-related tools. You can include them by setting include_release_tools=True when initializing the toolkit:
Settings include_release_tools=True will include the following tools:
  • Get Latest Release- fetches the latest release from the repository.
  • Get Releases- fetches the latest 5 releases from the repository.
  • Get Release- fetches a specific release from the repository by tag name, e.g. v1.0.0.

Use within an agent

We will need a LLM or chat model:
Initialize the agent with a subset of tools:
And issue it a query:

API reference

For detailed documentation of all GithubToolkit features and configurations head to the API reference.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.