github

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

deprecated_tool_aliases.go

Index

Constants

View Source
const (
	DescriptionRepositoryOwner = "Repository owner"
	DescriptionRepositoryName  = "Repository name"
)
View Source
const (
	FilterDefault           = "default"
	FilterIncludeRead       = "include_read_notifications"
	FilterOnlyParticipating = "only_participating"
)
View Source
const (
	NotificationActionIgnore = "ignore"
	NotificationActionWatch  = "watch"
	NotificationActionDelete = "delete"
)

Enum values for ManageNotificationSubscription action

View Source
const (
	RepositorySubscriptionActionWatch  = "watch"
	RepositorySubscriptionActionIgnore = "ignore"
	RepositorySubscriptionActionDelete = "delete"
)
View Source
const (
	ProjectUpdateFailedError             = "failed to update a project item"
	ProjectAddFailedError                = "failed to add a project item"
	ProjectDeleteFailedError             = "failed to delete a project item"
	ProjectListFailedError               = "failed to list project items"
	ProjectStatusUpdateListFailedError   = "failed to list project status updates"
	ProjectStatusUpdateGetFailedError    = "failed to get project status update"
	ProjectStatusUpdateCreateFailedError = "failed to create project status update"
	ProjectResolveIDFailedError          = "failed to resolve project ID"
	MaxProjectsPerPage                   = 50
)
View Source
const DefaultGraphQLPageSize = 30
View Source
const GetMeUIResourceURI = "ui://omnigit-mcp/get-me"

GetMeUIResourceURI is the URI for the get_me tool's MCP App UI resource.

View Source
const IssueWriteUIResourceURI = "ui://omnigit-mcp/issue-write"

IssueWrite creates a tool to create a new or update an existing issue in a GitHub repository. IssueWriteUIResourceURI is the URI for the issue_write tool's MCP App UI resource.

View Source
const PullRequestWriteUIResourceURI = "ui://omnigit-mcp/pr-write"

PullRequestWriteUIResourceURI is the URI for the create_pull_request tool's MCP App UI resource.

Variables

View Source
var (
	ToolsetMetadataAll = inventory.ToolsetMetadata{
		ID:          "all",
		Description: "Special toolset that enables all available toolsets",
		Icon:        "apps",
	}
	ToolsetMetadataDefault = inventory.ToolsetMetadata{
		ID:          "default",
		Description: "Special toolset that enables the default toolset configuration. When no toolsets are specified, this is the set that is enabled",
		Icon:        "check-circle",
	}
	ToolsetMetadataContext = inventory.ToolsetMetadata{
		ID:               "context",
		Description:      "Tools that provide context about the current user and GitHub context you are operating in",
		Default:          true,
		Icon:             "person",
		InstructionsFunc: generateContextToolsetInstructions,
	}
	ToolsetMetadataRepos = inventory.ToolsetMetadata{
		ID:          "repos",
		Description: "GitHub Repository related tools",
		Default:     true,
		Icon:        "repo",
	}
	ToolsetMetadataGit = inventory.ToolsetMetadata{
		ID:          "git",
		Description: "GitHub Git API related tools for low-level Git operations",
		Icon:        "git-branch",
	}
	ToolsetMetadataIssues = inventory.ToolsetMetadata{
		ID:               "issues",
		Description:      "GitHub Issues related tools",
		Default:          true,
		Icon:             "issue-opened",
		InstructionsFunc: generateIssuesToolsetInstructions,
	}
	ToolsetMetadataPullRequests = inventory.ToolsetMetadata{
		ID:               "pull_requests",
		Description:      "GitHub Pull Request related tools",
		Default:          true,
		Icon:             "git-pull-request",
		InstructionsFunc: generatePullRequestsToolsetInstructions,
	}
	ToolsetMetadataUsers = inventory.ToolsetMetadata{
		ID:          "users",
		Description: "GitHub User related tools",
		Default:     true,
		Icon:        "people",
	}
	ToolsetMetadataOrgs = inventory.ToolsetMetadata{
		ID:          "orgs",
		Description: "GitHub Organization related tools",
		Icon:        "organization",
	}
	ToolsetMetadataActions = inventory.ToolsetMetadata{
		ID:          "actions",
		Description: "GitHub Actions workflows and CI/CD operations",
		Icon:        "workflow",
	}
	ToolsetMetadataCodeSecurity = inventory.ToolsetMetadata{
		ID:          "code_security",
		Description: "Code security related tools, such as GitHub Code Scanning",
		Icon:        "codescan",
	}
	ToolsetMetadataSecretProtection = inventory.ToolsetMetadata{
		ID:          "secret_protection",
		Description: "Secret protection related tools, such as GitHub Secret Scanning",
		Icon:        "shield-lock",
	}
	ToolsetMetadataDependabot = inventory.ToolsetMetadata{
		ID:          "dependabot",
		Description: "Dependabot tools",
		Icon:        "dependabot",
	}
	ToolsetMetadataNotifications = inventory.ToolsetMetadata{
		ID:          "notifications",
		Description: "GitHub Notifications related tools",
		Icon:        "bell",
	}
	ToolsetMetadataDiscussions = inventory.ToolsetMetadata{
		ID:               "discussions",
		Description:      "GitHub Discussions related tools",
		Icon:             "comment-discussion",
		InstructionsFunc: generateDiscussionsToolsetInstructions,
	}
	ToolsetMetadataGists = inventory.ToolsetMetadata{
		ID:          "gists",
		Description: "GitHub Gist related tools",
		Icon:        "logo-gist",
	}
	ToolsetMetadataSecurityAdvisories = inventory.ToolsetMetadata{
		ID:          "security_advisories",
		Description: "Security advisories related tools",
		Icon:        "shield",
	}
	ToolsetMetadataProjects = inventory.ToolsetMetadata{
		ID:               "projects",
		Description:      "GitHub Projects related tools",
		Icon:             "project",
		InstructionsFunc: generateProjectsToolsetInstructions,
	}
	ToolsetMetadataStargazers = inventory.ToolsetMetadata{
		ID:          "stargazers",
		Description: "GitHub Stargazers related tools",
		Icon:        "star",
	}
	ToolsetMetadataDynamic = inventory.ToolsetMetadata{
		ID:          "dynamic",
		Description: "Discover GitHub MCP tools that can help achieve tasks by enabling additional sets of tools, you can control the enablement of any toolset to access its tools when this toolset is enabled.",
		Icon:        "tools",
	}
	ToolsetLabels = inventory.ToolsetMetadata{
		ID:          "labels",
		Description: "GitHub Labels related tools",
		Icon:        "tag",
	}

	// Remote-only toolsets - these are only available in the remote MCP server
	// but are documented here for consistency and to enable automated documentation.
	ToolsetMetadataCopilot = inventory.ToolsetMetadata{
		ID:          "copilot",
		Description: "Copilot related tools",
		Icon:        "copilot",
	}
	ToolsetMetadataCopilotSpaces = inventory.ToolsetMetadata{
		ID:          "copilot_spaces",
		Description: "Copilot Spaces tools",
		Icon:        "copilot",
	}
	ToolsetMetadataSupportSearch = inventory.ToolsetMetadata{
		ID:          "github_support_docs_search",
		Description: "Retrieve documentation to answer GitHub product and support questions. Topics include: GitHub Actions Workflows, Authentication, ...",
		Icon:        "book",
	}
)

Toolset metadata constants - these define all available toolsets and their descriptions. Tools use these constants to declare which toolset they belong to. Icons are Octicon names from https://primer.style/foundations/icons

View Source
var DeprecatedToolAliases = map[string]string{

	"list_workflows":                 "actions_list",
	"list_workflow_runs":             "actions_list",
	"list_workflow_jobs":             "actions_list",
	"list_workflow_run_artifacts":    "actions_list",
	"get_workflow":                   "actions_get",
	"get_workflow_run":               "actions_get",
	"get_workflow_job":               "actions_get",
	"get_workflow_run_usage":         "actions_get",
	"get_workflow_run_logs":          "actions_get",
	"get_workflow_job_logs":          "actions_get",
	"download_workflow_run_artifact": "actions_get",
	"run_workflow":                   "actions_run_trigger",
	"rerun_workflow_run":             "actions_run_trigger",
	"rerun_failed_jobs":              "actions_run_trigger",
	"cancel_workflow_run":            "actions_run_trigger",
	"delete_workflow_run_logs":       "actions_run_trigger",

	"list_projects":       "projects_list",
	"list_project_fields": "projects_list",
	"list_project_items":  "projects_list",
	"get_project":         "projects_get",
	"get_project_field":   "projects_get",
	"get_project_item":    "projects_get",
	"add_project_item":    "projects_write",
	"update_project_item": "projects_write",
	"delete_project_item": "projects_write",
}

