service

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: Apache-2.0 Imports: 27 Imported by: 1 module, 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUUID

func NewUUID() string

Types

type Account

type Account struct {
	Alias  string `json:"alias" description:"account name"`
	Domain string `json:"domain,omitempty" description:"GitHub host (default github.com)"`
}

type AddCommentInput

type AddCommentInput struct {
	GitTarget
	IssueNumber int    `json:"issueNumber"`
	Body        string `json:"body"`
}

type AddCommentOutput

type AddCommentOutput struct {
	Comment Comment `json:"comment"`
}

type AssetItem

type AssetItem struct {
	Type string `json:"type"` // file|dir
	Name string `json:"name"`
	Path string `json:"path"`
	Size int    `json:"size"`
	Sha  string `json:"sha"`
}

type CheckoutRepoInput

type CheckoutRepoInput struct {
	GitTarget
	Branch  string `json:"branch,omitempty"`
	Commit  string `json:"commit,omitempty"`
	DestDir string `json:"destDir,omitempty"`
	Depth   int    `json:"depth,omitempty"`
}

Checkout repo types

type CheckoutRepoOutput

type CheckoutRepoOutput struct {
	Path       string `json:"path"`
	CheckedOut string `json:"checkedOut"`
	WasCloned  bool   `json:"wasCloned"`
}

type Comment

type Comment struct {
	ID        int64  `json:"id"`
	Body      string `json:"body"`
	User      string `json:"user"`
	CreatedAt string `json:"createdAt"`
}

type Config

type Config struct {
	ClientID        string `json:"clientID"`
	StorageDir      string `json:"storageDir,omitempty"`
	CallbackBaseURL string `json:"callbackBaseURL,omitempty"`
	UseData         bool   `json:"useData,omitempty"`
	UseText         bool   `json:"useText,omitempty"`
	// SecretsBase is an AFS/scy URL root for persisting credentials per namespace.
	// Examples: mem://localhost/mcp-github, file://~/.mcp/github, gs://bucket/path
	SecretsBase string `json:"secretsBase,omitempty"`
}

type CreateIssueInput

type CreateIssueInput struct {
	GitTarget
	Title     string   `json:"title"`
	Body      string   `json:"body,omitempty"`
	Labels    []string `json:"labels,omitempty" description:"repeated"`
	Assignees []string `json:"assignees,omitempty" description:"repeated"`
}

type CreateIssueOutput

type CreateIssueOutput struct {
	Issue Issue `json:"issue"`
}

type CreatePRInput

type CreatePRInput struct {
	GitTarget
	Title string `json:"title"`
	Body  string `json:"body,omitempty"`
	Head  string `json:"head" description:"branch or user:branch"`
	Base  string `json:"base" description:"target branch"`
	Draft bool   `json:"draft,omitempty"`
}

type CreatePROutput

type CreatePROutput struct {
	Pull PullRequest `json:"pull"`
}

type DownloadInput

type DownloadInput struct {
	GitTarget
	Path string `json:"path"`
}

type DownloadOutput

type DownloadOutput struct {
	// Content carries binary data when the file is not recognized as UTF-8 text.
	Content []byte `json:"content,omitempty"`
	// Text carries UTF-8 textual content when auto-detected; in this case, Content is omitted.
	Text string `json:"text,omitempty"`
}

type GitTarget

type GitTarget struct {
	URL     string  `json:"url,omitempty" description:"encapsulates repo identity https://domain/owner/name"`
	Account Account `json:"account,omitempty" internal:"true"`
	Repo    RepoRef `json:"repo,omitempty" internal:"true"`
	Ref     string  `json:"ref,omitempty"`
}

GitTarget encapsulates repo identity (url/domain/owner/name), revision (ref), and auth (alias via Account).

func (*GitTarget) GetAlias

func (t *GitTarget) GetAlias(ctx context.Context, s *Service) (string, error)

GetAlias returns the effective alias for repo-scoped operations using only target data. Order of precedence: 1) Explicit account.alias if provided. 2) If exactly one stored alias has a token for this repo, use that alias (inference). 3) Default to "owner/repo" derived from the target.

func (*GitTarget) Init

func (t *GitTarget) Init(s *Service) (domain, owner, name, ref, alias string, err error)

Init parses URL first (if provided) and prefers values from the URL over explicit fields. It returns normalized domain, owner, name, ref, alias.

func (*GitTarget) ResolveRef

func (t *GitTarget) ResolveRef(ctx context.Context, cli *adapter.Client, token, owner, name, ref string) (string, error)

