http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package http implements Streamable HTTP component clients.

Index

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) Close

func (*Factory) Close() error

Close releases factory-owned resources. HTTP sessions are request-scoped.

func (*Factory) Discover

func (f *Factory) Discover(ctx context.Context, server config.Server) (*component.Features, error)

Discover connects to a component and exhausts every feature list.

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

type OAuthHandlerProviderFunc func(context.Context, config.Server) (auth.OAuthHandler, error)

OAuthHandlerProviderFunc adapts a function into an OAuthHandlerProvider.

func (OAuthHandlerProviderFunc) OAuthHandler

OAuthHandler implements OAuthHandlerProvider.

type TokenStore

type TokenStore interface {
	StoreToken(context.Context, *oauth2.Token) error
}

TokenStore persists an OAuth token. The token includes its access token, refresh token, type, expiry, and provider-specific extra fields.

type TokenStoreFunc

type TokenStoreFunc func(context.Context, *oauth2.Token) error

TokenStoreFunc adapts a function into a TokenStore.

func (TokenStoreFunc) StoreToken

func (f TokenStoreFunc) StoreToken(ctx context.Context, token *oauth2.Token) error

StoreToken implements TokenStore.

Jump to

Keyboard shortcuts

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