DeprecatedToolAliases maps old tool names to their new canonical names. When tools are renamed, add an entry here to maintain backward compatibility. Users referencing the old name will receive the new tool with a deprecation warning.

Example:

"get_issue": "issue_read",
"create_pr": "pull_request_create",
View Source
var ErrDepsNotInContext = errors.New("ToolDependencies not found in context; use ContextWithDeps to inject")

ErrDepsNotInContext is returned when ToolDependencies is not found in context.

View Source
var RepositoryResourceArgumentResolvers = map[string]CompleteHandler{
	"owner":    completeOwner,
	"repo":     completeRepo,
	"branch":   completeBranch,
	"sha":      completeSHA,
	"tag":      completeTag,
	"prNumber": completePRNumber,
	"path":     completePath,
}

RepositoryResourceArgumentResolvers is a map of argument names to their completion handlers

View Source
var UIAssets embed.FS

UIAssets embeds the built MCP App UI HTML files. These files are generated by running `script/build-ui` which compiles the React/Primer components in the ui/ directory.

Functions

func ActionsGet

ActionsGet returns the tool and handler for getting GitHub Actions resources.

func ActionsGetJobLogs

ActionsGetJobLogs returns the tool and handler for getting workflow job logs.

func ActionsList

ActionsList returns the tool and handler for listing GitHub Actions resources.

func ActionsRunTrigger

ActionsRunTrigger returns the tool and handler for triggering GitHub Actions workflows.

func AddCommentToPendingReview

func AddCommentToPendingReview(t translations.TranslationHelperFunc) inventory.ServerTool

AddCommentToPendingReview creates a tool to add a comment to a pull request review.

func AddDefaultToolset

func AddDefaultToolset(result []string) []string

AddDefaultToolset removes the default toolset and expands it to the actual default toolset IDs

func AddIssueComment

AddIssueComment creates a tool to add a comment to an issue.

func AddReplyToPullRequestComment

func AddReplyToPullRequestComment(t translations.TranslationHelperFunc) inventory.ServerTool

AddReplyToPullRequestComment creates a tool to add a reply to an existing pull request comment.

func AddSubIssue

func AddSubIssue(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int, replaceParent bool) (*mcp.CallToolResult, error)

func AllPrompts

AllPrompts returns all prompts with their embedded toolset metadata. Prompt functions return ServerPrompt directly with toolset info.

func AllResources

AllResources returns all resource templates with their embedded toolset metadata. Resource definitions are stateless - handlers are generated on-demand during registration.

func AllTools

AllTools returns all tools with their embedded toolset metadata. Tool functions return ServerTool directly with toolset info.

func CleanTools

func CleanTools(toolNames []string) []string

CleanTools cleans tool names by removing duplicates and trimming whitespace. Validation of tool existence is done during registration.

func CompletionsHandler

func CompletionsHandler(getClient GetClientFn) func(ctx context.Context, req *mcp.CompleteRequest) (*mcp.CompleteResult, error)

func ContainsToolset

func ContainsToolset(tools []string, toCheck string) bool

func ContextWithDeps

func ContextWithDeps(ctx context.Context, deps ToolDependencies) context.Context

ContextWithDeps returns a new context with the ToolDependencies stored in it. This is used to inject dependencies at request time rather than at registration time, avoiding expensive closure creation during server initialization.

For the local server, this is called once at startup since deps don't change. For the remote server, this is called per-request with request-specific deps.

func ContextWithPollConfig

func ContextWithPollConfig(ctx context.Context, config PollConfig) context.Context

ContextWithPollConfig returns a context with polling configuration. Use this in tests to reduce or disable polling.

func CreateBranch

CreateBranch creates a tool to create a new branch.

func CreateGist

CreateGist creates a tool to create a new gist

func CreateIssue

func CreateIssue(ctx context.Context, client *github.Client, owner string, repo string, title string, body string, assignees []string, labels []string, milestoneNum int, issueType string) (*mcp.CallToolResult, error)

func CreateOrUpdateFile

CreateOrUpdateFile creates a tool to create or update a file in a GitHub repository.

func CreatePullRequest

CreatePullRequest creates a tool to create a new pull request.

func CreatePullRequestReview

func CreatePullRequestReview(ctx context.Context, client *githubv4.Client, params PullRequestReviewWriteParams) (*mcp.CallToolResult, error)

func CreateRepository

CreateRepository creates a tool to create a new GitHub repository.

func CreateToolScopeFilter

func CreateToolScopeFilter(tokenScopes []string) inventory.ToolFilter

CreateToolScopeFilter creates an inventory.ToolFilter that filters tools based on the token's OAuth scopes.

For PATs (Personal Access Tokens), we cannot issue OAuth scope challenges like we can with OAuth apps. Instead, we hide tools that require scopes the token doesn't have.

This is the recommended way to filter tools for stdio servers where the token is known at startup and won't change during the session.

The filter returns true (include tool) if:

  • The tool has no scope requirements (AcceptedScopes is empty)
  • The tool is read-only and only requires repo/public_repo scopes (works on public repos)
  • The token has at least one of the tool's accepted scopes

Example usage:

tokenScopes, err := scopes.FetchTokenScopes(ctx, token)
if err != nil {
    // Handle error - maybe skip filtering
}
filter := github.CreateToolScopeFilter(tokenScopes)
inventory := github.NewInventory(t).WithFilter(filter).Build()

func DeleteFile

DeleteFile creates a tool to delete a file in a GitHub repository. This tool uses a more roundabout way of deleting a file than just using the client.Repositories.DeleteFile. This is because REST file deletion endpoint (and client.Repositories.DeleteFile) don't add commit signing to the deletion commit, unlike how the endpoint backing the create_or_update_files tool does. This appears to be a quirk of the API. The approach implemented here gets automatic commit signing when used with either the github-actions user or as an app, both of which suit an LLM well.

func DeletePendingPullRequestReview

func DeletePendingPullRequestReview(ctx context.Context, client *githubv4.Client, params PullRequestReviewWriteParams) (*mcp.CallToolResult, error)

func DismissNotification

DismissNotification creates a tool to mark a notification as read/done.

func DynamicTools

func DynamicTools(r *inventory.Inventory) []inventory.ServerTool

DynamicTools returns the tools for dynamic toolset management. These tools allow runtime discovery and enablement of inventory. The r parameter provides the available toolset IDs for JSON Schema enums.

func EnableToolset

func EnableToolset(r *inventory.Inventory) inventory.ServerTool

EnableToolset creates a tool that enables a toolset at runtime.

func ForkRepository

ForkRepository creates a tool to fork a repository.

func GenerateToolsetsHelp

func GenerateToolsetsHelp() string

GenerateToolsetsHelp generates the help text for the toolsets flag

func GetDefaultToolsetIDs

func GetDefaultToolsetIDs() []string

GetDefaultToolsetIDs returns the IDs of toolsets marked as Default. This is a convenience function that builds an inventory to determine defaults.

func GetFileContents

GetFileContents creates a tool to get the contents of a file or directory from a GitHub repository.

func GetGist

GetGist creates a tool to get the content of a gist

func GetIssue

func GetIssue(ctx context.Context, client *github.Client, deps ToolDependencies, owner string, repo string, issueNumber int) (*mcp.CallToolResult, error)

func GetIssueComments

func GetIssueComments(ctx context.Context, client *github.Client, deps ToolDependencies, owner string, repo string, issueNumber int, pagination PaginationParams) (*mcp.CallToolResult, error)

func GetIssueLabels

func GetIssueLabels(ctx context.Context, client *githubv4.Client, owner string, repo string, issueNumber int) (*mcp.CallToolResult, error)

func GetLabel

GetLabel retrieves a specific label by name from a GitHub repository

func GetLabelForLabelsToolset

func GetLabelForLabelsToolset(t translations.TranslationHelperFunc) inventory.ServerTool

GetLabelForLabelsToolset returns the same GetLabel tool but registered in the labels toolset. This provides conformance with the original behavior where get_label was in both toolsets.

func GetLatestRelease

GetLatestRelease creates a tool to get the latest release in a GitHub repository.

func GetMe

GetMe creates a tool to get details of the authenticated user.

func GetNotificationDetails

