Skip to main content
Version: Next · development

Local MCP tools

This page shows you how to give a trusted MCP client, such as a coding agent on your machine, read-only access to Golf. The golf CLI's local stdio server exposes 21 existing repository, organization and account reads, using the same generated API, permissions and session cleanup as the CLI. AI and Cloudflare are optional; no model credentials are needed.

Local server and remote MCP

This page covers the CLI's local stdio MCP server, which only reads. On a Cloudflare-native installation, coding agents can instead connect to the remote MCP endpoint /mcp with a scoped API token, including write tools for branches, commits, pull requests and comments (agentic mode AM-3, verified on the hosted demo with Claude Code). See Connect a coding agent.

Provider and source authority

This portable contract describes its linked source snapshot. For current deployment instructions, use current installation, authentication and native Cloudflare guides. Historical receipts do not verify later builds.

This guide describes the current alpha, including owner-issued read-only API credentials. The authoritative product implementation ledger records exact qualified revisions and remaining scope. This is a development contract, not a stable release.

Launch the server​

  1. Build the CLI in the product checkout and start MCP mode:

    make cli
    # GOLF_FORGE_TOKEN is supplied to this process by your secret manager.
    ./bin/golf mcp
  2. Configure your trusted MCP client to launch the absolute path to bin/golf with argument mcp.

  3. Supply exactly one of GOLF_API_TOKEN or GOLF_FORGE_TOKEN through the client's protected process environment. Golf API credentials delegate a browser session without sharing the upstream secret with the process.

Keep tokens out of config and history

Do not put a literal token in a committed client configuration or command history. No particular client's configuration format or installation workflow is qualified here.

Choose the Golf origin​

The Golf origin defaults to http://localhost:8080. Set GOLF_URL or launch ./bin/golf --url https://golf.example.com mcp to select another installation.

  • Remote Golf origins require HTTPS; HTTP is allowed only on loopback.
  • URLs with credentials, paths, query or fragment are rejected, and redirects are not followed.
  • A local stdio process can contact a remote HTTPS Golf installation without becoming a remote MCP server.

How credentials are handled​

Stdin and stdout belong to newline-delimited MCP JSON-RPC. Do not pipe the token to this command: both --token-stdin and --api-token-stdin are rejected in MCP mode.

The owner-configured origin and credential are captured at startup; tools cannot change either or select arbitrary RPC/shell commands. Restart the process after replacing its credential.

Credential modeBehavior per tool call
Golf API credential (GOLF_API_TOKEN)Delegates the issuing source session. Creates no temporary session or login/logout activity.
Forgejo PAT (GOLF_FORGE_TOKEN)Signs into Golf with the scoped PAT, performs one authorized domain read and logs out through an independent cleanup path. Cookies are not saved. A successful result is released only after logout succeeds; cleanup failure returns an error without the private result.

Discovery requires valid startup configuration but does not authenticate to Golf or list private resources.

Trust boundary

The process owner and MCP client are entrusted with the credential and returned data. This is not a sandbox for an untrusted local client, a managed Golf OAuth/device credential, or an MCP authorization-server flow. Browser OAuth is separate.

Scopes and side effects​

ReadRequired Forgejo PAT scopes
Repositories, branches, commits, source, diffs, PRs and native reviewsread:user, read:repository
Issuesread:user, read:repository, read:issue
Organizations, teams, members and assigned repositoriesread:user, read:organization; opening source separately needs read:repository
Own account activityread:user
Your creation recordread:user; current repository metadata also needs native repository access/scope

All tools together use read:user,read:repository,read:issue,read:organization. No administrator or write scope is required. A broader credential does not add hidden tools or override native permissions. Later collaborator or membership removal is checked on subsequent calls in the same MCP process.

These tools expose domain reads. API credential mode creates no temporary session or login/logout activity; PAT mode creates Golf login/logout activity, and some native Forgejo reads can schedule provider checks. Annotations therefore set readOnlyHint: false and idempotentHint: false, with destructiveHint: false and openWorldHint: true. These are client hints, not authorization. There are no create/merge/review/deployment, session-revocation or shell tools.

Protocol​

The adapter pins the official Go SDK v1.8.0. Supported protocol versions are exactly 2026-07-28 and 2025-11-25.

Protocol versionNegotiation
2026-07-28 (current)server/discover and per-request version metadata
2025-11-25initialize

The native proof exercises these distinct negotiation paths. See the dated versioning rules and stdio binding.

Tool catalogue​

tools/list returns this fixed catalogue. Every tool accepts an object with additionalProperties: false; unknown fields are rejected before authentication.

Repositories and source​

ToolRequired argumentsOptional arguments
golf_repo_listNonepage, limit
golf_repo_viewrepositoryNone
golf_repo_creationidempotency_keyNone
golf_repo_branchesrepositorypage, limit
golf_repo_commitsrepositoryref, page, limit
golf_repo_contentsrepositoryref, path
golf_commit_diffrepository, commit_idNone

Issues and pull requests​

ToolRequired argumentsOptional arguments
golf_issue_listrepositorystate, page, limit
golf_issue_viewrepository, numberNone
golf_issue_commentsrepository, numberpage, limit
golf_issue_operationidempotency_keyNone
golf_pr_listrepositorystate, page, limit
golf_pr_viewrepository, numberNone
golf_pr_reviewsrepository, numberpage, limit

Organizations and teams​

ToolRequired argumentsOptional arguments
golf_org_listNonepage, limit
golf_org_vieworganizationNone
golf_org_teamsorganizationpage, limit
golf_team_vieworganization, team_idNone
golf_team_membersorganization, team_idpage, limit
golf_team_reposorganization, team_idpage, limit