ResolveRef returns a usable ref, resolving the default branch if ref is empty.

type Issue

type Issue struct {
	ID     int64  `json:"id"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
}

type ListCommentsInput

type ListCommentsInput struct {
	GitTarget
	IssueNumber int `json:"issueNumber"`
}

type ListCommentsOutput

type ListCommentsOutput struct {
	Comments []Comment `json:"comments,omitempty"`
}

type ListRepoInput

type ListRepoInput struct {
	GitTarget
	Path        string   `json:"path"`
	Recursive   bool     `json:"recursive,omitempty" description:"traverse directories recursively"`
	Contains    string   `json:"contains,omitempty" description:"return only entries whose name or path contains this substring (traversal unaffected)"`
	Concurrency int      `json:"concurrency,omitempty" description:"number of concurrent directory fetches (default 6)"`
	Include     []string `json:"include,omitempty" description:"glob patterns to include (e.g., ['*.go','*.sql'])"`
	Exclude     []string `json:"exclude,omitempty" description:"glob patterns to exclude (e.g., ['*_test.go','**/vendor/**'])"`
}

List path (assets) types

type ListRepoIssuesInput

type ListRepoIssuesInput struct {
	GitTarget
	State string `json:"state,omitempty" description:"open|closed|all"`
}

type ListRepoIssuesOutput

type ListRepoIssuesOutput struct {
	Issues []Issue `json:"issues,omitempty"`
}

type ListRepoOutput

type ListRepoOutput struct {
	Items []AssetItem `json:"items"`
}

type ListRepoPRsInput

type ListRepoPRsInput struct {
	GitTarget
	State string `json:"state,omitempty" description:"open|closed|all"`
}

type ListRepoPRsOutput

type ListRepoPRsOutput struct {
	Pulls []PullRequest `json:"pulls,omitempty"`
}

type ListReposInput

type ListReposInput struct {
	Account     Account `json:"account"`
	Visibility  string  `json:"visibility,omitempty" description:"all|public|private"`
	Affiliation string  `json:"affiliation,omitempty" description:"owner,collaborator,organization_member (comma-separated)"`
	PerPage     int     `json:"perPage,omitempty" description:"page size (default 30)"`
}

type ListReposOutput

type ListReposOutput struct {
	Repos []Repo `json:"repos,omitempty"`
}

type PendingAuth

type PendingAuth struct {
	UUID      string
	Alias     string
	Namespace string
	UserCode  string
	VerifyURL string
}

type PendingAuths

type PendingAuths struct {
	// contains filtered or unexported fields
}

func NewPendingAuths

func NewPendingAuths() *PendingAuths

func (*PendingAuths) ClearNamespace

func (p *PendingAuths) ClearNamespace(ns string) []string

func (*PendingAuths) Get

func (p *PendingAuths) Get(uuid string) (*PendingAuth, bool)

func (*PendingAuths) ListNamespace

func (p *PendingAuths) ListNamespace(ns string) []*PendingAuth

func (*PendingAuths) Put

func (p *PendingAuths) Put(x *PendingAuth)

func (*PendingAuths) Remove

func (p *PendingAuths) Remove(uuid string)

type PullRequest

type PullRequest struct {
	ID     int64  `json:"id"`
	Number int    `json:"number"`
	Title  string `json:"title"`
	State  string `json:"state"`
}

type Repo

type Repo struct {
	ID       int64  `json:"id"`
	Name     string `json:"name"`
	FullName string `json:"fullName"`
}

type RepoRef

type RepoRef struct {
	Owner string `json:"owner"`
	Name  string `json:"name"`
}

type SearchIssuesInput

type SearchIssuesInput struct {
	GitTarget
	Query   string `json:"query"`
	PerPage int    `json:"perPage,omitempty"`
}

type SearchIssuesOutput

type SearchIssuesOutput struct {
	Issues []Issue `json:"issues,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg *Config) *Service

func (*Service) AddComment

func (s *Service) AddComment(ctx context.Context, in *AddCommentInput, prompt func(string)) (*AddCommentOutput, error)

AddComment adds a comment to an issue or PR (PR comments use issue comments endpoint).

func (*Service) BaseURL

func (s *Service) BaseURL() string

func (*Service) CheckoutRepo

func (s *Service) CheckoutRepo(ctx context.Context, in *CheckoutRepoInput, prompt func(string)) (*CheckoutRepoOutput, error)

CheckoutRepo clones a repository and optionally checks out a branch or commit.

func (*Service) ClientID

func (s *Service) ClientID() string

func (*Service) CreateIssue

func (s *Service) CreateIssue(ctx context.Context, in *CreateIssueInput, prompt func(string)) (*CreateIssueOutput, error)

CreateIssue creates a new issue in a repository.

func (*Service) CreatePR

func (s *Service) CreatePR(ctx context.Context, in *CreatePRInput, prompt func(string)) (*CreatePROutput, error)

CreatePR opens a pull request.

func (*Service) Credential

func (s *Service) Credential(ctx context.Context, alias, domain string, prompt func(string)) (string, error)

func (*Service) DeviceHandler

func (s *Service) DeviceHandler() http.HandlerFunc

func (*Service) DeviceStartHandler

func (s *Service) DeviceStartHandler() http.HandlerFunc

DeviceStartHandler initiates device authorization and returns URL+code without blocking for completion.

func (*Service) DownloadRepoFile

func (s *Service) DownloadRepoFile(ctx context.Context, in *DownloadInput, prompt func(string)) (*DownloadOutput, error)

DownloadRepoFile fetches raw bytes of a file at path and ref.

func (*Service) ElicitCooldown

func (s *Service) ElicitCooldown() time.Duration

ElicitCooldown returns cooldown between repeated elicitations; configurable via GITHUB_MCP_ELICIT_COOLDOWN_SECS (default 60s).

func (*Service) ListComments

func (s *Service) ListComments(ctx context.Context, in *ListCommentsInput, prompt func(string)) (*ListCommentsOutput, error)

ListComments lists comments for an issue or PR.

func (*Service) ListRepoIssues

func (s *Service) ListRepoIssues(ctx context.Context, in *ListRepoIssuesInput, prompt func(string)) (*ListRepoIssuesOutput, error)

func (*Service) ListRepoPRs

func (s *Service) ListRepoPRs(ctx context.Context, in *ListRepoPRsInput, prompt func(string)) (*ListRepoPRsOutput, error)

func (*Service) ListRepoPath

func (s *Service) ListRepoPath(ctx context.Context, in *ListRepoInput, prompt func(string)) (*ListRepoOutput, error)

ListRepoPath lists repo directory entries or a single file at the given path and ref.

func (*Service) ListRepos

func (s *Service) ListRepos(ctx context.Context, in *ListReposInput, prompt func(string)) (*ListReposOutput, error)

Public methods: ListRepos, ListRepoIssues, ListRepoPRs

func (*Service) Namespace

func (s *Service) Namespace(ctx context.Context) string

Namespace returns the effective authorization namespace for this request context, or "default" when not set.

func (*Service) NewOperationsHook

func (s *Service) NewOperationsHook(_ protoclient.Operations)

func (*Service) OOBHandler

func (s *Service) OOBHandler() http.HandlerFunc

OOBHandler serves a page to collect credentials: bearer token, basic creds, or start device flow.

func (*Service) PendingClearHandler

func (s *Service) PendingClearHandler() http.HandlerFunc

func (*Service) PendingListHandler

func (s *Service) PendingListHandler() http.HandlerFunc

func (*Service) RegisterHTTP

func (s *Service) RegisterHTTP(mux *http.ServeMux)

func (*Service) SearchIssues

func (s *Service) SearchIssues(ctx context.Context, in *SearchIssuesInput, prompt func(string)) (*SearchIssuesOutput, error)

SearchIssues runs a GitHub issues/PRs search query.

func (*Service) SetCmdRunner

func (s *Service) SetCmdRunner(r cmdRunner)

SetCmdRunner allows tests to inject a custom runner.

func (*Service) StorageDir

func (s *Service) StorageDir() string

func (*Service) TokenCheckHandler

func (s *Service) TokenCheckHandler() http.HandlerFunc

TokenCheckHandler returns whether a token exists for alias/domain.

func (*Service) TokenIngestHandler

func (s *Service) TokenIngestHandler() http.HandlerFunc

TokenIngestHandler accepts a token via Authorization header (Bearer or Basic) or JSON body and stores it for alias/domain.

func (*Service) UseTextField

func (s *Service) UseTextField() bool

func (*Service) VerifyHandler

func (s *Service) VerifyHandler() http.HandlerFunc

VerifyHandler checks whether the provided/stored credential can access the repo's default branch tree. GET /github/auth/verify?alias=...&domain=...&url=domain/owner/repo

func (*Service) WaitTimeout

func (s *Service) WaitTimeout() time.Duration

WaitTimeout returns maximum time to wait for credentials; configurable via GITHUB_MCP_WAIT_SECS (default 300s).

Jump to

Keyboard shortcuts

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