func GetNotificationDetails(t translations.TranslationHelperFunc) inventory.ServerTool

GetNotificationDetails creates a tool to get details for a specific notification.

func GetPullRequest

func GetPullRequest(ctx context.Context, client *github.Client, deps ToolDependencies, owner, repo string, pullNumber int) (*mcp.CallToolResult, error)

func GetPullRequestDiff

func GetPullRequestDiff(ctx context.Context, client *github.Client, owner, repo string, pullNumber int) (*mcp.CallToolResult, error)

func GetPullRequestFiles

func GetPullRequestFiles(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error)

func GetPullRequestReviewComments

func GetPullRequestReviewComments(ctx context.Context, gqlClient *githubv4.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination CursorPaginationParams) (*mcp.CallToolResult, error)

func GetPullRequestReviews

func GetPullRequestReviews(ctx context.Context, client *github.Client, deps ToolDependencies, owner, repo string, pullNumber int) (*mcp.CallToolResult, error)

func GetPullRequestStatus

func GetPullRequestStatus(ctx context.Context, client *github.Client, owner, repo string, pullNumber int) (*mcp.CallToolResult, error)

func GetRepositoryResourceBranchContent

func GetRepositoryResourceBranchContent(t translations.TranslationHelperFunc) inventory.ServerResourceTemplate

GetRepositoryResourceBranchContent defines the resource template for getting repository content for a branch.

func GetRepositoryResourceCommitContent

func GetRepositoryResourceCommitContent(t translations.TranslationHelperFunc) inventory.ServerResourceTemplate

GetRepositoryResourceCommitContent defines the resource template for getting repository content for a commit.

func GetRepositoryResourceContent

GetRepositoryResourceContent defines the resource template for getting repository content.

func GetRepositoryResourcePrContent

func GetRepositoryResourcePrContent(t translations.TranslationHelperFunc) inventory.ServerResourceTemplate

GetRepositoryResourcePrContent defines the resource template for getting repository content for a pull request.

func GetRepositoryResourceTagContent

func GetRepositoryResourceTagContent(t translations.TranslationHelperFunc) inventory.ServerResourceTemplate

GetRepositoryResourceTagContent defines the resource template for getting repository content for a tag.

func GetRepositoryTree

GetRepositoryTree creates a tool to get the tree structure of a GitHub repository.

func GetSubIssues

func GetSubIssues(ctx context.Context, client *github.Client, deps ToolDependencies, owner string, repo string, issueNumber int, pagination PaginationParams) (*mcp.CallToolResult, error)

func GetTag

GetTag creates a tool to get details about a specific tag in a GitHub repository.

func GetToolsetsTools

func GetToolsetsTools(r *inventory.Inventory) inventory.ServerTool

GetToolsetsTools creates a tool that lists all tools in a specific toolset.

func GetUIAsset

func GetUIAsset(name string) (string, error)

GetUIAsset reads a UI asset from the embedded filesystem. The name should be just the filename (e.g., "get-me.html").

func InjectDepsMiddleware

func InjectDepsMiddleware(deps ToolDependencies) mcp.Middleware

func InjectGitDepsMiddleware

func InjectGitDepsMiddleware(deps ToolDependencies) mcp.Middleware

InjectGitDepsMiddleware creates a middleware that injects git.ToolDependencies into the context. This allows git tools to retrieve their dependencies from context at call time.

func IssueCommentWrite

IssueCommentWrite creates a tool to update or delete an issue comment.

func IssueRead

IssueRead creates a tool to get details of a specific issue in a GitHub repository.

func IssueToFixWorkflowPrompt

func IssueToFixWorkflowPrompt(t translations.TranslationHelperFunc) inventory.ServerPrompt

IssueToFixWorkflowPrompt provides a guided workflow for creating an issue and then generating a PR to fix it

func LabelWrite

LabelWrite handles create, update, and delete operations for GitHub labels

func ListAvailableToolsets

func ListAvailableToolsets() inventory.ServerTool

ListAvailableToolsets creates a tool that lists all available inventory.

func ListBranches

ListBranches creates a tool to list branches in a GitHub repository.

func ListCommits

ListCommits creates a tool to get commits of a branch in a repository.

func ListGists

ListGists creates a tool to list gists for a user

func ListIssueTypes

ListIssueTypes creates a tool to list defined issue types for an organization. This can be used to understand supported issue type values for creating or updating issues.

func ListIssues

ListIssues creates a tool to list and filter repository issues

func ListLabels

ListLabels lists labels from a repository

func ListNotifications

ListNotifications creates a tool to list notifications for the current user.

func ListPullRequests

ListPullRequests creates a tool to list and filter repository pull requests.

func ListReleases

ListReleases creates a tool to list releases in a GitHub repository.

func ListStarredRepositories

func ListStarredRepositories(t translations.TranslationHelperFunc) inventory.ServerTool

ListStarredRepositories creates a tool to list starred repositories for the authenticated user or a specified user.

func ListTags

ListTags creates a tool to list tags in a GitHub repository.

func ManageNotificationSubscription

func ManageNotificationSubscription(t translations.TranslationHelperFunc) inventory.ServerTool

ManageNotificationSubscription creates a tool to manage a notification subscription (ignore, watch, delete)

func ManageRepositoryNotificationSubscription

func ManageRepositoryNotificationSubscription(t translations.TranslationHelperFunc) inventory.ServerTool

ManageRepositoryNotificationSubscription creates a tool to manage a repository notification subscription (ignore, watch, delete)

func MarkAllNotificationsRead

func MarkAllNotificationsRead(t translations.TranslationHelperFunc) inventory.ServerTool

MarkAllNotificationsRead creates a tool to mark all notifications as read.

func MarshalledTextResult

func MarshalledTextResult(v any) *mcp.CallToolResult

func MergePullRequest

MergePullRequest creates a tool to merge a pull request.

func MustGetUIAsset

func MustGetUIAsset(name string) string

MustGetUIAsset reads a UI asset and panics if it fails. Use this when the asset is required for server operation.

func NewDynamicTool

func NewDynamicTool(toolset inventory.ToolsetMetadata, tool mcp.Tool, handler func(deps DynamicToolDependencies) mcp.ToolHandlerFor[map[string]any, any]) inventory.ServerTool

NewDynamicTool creates a ServerTool with fully-typed DynamicToolDependencies. Dynamic tools use a different dependency structure (DynamicToolDependencies) than regular tools (ToolDependencies), so they intentionally use the closure pattern.

func NewInventory

NewInventory creates an Inventory with all available tools, resources, and prompts. Tools, resources, and prompts are self-describing with their toolset metadata embedded. This function is stateless - no dependencies are captured. Handlers are generated on-demand during registration via RegisterAll(ctx, server, deps). The "default" keyword in WithToolsets will expand to toolsets marked with Default: true.

func NewMCPServer

func NewMCPServer(ctx context.Context, cfg *MCPServerConfig, deps ToolDependencies, inv *inventory.Inventory, middleware ...mcp.Middleware) (*mcp.Server, error)

func NewServer

func NewServer(version string, opts *mcp.ServerOptions) *mcp.Server

NewServer creates a new GitHub MCP server with the specified GH client and logger.

func NewTool

func NewTool[In, Out any](
	toolset inventory.ToolsetMetadata,
	tool mcp.Tool,
	requiredScopes []scopes.Scope,
	handler func(ctx context.Context, deps ToolDependencies, req *mcp.CallToolRequest, args In) (*mcp.CallToolResult, Out, error),
) inventory.ServerTool

NewTool creates a ServerTool that retrieves ToolDependencies from context at call time. This avoids creating closures at registration time, which is important for performance in servers that create a new server instance per request (like the remote server).

The handler function receives deps extracted from context via MustDepsFromContext. Ensure ContextWithDeps is called to inject deps before any tool handlers are invoked.

requiredScopes specifies the minimum OAuth scopes needed for this tool. AcceptedScopes are automatically derived using the scope hierarchy (e.g., if public_repo is required, repo is also accepted since repo grants public_repo).

func NewToolFromHandler

func NewToolFromHandler(
	toolset inventory.ToolsetMetadata,
	tool mcp.Tool,
	requiredScopes []scopes.Scope,
	handler func(ctx context.Context, deps ToolDependencies, req *mcp.CallToolRequest) (*mcp.CallToolResult, error),
) inventory.ServerTool

NewToolFromHandler creates a ServerTool that retrieves ToolDependencies from context at call time. Use this when you have a handler that conforms to mcp.ToolHandler directly.

