Guide

Agents

The same 71 tools over MCP, Pi, OMP, the CLI and the AI SDK, what they hold back, and how tokens and hosts stay out of a model's hands.

71 tools, five surfaces

Every tool is written once, in src/tools.ts. @agntn/tools hands that one definition to the MCP server, both extensions, the forges CLI and the AI SDK. Same schema, same description, same error text. Fix it once, fixed everywhere.

GroupTools
repositoriesforges_repos_list, forges_repos_get, forges_repos_contents, forges_repos_tree, forges_repos_tags, forges_repos_labels
contribution templatesforges_contribution_templates_list, forges_contribution_templates_get
codeforges_code_search
CI and commitsforges_ci_runs_list, forges_ci_jobs_list, forges_ci_jobs_log, forges_commits_search, forges_commits_list, forges_commits_compare, forges_commits_get, forges_commits_checks, forges_commits_patch
releasesforges_releases_list, forges_releases_get, forges_releases_create, forges_releases_update
issuesforges_issues_list, forges_issues_search, forges_issues_search_global, forges_issues_get, forges_issues_comments, forges_issues_comments_get, forges_issues_reactions, forges_issues_events, forges_issues_comments_create, forges_issues_comments_update, forges_issues_comments_delete, forges_issues_fields, forges_issues_create, forges_issues_update, forges_issues_transfer, forges_issues_sub_issues, forges_issues_sub_issues_add, forges_issues_sub_issues_remove
pull requestsforges_pull_requests_list, forges_pull_requests_search, forges_pull_requests_search_global, forges_pull_requests_get, forges_pull_requests_files, forges_pull_requests_checks, forges_pull_requests_reviews, forges_pull_requests_reviews_get, forges_pull_requests_reviews_dismiss, forges_pull_requests_comments, forges_pull_requests_comments_get, forges_pull_requests_reactions, forges_pull_requests_events, forges_pull_requests_comments_create, forges_pull_requests_comments_update, forges_pull_requests_comments_delete, forges_pull_requests_create, forges_pull_requests_update, forges_pull_requests_merge
users and authforges_users_get, forges_users_authenticated, forges_auth_reload
review threadsforges_threads_list, forges_threads_get, forges_threads_reply, forges_threads_comments_update, forges_threads_comments_delete, forges_threads_resolve, forges_threads_unresolve
local inspectionforges_local_inspect
local Gitforges_local_merge_verify

Two shortcuts, because models kept tripping over the long form. platform defaults to github. And repo takes the slug everyone writes anyway, { "repo": "agntn/keys" }. An owner next to it may repeat the slug's owner. Naming someone else fails. No guessing which one you meant.

Cloudflare Artifacts? Git without the forge around it. So only the five Git reads take platform: "artifacts", and the rest don't even list it. The Artifacts page has the details.

Several issues, pull requests or threads in one call

Three issues used to mean the same tool three times in a row, like a broken record. Need several at once? Pass a list. One bad id doesn't sink the other nine.

forges_issues_get and forges_pull_requests_get take a number or a list of up to 10. forges_threads_get, forges_threads_resolve and forges_threads_unresolve take a thread id or a list. Lists are for MCP, Pi, OMP and the AI SDK. The CLI keeps --number 391 and --thread-id to one item per command.

json
{ "repo": "agntn/forges", "number": 398, "threadId": ["PRRT_a", "PRRT_b", "PRRT_c"] }

One value keeps the old answer. A list comes back in the same order. Each item has its key and a result or an error. Successful resolves stay resolved, so retry only the failed ids. An empty list or one above 10 is refused before any request.

Reads run in parallel. Resolves run one thread at a time, as GitHub asks of mutations. In a local run, three separate calls took about 1.5 s. One list took about 0.5 s, with nearly the same answer size.

Bodies share the single call's 200 000-character ceiling. Ten issues get 20 000 characters each by default. A bigger maxChars than that share? Refused. Continuations with offset and bodyHash take one number.

Checks that finish

Is CI green yet? Ask forges_pull_requests_checks again and again, and it says "still running" again and again. Pass waitSeconds instead, up to 300. The call comes back once every check concludes, or when the budget runs out. A timeout isn't an error. You still get the page, plus a wait field with what's left.

Every page of checks counts. A green first page with page two still building isn't done.

Right after a push there's a catch. For a moment the pull request can still point at the old head, and that head's checks are all done. Green, settled and wrong. So pass the SHA you just pushed as headSha. Until the pull request catches up, you get no rows, a staleHead naming the commit it still shows, and the wait keeps going.

