@circuitwall/github-langchain
v1.0.0
Published
LangChain tools for the GitHub REST API — direct REST calls, no MCP, no gh CLI, proxy-aware. Extracted from Jarela.
Maintainers
Readme
@circuitwall/github-langchain
LangChain tools for the GitHub REST API — direct REST calls, no MCP, no gh CLI, proxy-aware.
Extracted from Jarela. Works in any Node 20+ LangChain.js / LangGraph project. Inherits whatever HTTP proxy + CA bundle the host runtime configures, so it works on locked-down corp networks where the MCP install path is blocked.
Install
npm install @circuitwall/github-langchain @langchain/core zod@langchain/core and zod are peer dependencies — bring your own version.
Quick start
import {
setAuthResolver,
githubGetRepoTool,
githubSearchIssuesTool,
githubTools,
} from "@circuitwall/github-langchain";
// Option A: rely on env vars (GITHUB_TOKEN or GH_TOKEN). Nothing to do.
// Option B: plug in your own credential source (vault, UI form, …).
setAuthResolver(() => ({
token: process.env.MY_GITHUB_TOKEN ?? "",
}));
// Use individual tools …
const result = await githubGetRepoTool.invoke({
owner: "CircuitWall",
repo: "jarela",
});
// … or pass the whole array to a LangGraph agent.
const agent = await createReactAgent({ llm, tools: [...githubTools] });What's in the box
22 tools covering the GitHub REST API.
Issues
github_search_issues— full GitHub search syntax (issues + PRs)github_get_issuegithub_create_issuegithub_update_issue— title / body / labels / stategithub_add_commentgithub_list_issue_comments
Pull requests
github_list_pullsgithub_get_pull— full detail (mergeable, additions, reviews)github_create_pullgithub_update_pullgithub_merge_pull— execute capabilitygithub_request_reviewersgithub_create_review— APPROVE / REQUEST_CHANGES / COMMENTgithub_list_pull_files— with capped patch textgithub_list_pull_reviews
Repo content
github_get_repogithub_list_branchesgithub_get_file— capped UTF-8 read, binary-awaregithub_search_code
Capability groups
For tool-policy systems that need read / write / execute partitions:
import {
githubReadTools, // 11 read-only tools
githubWriteTools, // 7 mutating tools (issues + PRs)
githubExecuteTools, // 1 merge tool
} from "@circuitwall/github-langchain";github_merge_pull is in execute (not write) because merging a PR
triggers CI, deploys, and downstream automation — a different blast radius
than editing an issue title.
Low-level escape hatch
For endpoints not yet wrapped as tools:
import { githubFetch, resolveGithubAuthFromEnv } from "@circuitwall/github-langchain";
const auth = resolveGithubAuthFromEnv();
if (!("error" in auth)) {
const data = await githubFetch(auth, "/user");
}Pure helpers
Exported for reuse outside the LangChain tool wrappers:
truncate(text, cap)— pure-fn body capping ({text, truncated})decodeContentsBlob(content, encoding)— decode/contents/{path}blob, detect binary, return{binary, text?, size_bytes}
API notes
- Token scopes:
repocovers private + public repo content + issues + PRs;read:orgis needed for team-based reviewer requests. Fine-grained tokens must explicitly grant each resource. - Code search rate limits: GitHub's
/search/codeendpoint has stricter limits (10/min unauthenticated, 30/min authenticated) than the rest of the REST API. mergeable: null: On a freshly-pushed PR, GitHub computes mergeability asynchronously. The first call togithub_get_pullmay returnnull; call again after a few seconds.
License
Apache-2.0