The handler function receives deps extracted from context via MustDepsFromContext. Ensure ContextWithDeps is called to inject deps before any tool handlers are invoked.

requiredScopes specifies the minimum OAuth scopes needed for this tool. AcceptedScopes are automatically derived using the scope hierarchy.

func OptionalBigIntArrayParam

func OptionalBigIntArrayParam(args map[string]any, p string) ([]int64, error)

OptionalBigIntArrayParam is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request, if not, it returns an empty slice 2. If it is present, iterates the elements, checks each is a string, and converts them to int64 values

func OptionalBoolParamWithDefault

func OptionalBoolParamWithDefault(args map[string]any, p string, d bool) (bool, error)

OptionalBoolParamWithDefault is a helper function that can be used to fetch a requested parameter from the request similar to optionalBoolParam, but it also takes a default value.

func OptionalIntParam

func OptionalIntParam(args map[string]any, p string) (int, error)

OptionalIntParam is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request, if not, it returns its zero-value 2. If it is present, it checks if the parameter is of the expected type and returns it

func OptionalIntParamWithDefault

func OptionalIntParamWithDefault(args map[string]any, p string, d int) (int, error)

OptionalIntParamWithDefault is a helper function that can be used to fetch a requested parameter from the request similar to optionalIntParam, but it also takes a default value.

func OptionalParam

func OptionalParam[T any](args map[string]any, p string) (T, error)

OptionalParam is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request, if not, it returns its zero-value 2. If it is present, it checks if the parameter is of the expected type and returns it

func OptionalParamOK

func OptionalParamOK[T any, A map[string]any](args A, p string) (value T, ok bool, err error)

OptionalParamOK is a helper function that can be used to fetch a requested parameter from the request. It returns the value, a boolean indicating if the parameter was present, and an error if the type is wrong.

func OptionalStringArrayParam

func OptionalStringArrayParam(args map[string]any, p string) ([]string, error)

OptionalStringArrayParam is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request, if not, it returns its zero-value 2. If it is present, iterates the elements and checks each is a string

func ProjectsGet

ProjectsGet returns the tool and handler for getting GitHub Projects resources.

func ProjectsList

ProjectsList returns the tool and handler for listing GitHub Projects resources.

func ProjectsWrite

ProjectsWrite returns the tool and handler for modifying GitHub Projects resources.

func PullRequestCommentWrite

func PullRequestCommentWrite(t translations.TranslationHelperFunc) inventory.ServerTool

PullRequestCommentWrite creates a tool to update or delete a pull request review comment.

func PullRequestRead

PullRequestRead creates a tool to get details of a specific pull request.

func PushFiles

PushFiles creates a tool to push multiple files in a single commit to a GitHub repository.

func RegisterUIResources

func RegisterUIResources(s *mcp.Server)

RegisterUIResources registers MCP App UI resources with the server. These are static resources (not templates) that serve HTML content for MCP App-enabled tools. The HTML is built from React/Primer components in the ui/ directory using `script/build-ui`.

func RemoteOnlyToolsets

func RemoteOnlyToolsets() []inventory.ToolsetMetadata

RemoteOnlyToolsets returns toolset metadata for toolsets that are only available in the remote MCP server. These are documented but not registered in the local server.

func RemoveSubIssue

func RemoveSubIssue(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int) (*mcp.CallToolResult, error)

func RemoveToolset

func RemoveToolset(tools []string, toRemove string) []string

func RepositoryResourceCompletionHandler

func RepositoryResourceCompletionHandler(getClient GetClientFn) func(ctx context.Context, req *mcp.CompleteRequest) (*mcp.CompleteResult, error)

RepositoryResourceCompletionHandler returns a CompletionHandlerFunc for repository resource completions.

func RepositoryResourceContentsHandler

func RepositoryResourceContentsHandler(resourceURITemplate *uritemplate.Template) mcp.ResourceHandler

RepositoryResourceContentsHandler returns a handler function for repository content requests. It retrieves ToolDependencies from the context at call time via MustDepsFromContext.

func ReprioritizeSubIssue

func ReprioritizeSubIssue(ctx context.Context, client *github.Client, owner string, repo string, issueNumber int, subIssueID int, afterID int, beforeID int) (*mcp.CallToolResult, error)

func RequestCopilotReview

RequestCopilotReview creates a tool to request a Copilot review for a pull request. Note that this tool will not work on GHES where this feature is unsupported. In future, we should not expose this tool if the configured host does not support it.

func RequiredBigInt

func RequiredBigInt(args map[string]any, p string) (int64, error)

RequiredBigInt is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request. 2. Checks if the parameter is of the expected type (float64). 3. Checks if the parameter is not empty, i.e: non-zero value. 4. Validates that the float64 value can be safely converted to int64 without truncation.

func RequiredInt

func RequiredInt(args map[string]any, p string) (int, error)

RequiredInt is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request. 2. Checks if the parameter is of the expected type. 3. Checks if the parameter is not empty, i.e: non-zero value

func RequiredParam

func RequiredParam[T comparable](args map[string]any, p string) (T, error)

RequiredParam is a helper function that can be used to fetch a requested parameter from the request. It does the following checks: 1. Checks if the parameter is present in the request. 2. Checks if the parameter is of the expected type. 3. Checks if the parameter is not empty, i.e: non-zero value

func ResolvedEnabledToolsets

func ResolvedEnabledToolsets(dynamicToolsets bool, enabledToolsets []string, enabledTools []string) []string

ResolvedEnabledToolsets determines which toolsets should be enabled based on config. Returns nil for "use defaults", empty slice for "none", or explicit list.

func SearchCode

SearchCode creates a tool to search for code across GitHub repositories.

func SearchIssues

SearchIssues creates a tool to search for issues.

func SearchOrgs

SearchOrgs creates a tool to search for GitHub organizations.

func SearchPullRequests

SearchPullRequests creates a tool to search for pull requests.

func SearchRepositories

SearchRepositories creates a tool to search for GitHub repositories.

func SearchUsers

SearchUsers creates a tool to search for GitHub users.

func StarRepository

StarRepository creates a tool to star a repository.

func SubIssueWrite

SubIssueWrite creates a tool to add a sub-issue to a parent issue.

func SubmitPendingPullRequestReview

func SubmitPendingPullRequestReview(ctx context.Context, client *githubv4.Client, params PullRequestReviewWriteParams) (*mcp.CallToolResult, error)

func ToBoolPtr

func ToBoolPtr(b bool) *bool

ToBoolPtr converts a bool to a *bool pointer.

func ToStringPtr

func ToStringPtr(s string) *string

ToStringPtr converts a string to a *string pointer. Returns nil if the string is empty.

func UIAssetsAvailable

func UIAssetsAvailable() bool

UIAssetsAvailable returns true if the MCP App UI assets have been built. This checks for a known UI asset file to determine if `script/build-ui` has been run. Use this to gracefully skip UI registration when assets aren't available, allowing Insiders mode to work for non-UI features without requiring a UI build.

func UnstarRepository

UnstarRepository creates a tool to unstar a repository.

func UpdateGist

UpdateGist creates a tool to edit an existing gist

func UpdateIssue

func UpdateIssue(ctx context.Context, client *github.Client, gqlClient *githubv4.Client, owner string, repo string, issueNumber int, title string, body string, assignees []string, labels []string, milestoneNum int, issueType string, state string, stateReason string, duplicateOf int) (*mcp.CallToolResult, error)

func UpdatePullRequest

UpdatePullRequest creates a tool to update an existing pull request.

func UpdatePullRequestBranch

func UpdatePullRequestBranch(t translations.TranslationHelperFunc) inventory.ServerTool

UpdatePullRequestBranch creates a tool to update a pull request branch with the latest changes from the base branch.

func WithCursorPagination

func WithCursorPagination(schema *jsonschema.Schema) *jsonschema.Schema

WithCursorPagination adds only cursor-based pagination parameters to a tool (no page parameter).

func WithPagination

func WithPagination(schema *jsonschema.Schema) *jsonschema.Schema

WithPagination adds REST API pagination parameters to a tool. https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api

func WithUnifiedPagination

func WithUnifiedPagination(schema *jsonschema.Schema) *jsonschema.Schema

WithUnifiedPagination adds REST API pagination parameters to a tool. GraphQL tools will use this and convert page/perPage to GraphQL cursor parameters internally.

Types

type AgentAssignmentInput

