Documentation
¶
Index ¶
- func BuildAuthorizationURL(authEndpoint, clientID, redirectURI, state, codeChallenge, resourceURL string) string
- func GeneratePKCEVerifier() string
- func GenerateState() (string, error)
- func RegisterClient(ctx context.Context, authMetadata *AuthorizationServerMetadata, ...) (clientID, clientSecret string, err error)
- func RequestAuthorizationCode(ctx context.Context, authURL string, callbackServer *CallbackServer, ...) (string, string, error)
- type AuthorizationServerMetadata
- type CallbackServer
- func (cs *CallbackServer) GetRedirectURI() string
- func (cs *CallbackServer) SetExpectedState(state string)
- func (cs *CallbackServer) Shutdown(ctx context.Context) error
- func (cs *CallbackServer) Start() error
- func (cs *CallbackServer) WaitForCallback(ctx context.Context) (code, state string, err error)
- type GatewayToolset
- type InMemoryTokenStore
- type OAuthToken
- type OAuthTokenStore
- type PromptArgument
- type PromptInfo
- type Toolset
- func (ts *Toolset) Describe() string
- func (ts *Toolset) GetPrompt(ctx context.Context, name string, arguments map[string]string) (*mcp.GetPromptResult, error)
- func (ts *Toolset) Instructions() string
- func (ts *Toolset) ListPrompts(ctx context.Context) ([]PromptInfo, error)
- func (ts *Toolset) SetElicitationHandler(handler tools.ElicitationHandler)
- func (ts *Toolset) SetManagedOAuth(managed bool)
- func (ts *Toolset) SetOAuthSuccessHandler(handler func())
- func (ts *Toolset) SetToolsChangedHandler(handler func())
- func (ts *Toolset) Start(ctx context.Context) error
- func (ts *Toolset) Stop(ctx context.Context) error
- func (ts *Toolset) Tools(ctx context.Context) ([]tools.Tool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAuthorizationURL ¶
func BuildAuthorizationURL(authEndpoint, clientID, redirectURI, state, codeChallenge, resourceURL string) string
BuildAuthorizationURL builds the OAuth authorization URL with PKCE
func GeneratePKCEVerifier ¶
func GeneratePKCEVerifier() string
GeneratePKCEVerifier generates a PKCE code verifier using oauth2 library
func GenerateState ¶
GenerateState generates a random state parameter for OAuth CSRF protection
func RegisterClient ¶
func RegisterClient(ctx context.Context, authMetadata *AuthorizationServerMetadata, redirectURI string, scopes []string) (clientID, clientSecret string, err error)
RegisterClient performs dynamic client registration
func RequestAuthorizationCode ¶
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 ¶
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 ¶
type CallbackServer struct {
// contains filtered or unexported fields
}
CallbackServer handles OAuth callback requests
func NewCallbackServer ¶
func NewCallbackServer() (*CallbackServer, error)
NewCallbackServer creates a new OAuth callback server
func (*CallbackServer) GetRedirectURI ¶
func (cs *CallbackServer) GetRedirectURI() string
func (*CallbackServer) SetExpectedState ¶
func (cs *CallbackServer) SetExpectedState(state string)
func (*CallbackServer) Start ¶
func (cs *CallbackServer) Start() error
func (*CallbackServer) WaitForCallback ¶
func (cs *CallbackServer) WaitForCallback(ctx context.Context) (code, state string, err error)
type GatewayToolset ¶
type GatewayToolset struct {
*Toolset
// contains filtered or unexported fields
}
func NewGatewayToolset ¶
func NewGatewayToolset(ctx context.Context, name, mcpServerName string, config any, envProvider environment.Provider, cwd string) (*GatewayToolset, error)
type InMemoryTokenStore ¶
type InMemoryTokenStore struct {
// contains filtered or unexported fields
}
InMemoryTokenStore implements OAuthTokenStore in memory
func (*InMemoryTokenStore) GetToken ¶
func (s *InMemoryTokenStore) GetToken(resourceURL string) (*OAuthToken, error)
func (*InMemoryTokenStore) RemoveToken ¶
func (s *InMemoryTokenStore) RemoveToken(resourceURL string) error
func (*InMemoryTokenStore) StoreToken ¶
func (s *InMemoryTokenStore) StoreToken(resourceURL string, token *OAuthToken) error
type OAuthToken ¶
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"`
}
func ExchangeCodeForToken ¶
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 ¶
func (t *OAuthToken) IsExpired() bool
IsExpired checks if the token is expired
type OAuthTokenStore ¶
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 ¶
func NewInMemoryTokenStore() OAuthTokenStore
NewInMemoryTokenStore creates a new in-memory token store
type PromptArgument ¶
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 ¶
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 ¶
NewRemoteToolset creates a new MCP toolset from a remote MCP Server.
func NewToolsetCommand ¶
NewToolsetCommand creates a new MCP toolset from a command.
func (*Toolset) Describe ¶
Describe returns a short, user-visible description of this toolset instance. It never includes secrets.
func (*Toolset) GetPrompt ¶
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 (*Toolset) ListPrompts ¶
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 ¶
func (ts *Toolset) SetElicitationHandler(handler tools.ElicitationHandler)
func (*Toolset) SetManagedOAuth ¶
func (*Toolset) SetOAuthSuccessHandler ¶
func (ts *Toolset) SetOAuthSuccessHandler(handler func())
func (*Toolset) SetToolsChangedHandler ¶
func (ts *Toolset) SetToolsChangedHandler(handler func())