Account activity​

ToolRequired argumentsOptional arguments
golf_audit_listNonelimit, before_id, snapshot_id

Argument formats​

ArgumentFormat
repositoryOWNER/REPO
page, limitJSON integers. Defaults 1 and 20; bounds 1–10,000 and 1–100.
numberJSON integer from 1 through 2147483647
stateopen (default), closed or all
team_id, before_id, snapshot_idTeam and audit cursor IDs: canonical positive signed-64-bit decimal strings
idempotency_keyCanonical lowercase UUID v4 from a previous repository or issue/comment creation request
commit_idExact lowercase 40- or 64-character hexadecimal object ID; branch aliases and abbreviated hashes are invalid for diffs

String byte limits are 1,024 for ref, 4,096 for path and 2,048 for other fields, before the shared CLI/API validation.

Pagination​

Collections return one explicit page. Continue with data.page.nextPage, even on an empty provider-filtered page.

For activity, preserve the first data.snapshotId and pass data.nextBeforeId as before_id with that same snapshot_id. Each tool call adds session events; the captured snapshot keeps those later events outside that traversal.

Results and errors​

Successful tools return structuredContent plus one text-content block containing the same JSON envelope. For example, an empty repository page has this shape:

{"schema_version":"golf.mcp.v1","data":{"repositories":[],"page":{"nextPage":0}}}

data uses the existing API ProtoJSON contract: camelCase names, named enums, emitted default values and string-encoded 64-bit values. Preserve exact IDs and counts rather than converting through floating point. The envelope's schema version identifies this development format, not a stable product release.

Invalid arguments, busy admission, authorization/provider failures, excessive output and failed session cleanup return isError: true with safe diagnostic text and no successful private envelope. Protocol errors and unknown methods/tools use SDK errors. Do not interpret denial as an empty collection. Stdout contains only protocol messages; diagnostics use stderr without native response bodies or credentials.

Returned content is untrusted

Source, issues, reviews and diffs remain untrusted data. Their text cannot change the configured tools, origin or authority. A client must not execute embedded instructions or send private output to unrelated services. This adapter does not qualify an AI model's resistance to prompt injection.

What results mean​

  • Source navigation uses returned immutable commits.
  • Native diffs are not independently verified complete patches.
  • PR heads and review flags are observations rather than approval eligibility.
  • golf_repo_creation only inspects evidence: unknown/rejected is not creation success, and historical success does not grant current repository access.
  • Account activity remains selected session history, not a complete log of tool execution.
  • Issue comments resolve current repository and issue IDs within the same authenticated call, then return one filtered native repository-wide page. Empty pages may advance.
  • Own issue operation reads never dispatch writes; provisional receipt IDs do not imply success or current access.

Bounds​

BoundLimit
Inbound frame64 KiB; one UTF-8 JSON object followed by a newline. Arrays/batches are rejected.
Tool argument object16 KiB
Outstanding protocol request IDs256; duplicate active IDs or excess outstanding requests close the connection
Concurrent calls per process4; a fifth gets a busy error
Call deadline30 seconds
HTTP request timeout15 seconds
Logout deadline5 seconds (independent)
Logical ProtoJSON output8 MiB
Combined structured/text result JSON16 MiB before protocol framing

Excess output fails rather than being truncated. These are local bounds, not tenant quotas or throughput evidence.

Cancellation and qualification​

The final native SDK-client run exercises all 19 tools under both 2026-07-28 and 2025-11-25, with exact negotiation, catalogue/annotations, JSON parity, pagination, activity snapshots and temporary-session cleanup. Additional current-version checks cover invalid input before authentication, scope/account denial and subsequent permission loss.

A controlled loopback barrier held real Golf responses while four temporary sessions were active; a fifth call was refused. SDK cancellation and a separate SIGTERM trial each removed all four sessions. This validates application cleanup; the SDK client's cancellation behavior alone cannot prove what appeared on the raw protocol stream.

A separate raw-wire check found that unmodified SDK v1.8.0 sent a reply after cancellation. Golf's connection guard corrects that boundary. The final raw regression passes for both selected versions:

  • Pending cancellation aborts the HTTP read, performs logout and suppresses the cancelled reply.
  • Unknown/completed cancellation messages do not poison later reads.
  • Batches/oversized frames are denied before authentication.
  • Duplicate active request IDs abort the connection and clean up.

Legacy ID-reuse cases are defensive robustness tests, not a recommended client request pattern. These selected tests do not establish complete protocol conformance.

Run the checks​

From a product development checkout:

make cli
python3 scripts/mcp-cancellation-check.py --cli bin/golf
python3 scripts/mcp-smoke/run.py --cli bin/golf

The raw check uses a disposable local HTTP fixture. The native check requires the canonical local Golf/Forgejo stack, creates and removes ordinary temporary provider users/organizations/repositories, and retains their durable Golf identity/activity/creation history. It does not restart or reconfigure the normal stack. Full product checks and the Go race suite also pass for this increment; database-dependent tests without a test DSN are explicitly skipped in that MCP race run, not claimed as fresh native database coverage.

Known limits​

Forced termination such as SIGKILL, server unavailability or failed logout can leave a temporary session until its normal server expiry. Cancellation does not reverse native work already admitted.

For the local server: remote MCP authorization/audience binding, ACP, mutation approvals, agent execution, managed client credentials, subscriptions/resources/prompts, Cloudflare MCP integrations and actual coding-agent client compatibility remain open. The Cloudflare-native remote MCP endpoint is documented separately in Connect a coding agent. See implementation status for the final evidence and Agentic mode for the roadmap.