Docs
GitHub

Tools

Give the model GitHub operations it can call, from reading an issue to merging a pull request.

Beginner5 min read

Overview

A GitHub tool is one GitHub API operation an AI model can call, such as reading an issue or merging a pull request. The SDK has 97 of them: 49 read and 48 write. Each tool describes every input it takes, so the model knows what to pass, and returns only the fields the model needs instead of GitHub's whole response.

GET /issues/1347113 fields0 tokens
{
"id": 1,
"node_id": "MDU6SXNzdWUx",
"number": 1347,
"title": "Found a bug",
}
getIssue0 fields0 tokens
{
"number": 1347,
"title": "Found a bug",
"body": "I'm having a problem with this. Saving a file with a space in its name returns a 500.",
"state": "open",
"url": "https://github.com/octocat/Hello-World/issues/1347",
"author": "octocat",
"assignees": [
"hubot"
],
"labels": [
"bug",
"needs-triage"
],
"comments": 3,
"createdAt": "2026-10-28T09:14:02Z",
"updatedAt": "2026-11-02T16:40:51Z",
"closedAt": null
}
The model only reads the right side. GitHub's REST response for an issue carries over a hundred fields, and getIssue returns the few the model needs.

You create the tools in one call and hand them to the model like any other AI SDK tools. Most agents only need the tools for one job, which a preset picks for you. Every write tool asks for approval before it runs.

Configure

Create the tools with createGithubTools() and pass them wherever the AI SDK takes tools: generateText, streamText or a ToolLoopAgent.

summarize.ts
import { createGithubTools } from '@github-tools/sdk'
import { generateText } from 'ai'

const { text } = await generateText({
  model: 'anthropic/claude-opus-5.5',
  tools: createGithubTools({ preset: 'issue-triage' }),
  prompt: 'Summarize issue 42 on vercel/ai.',
})

The tool catalog lists all 97 tools.

Options

Every option is optional.

OptionDefaultWhat it does
tokenGITHUB_TOKENA token string, or an async function that returns one. See Auth
presetAll 97 toolsOne preset or an array of presets. See Presets
requireApprovaltrueWhich writes ask first: true, false, 'auto' or per tool. See Approval
evaluationJev, maxRisk: 1, minIntent: 0.6The decision model behind 'auto'. See Approval
contextNoneA default owner, repo, pull request, issue or ref. See Context
overridesNoneA per-tool description, title or needsApproval. See Overrides
author, committerThe token's ownerWho the commits are from. See Commits
coAuthorsNoneCo-authored-by trailers on every commit. See Commits
guardrailsBlock credentialsThe repositories and branches any call may act on, whoever approves it. See Guardrails
dryRunfalseShadow mode: reads run, writes report what they would have done. See Shadow mode

createGithubAgent() takes the same options plus model, instructions and additionalInstructions, and also accepts preset: 'auto'. The AI SDK integration covers it, and the API reference has every signature.

Call a tool from your code

Each tool has an execute function, so a script or a test can call it without a model. The result is the shaped object the model would read:

issue.ts
import { createGithubTools } from '@github-tools/sdk'

const tools = createGithubTools({ preset: 'repo-explorer' })

const issue = await tools.getIssue.execute!(
  { owner: 'vercel', repo: 'ai', issueNumber: 42 },
  { toolCallId: 'example', messages: [] },
)
// { number, title, body, state, url, author, assignees, labels, comments, createdAt, updatedAt, closedAt, rateLimit }

Pick single tools

When you want a hand-picked set instead of a preset, import the tools one by one. Each tool is exported as a factory. Read factories take a token, and write factories also take { needsApproval }, which defaults to true:

review-tools.ts
import { addPullRequestComment, getPullRequest, listPullRequestFiles } from '@github-tools/sdk'

const token = process.env.GITHUB_TOKEN!

const tools = {
  getPullRequest: getPullRequest(token),
  listPullRequestFiles: listPullRequestFiles(token),
  addPullRequestComment: addPullRequestComment(token, { needsApproval: true }),
}

A factory returns the bare tool, without the extras createGithubTools() adds. The FAQ lists what you give up.

Overrides

Overrides change how one tool is presented to the model or approved, without changing what it does. Use them to reword a description for your domain, or to stop one write from asking. Key them by tool name:

overrides.ts
import { createGithubTools } from '@github-tools/sdk'

const tools = createGithubTools({
  overrides: {
    listIssues: { description: 'List bugs for the current sprint' },
    deleteGist: { needsApproval: false },
  },
})
PropertyWhat it changes
descriptionWhat the model reads to decide when to call the tool
titleThe human-readable name
needsApprovalA boolean or a function of the input. Wins over requireApproval
strictStrict input generation, where the provider supports it
providerOptionsProvider-specific tool settings
toModelOutputHow the result is turned into what the model reads
onInputStart, onInputDelta, onInputAvailableCallbacks while the model streams the input

The type is exported as ToolOverrides.

Page through long lists

List tools return one page at a time, so a repository with thousands of issues doesn't arrive in one result:

{ items, hasMore, page, perPage, nextPage? }

When hasMore is true, the model calls the tool again with page: nextPage. Passing maxPages (up to 20) fetches that many pages in one call and returns them together.

ToolsDefault page sizeLargest perPage
Most lists30100
Search tools1030
listDiscussions, listNotifications20

Output size

Results are trimmed by default so one call can't fill the model's context. Most trims have an input that asks for more:

  • Long issue, pull request, discussion and release bodies are cut to about 500 characters. Pass detail: 'full' for the whole text.
  • Diff patches are left out of listPullRequestFiles, getCommit and compareCommits. Pass includePatch: true, and filenames on listPullRequestFiles, for the diffs you need.
  • getFileContent takes startLine, endLine or maxLines. The model sees at most 20,000 characters of a file, 4,000 of each patch and 200 entries of a tree.
  • getWorkflowJobLogs returns the last 200 lines without timestamps. Raise maxLines up to 2,000.

Context tools go further by answering a whole question, such as "why did CI fail", in one call.

Check the rate limit

GitHub limits how many requests a token can make. Every result that is an object carries a rateLimit field from the last GitHub response: remaining, limit, reset, and resource and retryAfter when GitHub sends them. resource is core, search or graphql.

createGithubTools() removes rateLimit from what the model reads, and your code still gets it, for example in onStepFinish or a UI tool part:

rate-limit.ts
import type { GithubRateLimit } from '@github-tools/sdk'

const remaining = (result as { rateLimit?: GithubRateLimit }).rateLimit?.remaining

When the limit runs out, calls fail with RATE_LIMITED, and the message includes the reset time.

Send fewer tool definitions

The model reads every tool definition on every request, whether it calls the tool or not. A preset lists only the tools one job needs, and preset: 'auto' lets a decision model pick them per conversation.

FAQ