Documentation
¶
Overview ¶
Package http implements Streamable HTTP component clients.
Index ¶
- func NewPersistentTokenSource(ctx context.Context, source oauth2.TokenSource, store TokenStore) oauth2.TokenSource
- type AuthorizationError
- type Factory
- func (f *Factory) CallTool(ctx context.Context, server config.Server, params *mcp.CallToolParams) (*mcp.CallToolResult, error)
- func (*Factory) Close() error
- func (f *Factory) Discover(ctx context.Context, server config.Server) (*component.Features, error)
- func (f *Factory) GetPrompt(ctx context.Context, server config.Server, params *mcp.GetPromptParams) (*mcp.GetPromptResult, error)
- func (f *Factory) OpenRuntime(ctx context.Context, server config.Server, opts component.RuntimeOptions) (component.Runtime, error)
- func (f *Factory) ReadResource(ctx context.Context, server config.Server, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error)
- func (f *Factory) Subscribe(ctx context.Context, server config.Server, params *mcp.SubscribeParams) error
- func (f *Factory) Unsubscribe(ctx context.Context, server config.Server, params *mcp.UnsubscribeParams) error
- type FactoryOptions
- type OAuthHandlerProvider
- type OAuthHandlerProviderFunc
- type TokenStore
- type TokenStoreFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPersistentTokenSource ¶
func NewPersistentTokenSource(ctx context.Context, source oauth2.TokenSource, store TokenStore) oauth2.TokenSource
NewPersistentTokenSource wraps source so that each new token it returns is written to store before it is returned to the caller. A storage failure is returned as a token error, preventing a refreshed token from being used without first being persisted.
This function is intended for auth.AuthorizationCodeHandlerConfig's NewTokenSource hook as well as InitialTokenSource. The context should outlive individual MCP requests; the SDK supplies such a context to NewTokenSource.
Types ¶
type AuthorizationError ¶
type AuthorizationError = component.AuthorizationError
AuthorizationError reports an authorization challenge returned by an HTTP component.
type Factory ¶
type Factory struct {
HTTPClient *http.Client
OAuth OAuthHandlerProvider
}
Factory creates isolated Streamable HTTP client sessions.
func NewFactory ¶
func NewFactory(opts FactoryOptions) *Factory
NewFactory creates a Streamable HTTP component factory.
func (*Factory) CallTool ¶
func (f *Factory) CallTool(ctx context.Context, server config.Server, params *mcp.CallToolParams) (*mcp.CallToolResult, error)
CallTool creates a fresh component session, invokes one tool, and closes it.
func (*Factory) GetPrompt ¶
func (f *Factory) GetPrompt(ctx context.Context, server config.Server, params *mcp.GetPromptParams) (*mcp.GetPromptResult, error)
GetPrompt gets one component prompt in a fresh component session.
func (*Factory) OpenRuntime ¶
func (f *Factory) OpenRuntime(ctx context.Context, server config.Server, opts component.RuntimeOptions) (component.Runtime, error)
OpenRuntime opens one persistent downstream client session.
func (*Factory) ReadResource ¶
func (f *Factory) ReadResource(ctx context.Context, server config.Server, params *mcp.ReadResourceParams) (*mcp.ReadResourceResult, error)
ReadResource reads one component resource in a fresh component session.
func (*Factory) Subscribe ¶
func (f *Factory) Subscribe(ctx context.Context, server config.Server, params *mcp.SubscribeParams) error
Subscribe forwards a resource subscription in a fresh component session.
func (*Factory) Unsubscribe ¶
func (f *Factory) Unsubscribe(ctx context.Context, server config.Server, params *mcp.UnsubscribeParams) error
Unsubscribe forwards a resource unsubscription in a fresh component session.
type FactoryOptions ¶
type FactoryOptions struct {
HTTPClient *http.Client
OAuth OAuthHandlerProvider
}
FactoryOptions configures a Streamable HTTP component factory.
type OAuthHandlerProvider ¶
type OAuthHandlerProvider interface {
OAuthHandler(context.Context, config.Server) (auth.OAuthHandler, error)
}
OAuthHandlerProvider returns the OAuth handler for a configured HTTP component. Implementations may load component-specific credentials and tokens from durable storage before constructing the handler.
type OAuthHandlerProviderFunc ¶
OAuthHandlerProviderFunc adapts a function into an OAuthHandlerProvider.
func (OAuthHandlerProviderFunc) OAuthHandler ¶
func (f OAuthHandlerProviderFunc) OAuthHandler(ctx context.Context, server config.Server) (auth.OAuthHandler, error)
OAuthHandler implements OAuthHandlerProvider.
type TokenStore ¶
TokenStore persists an OAuth token. The token includes its access token, refresh token, type, expiry, and provider-specific extra fields.
type TokenStoreFunc ¶
TokenStoreFunc adapts a function into a TokenStore.
func (TokenStoreFunc) StoreToken ¶
StoreToken implements TokenStore.