type AgentAssignmentInput struct {
	BaseRef            *githubv4.String `json:"baseRef,omitempty"`
	CustomAgent        *githubv4.String `json:"customAgent,omitempty"`
	CustomInstructions *githubv4.String `json:"customInstructions,omitempty"`
	TargetRepositoryID githubv4.ID      `json:"targetRepositoryId"`
}

AgentAssignmentInput represents the input for assigning an agent to an issue.

type BaseDeps

type BaseDeps struct {
	// Pre-created clients
	Client    *gogithub.Client
	GQLClient *githubv4.Client
	RawClient *raw.Client

	// Static dependencies
	RepoAccessCache   *lockdown.RepoAccessCache
	T                 translations.TranslationHelperFunc
	Flags             FeatureFlags
	ContentWindowSize int

	// Local git operations
	GitOps    gitops.GitOperations
	RepoPaths []string
	// contains filtered or unexported fields
}

BaseDeps is the standard implementation of ToolDependencies for the local server. It stores pre-created clients. The remote server can create its own struct implementing ToolDependencies with different client creation strategies.

func NewBaseDeps

func NewBaseDeps(
	client *gogithub.Client,
	gqlClient *githubv4.Client,
	rawClient *raw.Client,
	repoAccessCache *lockdown.RepoAccessCache,
	t translations.TranslationHelperFunc,
	flags FeatureFlags,
	contentWindowSize int,
	featureChecker inventory.FeatureFlagChecker,
	gitOps gitops.GitOperations,
	repoPaths []string,
) *BaseDeps

NewBaseDeps creates a BaseDeps with the provided clients and configuration.

func (BaseDeps) GetClient

func (d BaseDeps) GetClient(_ context.Context) (*gogithub.Client, error)

GetClient implements ToolDependencies.

func (BaseDeps) GetContentWindowSize

func (d BaseDeps) GetContentWindowSize() int

GetContentWindowSize implements ToolDependencies.

func (BaseDeps) GetFlags

func (d BaseDeps) GetFlags(_ context.Context) FeatureFlags

GetFlags implements ToolDependencies.

func (BaseDeps) GetGQLClient

func (d BaseDeps) GetGQLClient(_ context.Context) (*githubv4.Client, error)

GetGQLClient implements ToolDependencies.

func (BaseDeps) GetGitOps

func (d BaseDeps) GetGitOps() gitops.GitOperations

GetGitOps implements ToolDependencies.

func (BaseDeps) GetRawClient

func (d BaseDeps) GetRawClient(_ context.Context) (*raw.Client, error)

GetRawClient implements ToolDependencies.

func (BaseDeps) GetRepoAccessCache

func (d BaseDeps) GetRepoAccessCache(_ context.Context) (*lockdown.RepoAccessCache, error)

GetRepoAccessCache implements ToolDependencies.

func (BaseDeps) GetRepoPaths

func (d BaseDeps) GetRepoPaths() []string

GetRepoPaths implements ToolDependencies.

func (BaseDeps) GetT

GetT implements ToolDependencies.

func (BaseDeps) IsFeatureEnabled

func (d BaseDeps) IsFeatureEnabled(ctx context.Context, flagName string) bool

IsFeatureEnabled checks if a feature flag is enabled. Returns false if the feature checker is nil, flag name is empty, or an error occurs. This allows tools to conditionally change behavior based on feature flags.

type BasicNoOrder

