Thanks to visit codestin.com
Credit goes to pkg.go.dev

http

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGitHubMCPServerFactory

func DefaultGitHubMCPServerFactory(r *http.Request, deps github.ToolDependencies, inventory *inventory.Inventory, cfg *github.MCPServerConfig) (*mcp.Server, error)

func InventoryFiltersForRequest

func InventoryFiltersForRequest(r *http.Request, builder *inventory.Builder) *inventory.Builder

InventoryFiltersForRequest applies filters to the inventory builder based on the request context and headers. MCP Apps UI metadata is handled by the builder via the feature checker — no need to check headers here.

func PATScopeFilter

func PATScopeFilter(b *inventory.Builder, r *http.Request, fetcher scopes.FetcherInterface) *inventory.Builder

func RunHTTPServer

func RunHTTPServer(cfg ServerConfig) error

Types

type GitHubMCPServerFactoryFunc

type GitHubMCPServerFactoryFunc func(r *http.Request, deps github.ToolDependencies, inventory *inventory.Inventory, cfg *github.MCPServerConfig) (*mcp.Server, error)

GitHubMCPServerFactoryFunc is a function type for creating a new MCP Server instance. middleware are applied AFTER the default GitHub MCP Server middlewares (like error context injection)

type Handler

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

func (*Handler) RegisterMiddleware

func (h *Handler) RegisterMiddleware(r chi.Router)

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(r chi.Router)

RegisterRoutes registers the routes for the MCP server URL-based values take precedence over header-based values

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HandlerOption

type HandlerOption func(*HandlerOptions)

func WithFeatureChecker

func WithFeatureChecker(checker inventory.FeatureFlagChecker) HandlerOption

func WithGitHubMCPServerFactory

func WithGitHubMCPServerFactory(f GitHubMCPServerFactoryFunc) HandlerOption

func WithInventoryFactory

func WithInventoryFactory(f InventoryFactoryFunc) HandlerOption

func WithOAuthConfig

func WithOAuthConfig(cfg *oauth.Config) HandlerOption

func WithScopeFetcher

func WithScopeFetcher(f scopes.FetcherInterface) HandlerOption

type HandlerOptions

type HandlerOptions struct {
	GitHubMcpServerFactory GitHubMCPServerFactoryFunc
	InventoryFactory       InventoryFactoryFunc
	OAuthConfig            *oauth.Config
	ScopeFetcher           scopes.FetcherInterface
	FeatureChecker         inventory.FeatureFlagChecker
}

type InventoryFactoryFunc

type InventoryFactoryFunc func(r *http.Request) (*inventory.Inventory, error)

func DefaultInventoryFactory

func DefaultInventoryFactory(cfg *ServerConfig, t translations.TranslationHelperFunc, featureChecker inventory.FeatureFlagChecker, scopeFetcher scopes.FetcherInterface) InventoryFactoryFunc

DefaultInventoryFactory creates the default inventory factory for HTTP mode. When the ServerConfig includes static flags (--toolsets, --read-only, etc.), a static inventory is built once at factory creation to pre-filter the tool universe. Per-request headers can only narrow within these bounds.

type ServerConfig

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

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

	// Port to listen on (default: 8082)
	Port int

	// BaseURL is the publicly accessible URL of this server for OAuth resource metadata.
	// If not set, the server will derive the URL from incoming request headers.
	BaseURL string

	// ResourcePath is the externally visible base path for this server (e.g., "/mcp").
	// This is used to restore the original path when a proxy strips a base path before forwarding.
	ResourcePath string

	// ExportTranslations indicates if we should export translations
	// See: https://github.com/github/github-mcp-server?tab=readme-ov-file#i18n--overriding-descriptions
	ExportTranslations bool

	// EnableCommandLogging indicates if we should log commands
	EnableCommandLogging bool

	// Path to the log file if not stderr
	LogFilePath string

	// Content window size
	ContentWindowSize int

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

	// RepoAccessCacheTTL overrides the default TTL for repository access cache entries.
	RepoAccessCacheTTL *time.Duration

	// ScopeChallenge indicates if we should return OAuth scope challenges, and if we should perform
	// tool filtering based on token scopes.
	ScopeChallenge bool

	// ReadOnly indicates if we should only register read-only tools.
	// When set via CLI flag, this acts as an upper bound — per-request headers
	// cannot re-enable write tools.
	ReadOnly bool

	// EnabledToolsets is a list of toolsets to enable.
	// When set via CLI flag, per-request headers can only narrow within these toolsets.
	EnabledToolsets []string

	// EnabledTools is a list of specific tools to enable (additive to toolsets).
	EnabledTools []string

	// DynamicToolsets enables dynamic toolset discovery mode.
	DynamicToolsets bool

	// ExcludeTools is a list of tool names to disable regardless of other settings.
	// When set via CLI flag, per-request headers cannot re-include these tools.
	ExcludeTools []string

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

Directories

Path Synopsis
Package mark provides a mechanism for tagging errors with a well-known error value.
Package mark provides a mechanism for tagging errors with a well-known error value.
Package oauth provides OAuth 2.0 Protected Resource Metadata (RFC 9728) support for the GitHub MCP Server HTTP mode.
Package oauth provides OAuth 2.0 Protected Resource Metadata (RFC 9728) support for the GitHub MCP Server HTTP mode.

Jump to

Keyboard shortcuts

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