mcp

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAuthorizationURL added in v1.9.14

func BuildAuthorizationURL(authEndpoint, clientID, redirectURI, state, codeChallenge, resourceURL string) string

BuildAuthorizationURL builds the OAuth authorization URL with PKCE

func GeneratePKCEVerifier added in v1.9.14

func GeneratePKCEVerifier() string

GeneratePKCEVerifier generates a PKCE code verifier using oauth2 library

func GenerateState added in v1.9.14

func GenerateState() (string, error)

GenerateState generates a random state parameter for OAuth CSRF protection

func RegisterClient added in v1.9.14

func RegisterClient(ctx context.Context, authMetadata *AuthorizationServerMetadata, redirectURI string, scopes []string) (clientID, clientSecret string, err error)

RegisterClient performs dynamic client registration

func RequestAuthorizationCode added in v1.9.14

func RequestAuthorizationCode(ctx context.Context, authURL string, callbackServer *CallbackServer, expectedState string) (string, string, error)

RequestAuthorizationCode requests the user to open the authorization URL and waits for the callback

Types

type AuthorizationServerMetadata added in v1.9.14

type AuthorizationServerMetadata struct {
	Issuer                                 string   `json:"issuer"`
	AuthorizationEndpoint                  string   `json:"authorization_endpoint"`
	TokenEndpoint                          string   `json:"token_endpoint"`
	RegistrationEndpoint                   string   `json:"registration_endpoint,omitempty"`
	RevocationEndpoint                     string   `json:"revocation_endpoint,omitempty"`
	IntrospectionEndpoint                  string   `json:"introspection_endpoint,omitempty"`
	JwksURI                                string   `json:"jwks_uri,omitempty"`
	ScopesSupported                        []string `json:"scopes_supported,omitempty"`
	ResponseTypesSupported                 []string `json:"response_types_supported"`
	ResponseModesSupported                 []string `json:"response_modes_supported,omitempty"`
	GrantTypesSupported                    []string `json:"grant_types_supported,omitempty"`
	TokenEndpointAuthMethodsSupported      []string `json:"token_endpoint_auth_methods_supported,omitempty"`
	RevocationEndpointAuthMethodsSupported []string `json:"revocation_endpoint_auth_methods_supported,omitempty"`
	CodeChallengeMethodsSupported          []string `json:"code_challenge_methods_supported,omitempty"`
}

AuthorizationServerMetadata represents OAuth 2.0 Authorization Server Metadata (RFC 8414)

type CallbackServer added in v1.7.0

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

CallbackServer handles OAuth callback requests

func NewCallbackServer added in v1.7.0

func NewCallbackServer() (*CallbackServer, error)

NewCallbackServer creates a new OAuth callback server

func (*CallbackServer) GetRedirectURI added in v1.7.0

func (cs *CallbackServer) GetRedirectURI() string

func (*CallbackServer) SetExpectedState added in v1.7.0

func (cs *CallbackServer) SetExpectedState(state string)

func (*CallbackServer) Shutdown added in v1.7.0

func (cs *CallbackServer) Shutdown(ctx context.Context) error

func (*CallbackServer) Start added in v1.7.0

func (cs *CallbackServer) Start() error

func (*CallbackServer) WaitForCallback added in v1.7.0

func (cs *CallbackServer) WaitForCallback(ctx context.Context) (code, state string, err error)

type GatewayToolset added in v1.0.7

type GatewayToolset struct {
	*Toolset
	// contains filtered or unexported fields
}

func NewGatewayToolset added in v1.0.7

func NewGatewayToolset(ctx context.Context, name, mcpServerName string, config any, envProvider environment.Provider, cwd string) (*GatewayToolset, error)

func (*GatewayToolset) Stop added in v1.0.7

func (t *GatewayToolset) Stop(ctx context.Context) error

type InMemoryTokenStore added in v1.7.0

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

InMemoryTokenStore implements OAuthTokenStore in memory

func (*InMemoryTokenStore) GetToken added in v1.7.0

func (s *InMemoryTokenStore) GetToken(resourceURL string) (*OAuthToken, error)

func (*InMemoryTokenStore) RemoveToken added in v1.7.0