type BasicNoOrder struct {
	Repository struct {
		Discussions DiscussionFragment `graphql:"discussions(first: $first, after: $after)"`
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

func (*BasicNoOrder) GetDiscussionFragment

func (q *BasicNoOrder) GetDiscussionFragment() DiscussionFragment

Implement the interface for all query types

type BasicWithOrder

type BasicWithOrder struct {
	Repository struct {
		Discussions DiscussionFragment `graphql:"discussions(first: $first, after: $after, orderBy: { field: $orderByField, direction: $orderByDirection })"`
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

func (*BasicWithOrder) GetDiscussionFragment

func (q *BasicWithOrder) GetDiscussionFragment() DiscussionFragment

type CloseIssueInput

type CloseIssueInput struct {
	IssueID          githubv4.ID             `json:"issueId"`
	ClientMutationID *githubv4.String        `json:"clientMutationId,omitempty"`
	StateReason      *IssueClosedStateReason `json:"stateReason,omitempty"`
	DuplicateIssueID *githubv4.ID            `json:"duplicateIssueId,omitempty"`
}

CloseIssueInput represents the input for closing an issue via the GraphQL API. Used to extend the functionality of the githubv4 library to support closing issues as duplicates.

type CompleteHandler

type CompleteHandler func(ctx context.Context, client *github.Client, resolved map[string]string, argValue string) ([]string, error)

CompleteHandler defines function signature for completion handlers

type CreateProjectV2StatusUpdateInput

type CreateProjectV2StatusUpdateInput struct {
	ProjectID        githubv4.ID      `json:"projectId"`
	Body             *githubv4.String `json:"body,omitempty"`
	Status           *githubv4.String `json:"status,omitempty"`
	StartDate        *githubv4.String `json:"startDate,omitempty"`
	TargetDate       *githubv4.String `json:"targetDate,omitempty"`
	ClientMutationID *githubv4.String `json:"clientMutationId,omitempty"`
}

CreateProjectV2StatusUpdateInput is the input for the createProjectV2StatusUpdate mutation. Defined locally because the shurcooL/githubv4 library does not include this type.

type CursorPaginationParams

type CursorPaginationParams struct {
	PerPage int
	After   string
}

func OptionalCursorPaginationParams

func OptionalCursorPaginationParams(args map[string]any) (CursorPaginationParams, error)

OptionalCursorPaginationParams returns the "perPage" and "after" parameters from the request, without the "page" parameter, suitable for cursor-based pagination only.

func (CursorPaginationParams) ToGraphQLParams

func (p CursorPaginationParams) ToGraphQLParams() (*GraphQLPaginationParams, error)

ToGraphQLParams converts cursor pagination parameters to GraphQL-specific parameters.

type DiscussionFragment

type DiscussionFragment struct {
	Nodes      []NodeFragment
	PageInfo   PageInfoFragment
	TotalCount githubv4.Int
}

type DiscussionQueryResult

type DiscussionQueryResult interface {
	GetDiscussionFragment() DiscussionFragment
}

Common interface for all discussion query types

type DynamicToolDependencies

type DynamicToolDependencies struct {
	// Server is the MCP server to register tools with
	Server *mcp.Server
	// Inventory contains all available tools, resources and prompts that can be enabled dynamically
	Inventory *inventory.Inventory
	// ToolDeps are the dependencies passed to tools when they are registered
	ToolDeps any
	// T is the translation helper function
	T translations.TranslationHelperFunc
}

DynamicToolDependencies contains dependencies for dynamic toolset management tools. It includes the managed Inventory, the server for registration, and the deps that will be passed to tools when they are dynamically enabled.

type FeatureFlags

type FeatureFlags struct {
	LockdownMode bool
	InsidersMode bool
}

FeatureFlags defines runtime feature toggles that adjust tool behavior.

type GetClientFn

type GetClientFn func(context.Context) (*github.Client, error)

type GetGQLClientFn

type GetGQLClientFn func(context.Context) (*githubv4.Client, error)

type GraphQLPaginationParams

type GraphQLPaginationParams struct {
	First *int32
	After *string
}

type IssueClosedStateReason

type IssueClosedStateReason string

IssueClosedStateReason represents the reason an issue was closed. Used to extend the functionality of the githubv4 library to support closing issues as duplicates.

const (
	IssueClosedStateReasonCompleted  IssueClosedStateReason = "COMPLETED"
	IssueClosedStateReasonDuplicate  IssueClosedStateReason = "DUPLICATE"
	IssueClosedStateReasonNotPlanned IssueClosedStateReason = "NOT_PLANNED"
)

type IssueFragment

type IssueFragment struct {
	Number     githubv4.Int
	Title      githubv4.String
	Body       githubv4.String
	State      githubv4.String
	DatabaseID int64

	Author struct {
		Login githubv4.String
	}
	CreatedAt githubv4.DateTime
	UpdatedAt githubv4.DateTime
	Labels    struct {
		Nodes []struct {
			Name        githubv4.String
			ID          githubv4.String
			Description githubv4.String
		}
	} `graphql:"labels(first: 100)"`
	Comments struct {
		TotalCount githubv4.Int
	} `graphql:"comments"`
}

IssueFragment represents a fragment of an issue node in the GraphQL API.

type IssueQueryFragment

type IssueQueryFragment struct {
	Nodes    []IssueFragment `graphql:"nodes"`
	PageInfo struct {
		HasNextPage     githubv4.Boolean
		HasPreviousPage githubv4.Boolean
		StartCursor     githubv4.String
		EndCursor       githubv4.String
	}
	TotalCount int
}

type IssueQueryResult

type IssueQueryResult interface {
	GetIssueFragment() IssueQueryFragment
}

Common interface for all issue query types

type ListIssuesQuery

type ListIssuesQuery struct {
	Repository struct {
		Issues IssueQueryFragment `graphql:"issues(first: $first, after: $after, states: $states, orderBy: {field: $orderBy, direction: $direction})"`
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

ListIssuesQuery is the root query structure for fetching issues with optional label filtering.

func (*ListIssuesQuery) GetIssueFragment

func (q *ListIssuesQuery) GetIssueFragment() IssueQueryFragment

type ListIssuesQueryTypeWithLabels

type ListIssuesQueryTypeWithLabels struct {
	Repository struct {
		Issues IssueQueryFragment `` /* 131-byte string literal not displayed */
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

ListIssuesQueryTypeWithLabels is the query structure for fetching issues with optional label filtering.

func (*ListIssuesQueryTypeWithLabels) GetIssueFragment

func (q *ListIssuesQueryTypeWithLabels) GetIssueFragment() IssueQueryFragment

Implement the interface for all query types

type ListIssuesQueryTypeWithLabelsWithSince

type ListIssuesQueryTypeWithLabelsWithSince struct {
	Repository struct {
		Issues IssueQueryFragment `` /* 158-byte string literal not displayed */
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

ListIssuesQueryTypeWithLabelsWithSince is the query structure for fetching issues with both label and since filtering.

func (*ListIssuesQueryTypeWithLabelsWithSince) GetIssueFragment

type ListIssuesQueryWithSince

type ListIssuesQueryWithSince struct {
	Repository struct {
		Issues IssueQueryFragment `` /* 141-byte string literal not displayed */
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

ListIssuesQueryWithSince is the query structure for fetching issues without label filtering but with since filtering.

func (*ListIssuesQueryWithSince) GetIssueFragment

func (q *ListIssuesQueryWithSince) GetIssueFragment() IssueQueryFragment

type MCPServerConfig

type MCPServerConfig struct {
	// Version of the server
	Version string

	// GitHub Host to target for API requests (e.g. github.com or github.enterprise.com)
	Host string

	// GitHub Token to authenticate with the GitHub API
	Token string

	// EnabledToolsets is a list of toolsets to enable
	// See: https://github.com/aifity/omnigit-mcp?tab=readme-ov-file#tool-configuration
	EnabledToolsets []string

	// EnabledTools is a list of specific tools to enable (additive to toolsets)
	// When specified, these tools are registered in addition to any specified toolset tools
	EnabledTools []string

	// EnabledFeatures is a list of feature flags that are enabled
	// Items with FeatureFlagEnable matching an entry in this list will be available
	EnabledFeatures []string

	// Whether to enable dynamic toolsets
	// See: https://github.com/aifity/omnigit-mcp?tab=readme-ov-file#dynamic-tool-discovery
	DynamicToolsets bool

	// ReadOnly indicates if we should only offer read-only tools
	ReadOnly bool

	// Translator provides translated text for the server tooling
	Translator translations.TranslationHelperFunc

	// Content window size
	ContentWindowSize int

	// LockdownMode indicates if we should enable lockdown mode
	LockdownMode bool

	// InsidersMode indicates if we should enable experimental features
	InsidersMode bool

	// Logger is used for logging within the server
	Logger *slog.Logger
	// RepoAccessTTL overrides the default TTL for repository access cache entries.
	RepoAccessTTL *time.Duration

	// ExcludeTools is a list of tool names that should be disabled regardless of
	// other configuration. These tools will be excluded even if their toolset is enabled
	// or they are explicitly listed in EnabledTools.
	ExcludeTools []string

	// TokenScopes contains the OAuth scopes available to the token.
	// When non-nil, tools requiring scopes not in this list will be hidden.
	// This is used for PAT scope filtering where we can't issue scope challenges.
	TokenScopes []string

	// Additional server options to apply
	ServerOptions []MCPServerOption
}

type MCPServerOption

type MCPServerOption func(*mcp.ServerOptions)

type MinimalBranch

type MinimalBranch struct {
	Name      string `json:"name"`
	SHA       string `json:"sha"`
	Protected bool   `json:"protected"`
}

MinimalBranch is the trimmed output type for branch objects.

type MinimalCommit

type MinimalCommit struct {
	SHA       string              `json:"sha"`
	HTMLURL   string              `json:"html_url"`
	Commit    *MinimalCommitInfo  `json:"commit,omitempty"`
	Author    *MinimalUser        `json:"author,omitempty"`
	Committer *MinimalUser        `json:"committer,omitempty"`
	Stats     *MinimalCommitStats `json:"stats,omitempty"`
	Files     []MinimalCommitFile `json:"files,omitempty"`
}

MinimalCommit is the trimmed output type for commit objects.

type MinimalCommitAuthor

type MinimalCommitAuthor struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
	Date  string `json:"date,omitempty"`
}

MinimalCommitAuthor represents commit author information.

type MinimalCommitFile

type MinimalCommitFile struct {
	Filename  string `json:"filename"`
	Status    string `json:"status,omitempty"`
	Additions int    `json:"additions,omitempty"`
	Deletions int    `json:"deletions,omitempty"`
	Changes   int    `json:"changes,omitempty"`
}

MinimalCommitFile represents a file changed in a commit.

type MinimalCommitInfo

type MinimalCommitInfo struct {
	Message   string               `json:"message"`
	Author    *MinimalCommitAuthor `json:"author,omitempty"`
	Committer *MinimalCommitAuthor `json:"committer,omitempty"`
}

MinimalCommitInfo represents core commit information.

type MinimalCommitStats

type MinimalCommitStats struct {
	Additions int `json:"additions,omitempty"`
	Deletions int `json:"deletions,omitempty"`
	Total     int `json:"total,omitempty"`
}

MinimalCommitStats represents commit statistics.

type MinimalFileCommit

type MinimalFileCommit struct {
	SHA     string               `json:"sha"`
	Message string               `json:"message,omitempty"`
	HTMLURL string               `json:"html_url,omitempty"`
	Author  *MinimalCommitAuthor `json:"author,omitempty"`
}

MinimalFileCommit is the trimmed commit portion of a file operation response.

type MinimalFileContent

type MinimalFileContent struct {
	Name    string `json:"name"`
	Path    string `json:"path"`
	SHA     string `json:"sha"`
	Size    int    `json:"size,omitempty"`
	HTMLURL string `json:"html_url"`
}

MinimalFileContent is the trimmed content portion of a file operation response.

type MinimalFileContentResponse

type MinimalFileContentResponse struct {
	Content *MinimalFileContent `json:"content,omitempty"`
	Commit  *MinimalFileCommit  `json:"commit,omitempty"`
}

MinimalFileContentResponse is the trimmed output type for create/update/delete file responses.

type MinimalIssue

type MinimalIssue struct {
	Number            int               `json:"number"`
	Title             string            `json:"title"`
	Body              string            `json:"body,omitempty"`
	State             string            `json:"state"`
	StateReason       string            `json:"state_reason,omitempty"`
	Draft             bool              `json:"draft,omitempty"`
	Locked            bool              `json:"locked,omitempty"`
	HTMLURL           string            `json:"html_url"`
	User              *MinimalUser      `json:"user,omitempty"`
	AuthorAssociation string            `json:"author_association,omitempty"`
	Labels            []string          `json:"labels,omitempty"`
	Assignees         []string          `json:"assignees,omitempty"`
	Milestone         string            `json:"milestone,omitempty"`
	Comments          int               `json:"comments,omitempty"`
	Reactions         *MinimalReactions `json:"reactions,omitempty"`
	CreatedAt         string            `json:"created_at,omitempty"`
	UpdatedAt         string            `json:"updated_at,omitempty"`
	ClosedAt          string            `json:"closed_at,omitempty"`
	ClosedBy          string            `json:"closed_by,omitempty"`
	IssueType         string            `json:"issue_type,omitempty"`
}

MinimalIssue is the trimmed output type for issue objects to reduce verbosity.

type MinimalIssueComment

type MinimalIssueComment struct {
	ID                int64             `json:"id"`
	Body              string            `json:"body,omitempty"`
	HTMLURL           string            `json:"html_url"`
	User              *MinimalUser      `json:"user,omitempty"`
	AuthorAssociation string            `json:"author_association,omitempty"`
	Reactions         *MinimalReactions `json:"reactions,omitempty"`
	CreatedAt         string            `json:"created_at,omitempty"`
	UpdatedAt         string            `json:"updated_at,omitempty"`
}

MinimalIssueComment is the trimmed output type for issue comment objects to reduce verbosity.

type MinimalPRBranch

type MinimalPRBranch struct {
	Ref  string               `json:"ref"`
	SHA  string               `json:"sha"`
	Repo *MinimalPRBranchRepo `json:"repo,omitempty"`
}

MinimalPRBranch is the trimmed output type for pull request branch references.

type MinimalPRBranchRepo

type MinimalPRBranchRepo struct {
	FullName    string `json:"full_name"`
	Description string `json:"description,omitempty"`
}

MinimalPRBranchRepo is the trimmed repo info nested inside a PR branch.

type MinimalProject

type MinimalProject struct {
	ID               *int64            `json:"id,omitempty"`
	NodeID           *string           `json:"node_id,omitempty"`
	Owner            *MinimalUser      `json:"owner,omitempty"`
	Creator          *MinimalUser      `json:"creator,omitempty"`
	Title            *string           `json:"title,omitempty"`
	Description      *string           `json:"description,omitempty"`
	Public           *bool             `json:"public,omitempty"`
	ClosedAt         *github.Timestamp `json:"closed_at,omitempty"`
	CreatedAt        *github.Timestamp `json:"created_at,omitempty"`
	UpdatedAt        *github.Timestamp `json:"updated_at,omitempty"`
	DeletedAt        *github.Timestamp `json:"deleted_at,omitempty"`
	Number           *int              `json:"number,omitempty"`
	ShortDescription *string           `json:"short_description,omitempty"`
	DeletedBy        *MinimalUser      `json:"deleted_by,omitempty"`
	OwnerType        string            `json:"owner_type,omitempty"`
}

type MinimalProjectStatusUpdate

type MinimalProjectStatusUpdate struct {
	ID         string       `json:"id"`
	Body       string       `json:"body,omitempty"`
	Status     string       `json:"status,omitempty"`
	CreatedAt  string       `json:"created_at,omitempty"`
	StartDate  string       `json:"start_date,omitempty"`
	TargetDate string       `json:"target_date,omitempty"`
	Creator    *MinimalUser `json:"creator,omitempty"`
}

type MinimalPullRequest

type MinimalPullRequest struct {
	Number             int              `json:"number"`
	Title              string           `json:"title"`
	Body               string           `json:"body,omitempty"`
	State              string           `json:"state"`
	Draft              bool             `json:"draft"`
	Merged             bool             `json:"merged"`
	MergeableState     string           `json:"mergeable_state,omitempty"`
	HTMLURL            string           `json:"html_url"`
	User               *MinimalUser     `json:"user,omitempty"`
	Labels             []string         `json:"labels,omitempty"`
	Assignees          []string         `json:"assignees,omitempty"`
	RequestedReviewers []string         `json:"requested_reviewers,omitempty"`
	MergedBy           string           `json:"merged_by,omitempty"`
	Head               *MinimalPRBranch `json:"head,omitempty"`
	Base               *MinimalPRBranch `json:"base,omitempty"`
	Additions          int              `json:"additions,omitempty"`
	Deletions          int              `json:"deletions,omitempty"`
	ChangedFiles       int              `json:"changed_files,omitempty"`
	Commits            int              `json:"commits,omitempty"`
	Comments           int              `json:"comments,omitempty"`
	CreatedAt          string           `json:"created_at,omitempty"`
	UpdatedAt          string           `json:"updated_at,omitempty"`
	ClosedAt           string           `json:"closed_at,omitempty"`
	MergedAt           string           `json:"merged_at,omitempty"`
	Milestone          string           `json:"milestone,omitempty"`
}

MinimalPullRequest is the trimmed output type for pull request objects to reduce verbosity.

type MinimalReactions

type MinimalReactions struct {
	TotalCount int `json:"total_count"`
	PlusOne    int `json:"+1"`
	MinusOne   int `json:"-1"`
	Laugh      int `json:"laugh"`
	Confused   int `json:"confused"`
	Heart      int `json:"heart"`
	Hooray     int `json:"hooray"`
	Rocket     int `json:"rocket"`
	Eyes       int `json:"eyes"`
}

MinimalReactions is the trimmed output type for reaction summaries, dropping the API URL.

type MinimalRelease

type MinimalRelease struct {
	ID          int64        `json:"id"`
	TagName     string       `json:"tag_name"`
	Name        string       `json:"name,omitempty"`
	Body        string       `json:"body,omitempty"`
	HTMLURL     string       `json:"html_url"`
	PublishedAt string       `json:"published_at,omitempty"`
	Prerelease  bool         `json:"prerelease"`
	Draft       bool         `json:"draft"`
	Author      *MinimalUser `json:"author,omitempty"`
}

MinimalRelease is the trimmed output type for release objects.

type MinimalRepository

type MinimalRepository struct {
	ID            int64    `json:"id"`
	Name          string   `json:"name"`
	FullName      string   `json:"full_name"`
	Description   string   `json:"description,omitempty"`
	HTMLURL       string   `json:"html_url"`
	Language      string   `json:"language,omitempty"`
	Stars         int      `json:"stargazers_count"`
	Forks         int      `json:"forks_count"`
	OpenIssues    int      `json:"open_issues_count"`
	UpdatedAt     string   `json:"updated_at,omitempty"`
	CreatedAt     string   `json:"created_at,omitempty"`
	Topics        []string `json:"topics,omitempty"`
	Private       bool     `json:"private"`
	Fork          bool     `json:"fork"`
	Archived      bool     `json:"archived"`
	DefaultBranch string   `json:"default_branch,omitempty"`
}

MinimalRepository is the trimmed output type for repository objects to reduce verbosity.

type MinimalResponse

type MinimalResponse struct {
	ID  string `json:"id"`
	URL string `json:"url"`
}

MinimalResponse represents a minimal response for all CRUD operations. Success is implicit in the HTTP response status, and all other information can be derived from the URL or fetched separately if needed.

type MinimalSearchRepositoriesResult

type MinimalSearchRepositoriesResult struct {
	TotalCount        int                 `json:"total_count"`
	IncompleteResults bool                `json:"incomplete_results"`
	Items             []MinimalRepository `json:"items"`
}

MinimalSearchRepositoriesResult is the trimmed output type for repository search results.

type MinimalSearchUsersResult

type MinimalSearchUsersResult struct {
	TotalCount        int           `json:"total_count"`
	IncompleteResults bool          `json:"incomplete_results"`
	Items             []MinimalUser `json:"items"`
}

MinimalSearchUsersResult is the trimmed output type for user search results.

type MinimalUser

type MinimalUser struct {
	Login      string       `json:"login"`
	ID         int64        `json:"id,omitempty"`
	ProfileURL string       `json:"profile_url,omitempty"`
	AvatarURL  string       `json:"avatar_url,omitempty"`
	Details    *UserDetails `json:"details,omitempty"` // Optional field for additional user details
}

MinimalUser is the output type for user and organization search results.

type NodeFragment

type NodeFragment struct {
	Number         githubv4.Int
	Title          githubv4.String
	CreatedAt      githubv4.DateTime
	UpdatedAt      githubv4.DateTime
	Closed         githubv4.Boolean
	IsAnswered     githubv4.Boolean
	AnswerChosenAt *githubv4.DateTime
	Author         struct {
		Login githubv4.String
	}
	Category struct {
		Name githubv4.String
	} `graphql:"category"`
	URL githubv4.String `graphql:"url"`
}

type OrganizationTeams

type OrganizationTeams struct {
	Org   string     `json:"org"`
	Teams []TeamInfo `json:"teams"`
}

type PageInfoFragment

type PageInfoFragment struct {
	HasNextPage     bool
	HasPreviousPage bool
	StartCursor     githubv4.String
	EndCursor       githubv4.String
}

type PaginationParams

type PaginationParams struct {
	Page    int
	PerPage int
	After   string
}

func OptionalPaginationParams

func OptionalPaginationParams(args map[string]any) (PaginationParams, error)

OptionalPaginationParams returns the "page", "perPage", and "after" parameters from the request, or their default values if not present, "page" default is 1, "perPage" default is 30. In future, we may want to make the default values configurable, or even have this function returned from `withPagination`, where the defaults are provided alongside the min/max values.

func (PaginationParams) ToGraphQLParams

func (p PaginationParams) ToGraphQLParams() (*GraphQLPaginationParams, error)

ToGraphQLParams converts REST API pagination parameters to GraphQL-specific parameters. This converts page/perPage to first parameter for GraphQL queries. If After is provided, it takes precedence over page-based pagination.

type PollConfig

type PollConfig struct {
	MaxAttempts int
	Delay       time.Duration
}

PollConfig configures the PR polling behavior.

type PullRequestReviewWriteParams

type PullRequestReviewWriteParams struct {
	Method     string
	Owner      string
	Repo       string
	PullNumber int32
	Body       string
	Event      string
	CommitID   *string
}

type ReplaceActorsForAssignableInput

type ReplaceActorsForAssignableInput struct {
	AssignableID githubv4.ID   `json:"assignableId"`
	ActorIDs     []githubv4.ID `json:"actorIds"`
}

type RequestDeps

type RequestDeps struct {
	RepoAccessOpts    []lockdown.RepoAccessOption
	T                 translations.TranslationHelperFunc
	ContentWindowSize int
	// contains filtered or unexported fields
}

func NewRequestDeps

func NewRequestDeps(
	apiHosts utils.APIHostResolver,
	version string,
	lockdownMode bool,
	repoAccessOpts []lockdown.RepoAccessOption,
	t translations.TranslationHelperFunc,
	contentWindowSize int,
	featureChecker inventory.FeatureFlagChecker,
) *RequestDeps

NewRequestDeps creates a RequestDeps with the provided clients and configuration.

func (*RequestDeps) GetClient

func (d *RequestDeps) GetClient(ctx context.Context) (*gogithub.Client, error)

GetClient implements ToolDependencies.

func (*RequestDeps) GetContentWindowSize

func (d *RequestDeps) GetContentWindowSize() int

GetContentWindowSize implements ToolDependencies.

func (*RequestDeps) GetFlags

func (d *RequestDeps) GetFlags(ctx context.Context) FeatureFlags

GetFlags implements ToolDependencies.

func (*RequestDeps) GetGQLClient

func (d *RequestDeps) GetGQLClient(ctx context.Context) (*githubv4.Client, error)

GetGQLClient implements ToolDependencies.

func (*RequestDeps) GetGitOps

func (d *RequestDeps) GetGitOps() gitops.GitOperations

GetGitOps implements ToolDependencies. RequestDeps doesn't support git operations - returns nil.

func (*RequestDeps) GetRawClient

func (d *RequestDeps) GetRawClient(ctx context.Context) (*raw.Client, error)

GetRawClient implements ToolDependencies.

func (*RequestDeps) GetRepoAccessCache

func (d *RequestDeps) GetRepoAccessCache(ctx context.Context) (*lockdown.RepoAccessCache, error)

GetRepoAccessCache implements ToolDependencies.

func (*RequestDeps) GetRepoPaths

func (d *RequestDeps) GetRepoPaths() []string

GetRepoPaths implements ToolDependencies. RequestDeps doesn't support git operations - returns empty slice.

func (*RequestDeps) GetT

GetT implements ToolDependencies.

func (*RequestDeps) IsFeatureEnabled

func (d *RequestDeps) IsFeatureEnabled(ctx context.Context, flagName string) bool

IsFeatureEnabled checks if a feature flag is enabled.

type TeamInfo

type TeamInfo struct {
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Description string `json:"description"`
}

type ToolDependencies

type ToolDependencies interface {
	// GetClient returns a GitHub REST API client
	GetClient(ctx context.Context) (*gogithub.Client, error)

	// GetGQLClient returns a GitHub GraphQL client
	GetGQLClient(ctx context.Context) (*githubv4.Client, error)

	// GetRawClient returns a raw content client for GitHub
	GetRawClient(ctx context.Context) (*raw.Client, error)

	// GetRepoAccessCache returns the lockdown mode repo access cache
	GetRepoAccessCache(ctx context.Context) (*lockdown.RepoAccessCache, error)

	// GetT returns the translation helper function
	GetT() translations.TranslationHelperFunc

	// GetFlags returns feature flags
	GetFlags(ctx context.Context) FeatureFlags

	// GetContentWindowSize returns the content window size for log truncation
	GetContentWindowSize() int

	// IsFeatureEnabled checks if a feature flag is enabled.
	IsFeatureEnabled(ctx context.Context, flagName string) bool

	// GetGitOps returns the git operations implementation for local git tools
	GetGitOps() gitops.GitOperations

	// GetRepoPaths returns the list of allowed repository paths for local git operations
	GetRepoPaths() []string
}

ToolDependencies defines the interface for dependencies that tool handlers need. This is an interface to allow different implementations:

  • Local server: stores closures that create clients on demand
  • Remote server: can store pre-created clients per-request for efficiency

The toolsets package uses `any` for deps and tool handlers type-assert to this interface.

func DepsFromContext

func DepsFromContext(ctx context.Context) (ToolDependencies, bool)

DepsFromContext retrieves ToolDependencies from the context. Returns the deps and true if found, or nil and false if not present. Use MustDepsFromContext if you want to panic on missing deps (for handlers that require deps to function).

func MustDepsFromContext

func MustDepsFromContext(ctx context.Context) ToolDependencies

MustDepsFromContext retrieves ToolDependencies from the context. Panics if deps are not found - use this in handlers where deps are required.

type TreeEntryResponse

type TreeEntryResponse struct {
	Path string `json:"path"`
	Type string `json:"type"`
	Size *int   `json:"size,omitempty"`
	Mode string `json:"mode"`
	SHA  string `json:"sha"`
	URL  string `json:"url"`
}

TreeEntryResponse represents a single entry in a Git tree.

type TreeResponse

type TreeResponse struct {
	SHA       string              `json:"sha"`
	Truncated bool                `json:"truncated"`
	Tree      []TreeEntryResponse `json:"tree"`
	TreeSHA   string              `json:"tree_sha"`
	Owner     string              `json:"owner"`
	Repo      string              `json:"repo"`
	Recursive bool                `json:"recursive"`
	Count     int                 `json:"count"`
}

TreeResponse represents the response structure for a Git tree.

type UpdateIssueInput

type UpdateIssueInput struct {
	ID              githubv4.ID           `json:"id"`
	AssigneeIDs     []githubv4.ID         `json:"assigneeIds"`
	AgentAssignment *AgentAssignmentInput `json:"agentAssignment,omitempty"`
}

UpdateIssueInput represents the input for updating an issue with agent assignment.

type UserDetails

type UserDetails struct {
	Name              string    `json:"name,omitempty"`
	Company           string    `json:"company,omitempty"`
	Blog              string    `json:"blog,omitempty"`
	Location          string    `json:"location,omitempty"`
	Email             string    `json:"email,omitempty"`
	Hireable          bool      `json:"hireable,omitempty"`
	Bio               string    `json:"bio,omitempty"`
	TwitterUsername   string    `json:"twitter_username,omitempty"`
	PublicRepos       int       `json:"public_repos"`
	PublicGists       int       `json:"public_gists"`
	Followers         int       `json:"followers"`
	Following         int       `json:"following"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
	PrivateGists      int       `json:"private_gists,omitempty"`
	TotalPrivateRepos int64     `json:"total_private_repos,omitempty"`
	OwnedPrivateRepos int64     `json:"owned_private_repos,omitempty"`
}

UserDetails contains additional fields about a GitHub user not already present in MinimalUser. Used by get_me context tool but omitted from search_users.

type WithCategoryAndOrder

type WithCategoryAndOrder struct {
	Repository struct {
		Discussions DiscussionFragment `` /* 141-byte string literal not displayed */
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

func (*WithCategoryAndOrder) GetDiscussionFragment

func (q *WithCategoryAndOrder) GetDiscussionFragment() DiscussionFragment

type WithCategoryNoOrder

type WithCategoryNoOrder struct {
	Repository struct {
		Discussions DiscussionFragment `graphql:"discussions(first: $first, after: $after, categoryId: $categoryId)"`
	} `graphql:"repository(owner: $owner, name: $repo)"`
}

func (*WithCategoryNoOrder) GetDiscussionFragment

func (q *WithCategoryNoOrder) GetDiscussionFragment() DiscussionFragment

Jump to

Keyboard shortcuts

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