forges_commits_checks lists checks for a SHA, branch or tag. Like forges_pull_requests_checks, it accepts waitSeconds up to 300. The shell loop calling gh api every 20 seconds can finally go. Some checks arrive after the merge party: a Workers Builds deploy, a release, a publish. They run on the merge commit, outside the pull request's checks.

A branch or tag is pinned to its commit when the call starts, so a push in the meantime doesn't move it. The result's sha names that commit, and wait matches the pull request version. An empty list never settles it, though. A commit can't say when it was pushed, so a deploy that starts late still gets caught.

Let CI ring the bell

Why make an agent babysit a clock? A 15 minute run used to mean a string of blocking calls. Up to 300 seconds each with waitSeconds. Then "call again". CI can ring its own bell.

In Pi and OMP, call forges_checks_watch and keep working. It answers at once with how many checks still run. Already done? Then the answer says so, and no watch starts.

A pull request takes number and an optional headSha. A commit, branch or tag takes ref. Never both. Pushed again? Watch the pull request again with the new SHA. The new watch replaces the old one.

json
{ "repo": "agntn/forges", "number": 463, "headSha": "<the SHA you just pushed>" }

Once every check concludes, one message lands in the session. An idle agent gets a new turn. A busy one finishes first. Checks that didn't pass come with their id and URL. forges_ci_jobs_log reads the log. The watch gives up after minutes, 60 by default and 360 at most. Then it names what still ran.

The session has to stay open: interactive or RPC. A reload or resume starts the open watches again. Quitting stops them quietly. pi -p ends with its answer, so it refuses the call and points at waitSeconds. It's the one tool outside the shared set. MCP, the CLI and the AI SDK don't get it.

Review bots that edit in place

Green CI, and the bot? A review bot rarely says "done" out loud. Codex edits one sticky comment: Running when its round starts, Completed when it ends. PR Lens does the same under its own marker.

So forges_pull_requests_comments waits too. marker keeps the comments whose body has that text. since keeps the ones created or edited after it. Both read every page in one call, so there's no cursor.

json
{
  "repo": "agntn/forges",
  "number": 339,
  "marker": "codex-pull-request-review-summary",
  "since": "2026-10-26T20:50:00Z",
  "waitSeconds": 110
}

With since at your push, the first edit after it settles the call. Usually that's Running. Call again without since, and it waits for the next edit after the call starts. That one says Completed. Two calls, not 85 lines of gh in a shell loop.

You get only the changed comments. Plus wait: settled, waitedMs, polls. Bodies are still cut in a list. PR Lens puts its verdict at the bottom, so read that one whole with forges_pull_requests_comments_get.

forges_pull_requests_reactions plays by the same rules. author stands in for marker. Its wait also settles when a reaction from the first read goes away. Codex's eyes does that when a round ends with findings. You'll find it in wait.removed.

A quiet bot isn't an error. The budget runs out, settled is false and the list is empty. The note says to call again.

Changed your mind halfway? Hit Esc in Pi or OMP, or cancel the call from your MCP client. The wait ends right there. The next poll never goes out. No more five minutes of forges refreshing CI for an agent that's long gone.

Every other read lets go just as fast. A silent host can't hold your session for 30 seconds. The request runs out in the background. Nobody reads the reply.

Local Git

Two tools read a checkout instead of a forge. No token, no fetch, no writes.

forges_local_inspect gives status, tracked files and the last few commit messages in one call. Point paths at *AGENTS.md and it finds every instruction file. A big repository comes back in pages.

forges_local_merge_verify asks something narrower. Is the merge commit on the target? Did these paths land exactly as they were on the PR head? Fetch the target first, then pass the head, the merge commit and the paths.

A match isn't a license to clean up, though. Paths you didn't list weren't checked, and refs move. Look at the live PR before deleting anything. The library has both as inspectLocal and verifyLocalMerge in @agntn/forges/local.

MCP

shell
forges mcp
claude mcp add forges --scope user -- npx -y @agntn/forges mcp

Or in a client's config:

json
{
  "mcpServers": {
    "forges": { "command": "npx", "args": ["-y", "@agntn/forges", "mcp"] }
  }
}

That's stdio. A host with its own transport takes createMcpServer() from @agntn/forges/mcp.

Issue and pull request lists leave bodies out and name the tool that reads one in full. A page of busy issues with every body inside would push the conversation that asked for it out of the window. Two small calls beat one huge one.