func (s *InMemoryTokenStore) RemoveToken(resourceURL string) error

func (*InMemoryTokenStore) StoreToken added in v1.7.0

func (s *InMemoryTokenStore) StoreToken(resourceURL string, token *OAuthToken) error

type OAuthToken added in v1.7.0

type OAuthToken struct {
	AccessToken  string    `json:"access_token"`
	TokenType    string    `json:"token_type"`
	ExpiresIn    int       `json:"expires_in,omitempty"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	Scope        string    `json:"scope,omitempty"`
	ExpiresAt    time.Time `json:"expires_at,omitempty"`
}

func ExchangeCodeForToken added in v1.9.14

func ExchangeCodeForToken(ctx context.Context, tokenEndpoint, code, codeVerifier, clientID, clientSecret, redirectURI string) (*OAuthToken, error)

ExchangeCodeForToken exchanges an authorization code for an access token

func (*OAuthToken) IsExpired added in v1.7.0

func (t *OAuthToken) IsExpired() bool

IsExpired checks if the token is expired

type OAuthTokenStore added in v1.7.0

type OAuthTokenStore interface {
	// GetToken retrieves a token for the given resource URL
	GetToken(resourceURL string) (*OAuthToken, error)
	// StoreToken stores a token for the given resource URL
	StoreToken(resourceURL string, token *OAuthToken) error
	// RemoveToken removes a token for the given resource URL
	RemoveToken(resourceURL string) error
}

OAuthTokenStore manages OAuth tokens

func NewInMemoryTokenStore added in v1.7.0

func NewInMemoryTokenStore() OAuthTokenStore

NewInMemoryTokenStore creates a new in-memory token store

type PromptArgument added in v1.9.25

type PromptArgument struct {
	Name        string `json:"name"`        // The name of the argument
	Description string `json:"description"` // Human-readable description of the argument
	Required    bool   `json:"required"`    // Whether this argument is required
}

PromptArgument represents a single argument for an MCP prompt

type PromptInfo added in v1.9.25

type PromptInfo struct {
	Name        string           `json:"name"`        // The prompt name/identifier
	Description string           `json:"description"` // Human-readable description of what this prompt does
	Arguments   []PromptArgument `json:"arguments"`   // List of arguments this prompt accepts
}

PromptInfo contains metadata about an available MCP prompt

type Toolset

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

Toolset represents a set of MCP tools

func NewRemoteToolset added in v1.6.3

func NewRemoteToolset(name, url, transport string, headers map[string]string) *Toolset

NewRemoteToolset creates a new MCP toolset from a remote MCP Server.

func NewToolsetCommand

func NewToolsetCommand(name, command string, args, env []string, cwd string) *Toolset

NewToolsetCommand creates a new MCP toolset from a command.

func (*Toolset) GetPrompt added in v1.9.25

func (ts *Toolset) GetPrompt(ctx context.Context, name string, arguments map[string]string) (*mcp.GetPromptResult, error)

GetPrompt retrieves a specific prompt with provided arguments from the MCP server. This method executes the prompt and returns the result content.

func (*Toolset) Instructions

func (ts *Toolset) Instructions() string

func (*Toolset) ListPrompts added in v1.9.25

func (ts *Toolset) ListPrompts(ctx context.Context) ([]PromptInfo, error)

ListPrompts retrieves available prompts from the MCP server. Returns a slice of PromptInfo containing metadata about each available prompt including name, description, and argument specifications.

func (*Toolset) SetElicitationHandler added in v1.7.0

func (ts *Toolset) SetElicitationHandler(handler tools.ElicitationHandler)

func (*Toolset) SetManagedOAuth added in v1.9.14

func (ts *Toolset) SetManagedOAuth(managed bool)

func (*Toolset) SetOAuthSuccessHandler added in v1.7.0

func (ts *Toolset) SetOAuthSuccessHandler(handler func())

func (*Toolset) Start

func (ts *Toolset) Start(ctx context.Context) error

func (*Toolset) Stop

func (ts *Toolset) Stop(ctx context.Context) error

func (*Toolset) Tools

func (ts *Toolset) Tools(ctx context.Context) ([]tools.Tool, error)

Jump to

Keyboard shortcuts

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