utils

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingAuthorizationHeader     = fmt.Errorf("%w: missing required Authorization header", mark.ErrBadRequest)
	ErrBadAuthorizationHeader         = fmt.Errorf("%w: Authorization header is badly formatted", mark.ErrBadRequest)
	ErrUnsupportedAuthorizationHeader = fmt.Errorf("%w: unsupported Authorization header", mark.ErrBadRequest)
)

Functions

func NewToolResultAwaitingFormSubmission

func NewToolResultAwaitingFormSubmission(message string) *mcp.CallToolResult

NewToolResultAwaitingFormSubmission signals to the agent that a tool call has been intercepted to show an MCP App form to the user and has NOT performed the requested operation. The agent must stop, not chain dependent tool calls, and not claim the operation succeeded. The result is marked IsError=true so agents that bail on error don't proceed; the host still renders the UI because rendering is keyed off the tool's _meta.ui, not the result. The MCP App form will submit the operation directly when the user clicks submit, after which a ui/update-model-context call delivers the real outcome to the agent.

func NewToolResultError

func NewToolResultError(message string) *mcp.CallToolResult

func NewToolResultErrorFromErr

func NewToolResultErrorFromErr(message string, err error) *mcp.CallToolResult

func NewToolResultResource

func NewToolResultResource(message string, contents *mcp.ResourceContents) *mcp.CallToolResult
func NewToolResultResourceLink(message string, link *mcp.ResourceLink) *mcp.CallToolResult

func NewToolResultText

func NewToolResultText(message string) *mcp.CallToolResult

Types

type APIHost

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

func (APIHost) AuthorizationServerURL

func (a APIHost) AuthorizationServerURL(_ context.Context) (*url.URL, error)

func (APIHost) BaseRESTURL

func (a APIHost) BaseRESTURL(_ context.Context) (*url.URL, error)

APIHostResolver implementation

func (APIHost) GraphqlURL

func (a APIHost) GraphqlURL(_ context.Context) (*url.URL, error)

func (APIHost) RawURL

func (a APIHost) RawURL(_ context.Context) (*url.URL, error)

func (APIHost) UploadURL

func (a APIHost) UploadURL(_ context.Context) (*url.URL, error)

type APIHostResolver

type APIHostResolver interface {
	BaseRESTURL(ctx context.Context) (*url.URL, error)
	GraphqlURL(ctx context.Context) (*url.URL, error)
	UploadURL(ctx context.Context) (*url.URL, error)
	RawURL(ctx context.Context) (*url.URL, error)
	AuthorizationServerURL(ctx context.Context) (*url.URL, error)
}

func NewAPIHost

func NewAPIHost(s string) (APIHostResolver, error)

type HostType

type HostType int

HostType identifies which GitHub deployment a host refers to. Tools use this to skip capabilities that only exist on some deployments.

const (
	HostTypeDotcom HostType = iota
	HostTypeGHEC
	HostTypeGHES
)

func ParseHostType

func ParseHostType(s string) (HostType, error)

ParseHostType classifies a host string. An empty string means github.com, matching NewAPIHost. It returns an error only when the string is not a URL with a scheme.

type TokenType

type TokenType int
const (
	TokenTypeUnknown TokenType = iota
	TokenTypePersonalAccessToken
	TokenTypeFineGrainedPersonalAccessToken
	TokenTypeOAuthAccessToken
	TokenTypeUserToServerGitHubAppToken
	TokenTypeServerToServerGitHubAppToken
)

func ParseAuthorizationHeader

func ParseAuthorizationHeader(req *http.Request) (tokenType TokenType, token string, _ error)

ParseAuthorizationHeader parses the Authorization header from the HTTP request

Jump to

Keyboard shortcuts

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