Searches also leave bodies out unless bodyChars asks for the start of each one. Reading the starts of someone's last eight PR bodies takes one search call, not a small pilgrimage through eight more. Comments, reviews and threads keep their bodies, cut to twelve lines and 4,000 characters each, so a heavily reviewed PR wants a small perPage.

Reads, writes and whose account

Reads go through the usual token chain. Nothing found? They go out anonymous. That anonymous provider never gets reused for a write, not even by accident. Artifacts has no guest mode, so no token there means a clear error.

Twenty-two tools write to the host, and their MCP annotations say so. Run a create or a reply twice and you get two of them.

Updates, comment edits and deletes, the merge, a review dismissal and an issue transfer are marked destructive. Pi asks before each comment edit or delete, which is worth the interruption. A merge doesn't come back, and neither does a deleted comment.

Esc doesn't cut a write short, though. The forge may already have it. So forges waits for the answer. Guessing is how a model posts the same comment twice.

Before a model writes anything, forges_users_authenticated tells you whose account it'll use. Two GitHub logins in gh? A write can pick one with account. forges then asks /user whose token that really is and refuses on a mismatch. That check is the point. A GH_TOKEN in the environment still wins the lookup, and a reply signed by the wrong person looks exactly like a success. GitLab, Gitea and Artifacts don't take account.

The credential stays pinned until forges_auth_reload swaps it. Even an expired one. So a rejected token comes back with where it came from and which login to redo. Then the reload. A bare 401 tells a model nothing.

Hosts stay local

A self hosted forge comes from FORGES_GITHUB_BASE_URL, FORGES_GITLAB_BASE_URL, FORGES_GITEA_BASE_URL, FORGES_BITBUCKET_BASE_URL, FORGES_GITEE_BASE_URL, FORGES_AZURE_DEVOPS_BASE_URL, FORGES_GITCAFE_BASE_URL, FORGES_PUSHIN_BASE_URL or FORGES_TANGLED_BASE_URL in the agent's environment. FORGES_ARTIFACTS_BASE_URL does the same for the Cloudflare API. Never a tool argument, so a model can't aim a call somewhere else. Errors name the status and, on a rate limit, when to retry. Never the endpoint.

A failed call is a sentence for the model. The session survives.

Pi and OMP

shell
pi install npm:@agntn/forges

Both extensions draw calls and results in the terminal. A repository row, pull requests with their states, a thread with its comments.

Pi stops before eight writes: creating, editing or merging a pull request, dismissing a review, editing or moving an issue, creating or editing a release. It shows what goes out and waits for a yes. No UI to ask? No write. OMP puts its own approval in front of every write.

Which repo is this, anyway? Both extensions answer before the agent asks. Each run gets the checkout's forge remotes in its system prompt, origin and upstream first, with the platform, owner and repo the tools take.

Plain local Git, about 7 ms, no network, no token. Credentials in a remote URL stay out. Without it the model said unknown. With it, GitHub, agntn, forges.

What does a Pi codemode script get back? An object now, not a string wearing JSON. Call forges_issues_get and read r.result.title directly. A list of numbers gives an array, each item with its number and a result or error. No more JSON.parse on every call, thankfully. The model still reads the same text.

AI SDK

One import gives your model all 71 tools, no wrappers to write.

shell
pnpm add @agntn/forges ai @ai-sdk/anthropic
ts
import { anthropic } from "@ai-sdk/anthropic";
import { forgesAiTools } from "@agntn/forges/ai";
import { generateText, isStepCount } from "ai";

const { text } = await generateText({
  model: anthropic("claude-sonnet-5-5"),
  tools: forgesAiTools,
  stopWhen: isStepCount(5),
  prompt: "What's still open on agntn/forges?",
});

Reads run without asking. The twenty-two host writes stop at a tool approval request. So does forges_auth_reload, which swaps the pinned credential. Why ask? A bare generateText loop has nobody there to approve a merge. The model's finger can hover, but it can't press.

Your loop, your call. A toolApproval you pass wins over that default:

ts
await generateText({
  model: anthropic("claude-sonnet-5-5"),
  tools: forgesAiTools,
  toolApproval: { forges_issues_comments_create: "approved" },
  prompt: "Say thanks on agntn/forges#346.",
});

It also takes "denied", "user-approval" or a function. Keys are the MCP names, and the model reads the same text an MCP client gets. ai is an optional peer, any 7.x.

What comes back

Normalized objects, not prose. Want to check a model's summary against the source? The Explorer shows the same objects for any public repository.

Issue bodies, comments and review threads come from whoever has an account. Data to report, not instructions to follow. An agent that reads ignore previous instructions in an issue has learned something about the issue. Nothing about what to do next.