github

command
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GitHub REST import

A slice of the GitHub REST API served as an MCP tool with one call to mcp.FromREST. The GitHub struct describes the endpoint with a rest: tag (GET /repos/{owner}/{repo}/issues?per_page=...) and names its arguments with args:"owner,repo,per_page"; the nested Issues section becomes the tool name issues.list.

The token comes from GITHUB_TOKEN and rides a static Authorization header (mcp.WithHeader), which is sent only to the backend's own host - never taken from tool arguments. Every declared operation is exposed; examples/curated shows how to narrow and fix arguments. See main.go.

Run it

From the repository root (this one calls the real api.github.com):

GITHUB_TOKEN=ghp_... go run ./examples/github                        # stdio
GITHUB_TOKEN=ghp_... go run ./examples/github -addr 127.0.0.1:8080   # Streamable HTTP on /mcp

Test it - the test never dials GitHub; it serves the same structure against an offline stand-in backend and checks the credential header:

go test ./examples/github

Expected output

Without a token it refuses to start (exit status 1):

$ go run ./examples/github
mcp-github: set GITHUB_TOKEN; the GitHub API requires a credential

(prefixed with the log timestamp). With a token and -addr, listing the tools needs no call to GitHub; the generated input and output schemas come from the Go signature, and the annotations from its hint:"readonly" tag - with "openWorldHint": true, because the tool calls a backend mcp.FromREST imported:

$ curl -s -H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
    -H 'MCP-Protocol-Version: 2025-11-25' http://127.0.0.1:8080/mcp \
    -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
{"jsonrpc":"2.0","id":1,"result":{"ttlMs":0,"cacheScope":"private","tools":[{"annotations":{"destructiveHint":false,"idempotentHint":false,"openWorldHint":true,"readOnlyHint":true},"description":"lists a repository's issues, newest first.","inputSchema":{"additionalProperties":false,"properties":{"owner":{"type":"string"},"per_page":{"type":"integer"},"repo":{"type":"string"}},"required":["owner","repo","per_page"],"type":"object"},"name":"issues.list","outputSchema":{"additionalProperties":false,"properties":{"result":{"items":{"additionalProperties":false,"properties":{"number":{"type":"integer"},"state":{"type":"string"},"title":{"type":"string"}},"required":["number","title","state"],"type":"object"},"type":"array"}},"required":["result"],"type":"object"}}]}}

A tools/call of issues.list returns the repository's issues as {"result":[{"number":...,"title":...,"state":...}]}; that call needs a real token and network access, so no captured output is shown here.

Documentation

Overview

Command github is DESIGN_SPEC.md K46's "GitHub via rest.Import" example and D17's one-line promise made runnable: a GitHub-shaped REST API imported by mcp.FromREST and served over stdio.

Run it:

GITHUB_TOKEN=ghp_... go run ./examples/github

The credential comes from the environment (D21: credentials come from server configuration, never from tool arguments) and rides a static Authorization header - the bridge's static-key option. Per-user delegated exchange, the Auth half of DESIGN_SPEC.md §4's second snippet, is mcp.Auth over oauth.PerUser (decisions 0015 and 0049). Exposure is the default curation (every declared operation exposed, the loud expose-all warning on stderr); the curation vocabulary - Only and Fix over this same shape - is examples/curated.

The example's test never dials github.com: it drives the same structure against an offline stand-in backend, so the import, the credential header and the served surface are tested in CI without network access.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL