mcp_client

package
v0.0.0-...-91534d0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectAndUseHttp

func ConnectAndUseHttp(overrides *mcp_config.OverrideT, workspace, server, serverURL string, oauth *mcp_config.OAuthT, hooks OAuthUIHooks, onOAuthRequired func(), useClient func(*Client) error) error

func DefaultClientURI

func DefaultClientURI() string

func DefaultRedirectURI

func DefaultRedirectURI() string

func DefaultTokenFile

func DefaultTokenFile(workspace, serverName, rawURL string) string

func IsAuthorizationFailure

func IsAuthorizationFailure(err error) bool

func NewFilePersistingTokenSource

func NewFilePersistingTokenSource(path string, base oauth2.TokenSource) oauth2.TokenSource

NewFilePersistingTokenSource returns an oauth2.TokenSource that attempts to read an existing token from `path` when `base` is nil, otherwise delegates to `base` and persists tokens returned by it to `path`.

Types

type Client

type Client struct {
	Tools *mcp_sdk.ListToolsResult
	// contains filtered or unexported fields
}

func ConnectCmdLine

func ConnectCmdLine(overrides *mcp_config.OverrideT, envvars []string, command string, args ...string) (*Client, error)

func ConnectHttp

func ConnectHttp(overrides *mcp_config.OverrideT, url string) (*Client, error)

func ConnectHttpOAuthInteractive

func ConnectHttpOAuthInteractive(overrides *mcp_config.OverrideT, serverURL string, oauthCfg OAuthConfig, hooks OAuthUIHooks) (*Client, error)

func (*Client) Call

func (c *Client) Call(ctx context.Context, name string, args map[string]any) (string, error)

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying client connection

func (*Client) ListTools

func (c *Client) ListTools() error

type FileTokenStore

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

func NewFileTokenStore

func NewFileTokenStore(path string) *FileTokenStore

func (*FileTokenStore) GetToken

func (s *FileTokenStore) GetToken(ctx context.Context) (*oauth2.Token, error)

func (*FileTokenStore) StoreToken

func (s *FileTokenStore) StoreToken(ctx context.Context, token *oauth2.Token) error

type GoSDKClient

type GoSDKClient struct {
	Tools *mcp_sdk.ListToolsResult
	// contains filtered or unexported fields
}

GoSDKClient is a thin adapter around github.com/modelcontextprotocol/go-sdk's ClientSession.

func ConnectCmdLineGoSDK

func ConnectCmdLineGoSDK(overrides *mcp_config.OverrideT, envvars []string, command string, args ...string) (*GoSDKClient, error)

ConnectCmdLineGoSDK connects to a local MCP server process using the Go SDK transports.

func ConnectHttpGoSDK

func ConnectHttpGoSDK(overrides *mcp_config.OverrideT, endpoint string, oauth authsdk.OAuthHandler) (*GoSDKClient, error)

ConnectHttpGoSDK connects to a streamable HTTP MCP endpoint. oauth may be nil.

func (*GoSDKClient) Call

func (c *GoSDKClient) Call(ctx context.Context, name string, args map[string]any) (string, error)

Call invokes a tool with retry logic for temporary connection failures. It uses exponential backoff with jitter to handle transient network issues.

func (*GoSDKClient) Close

func (c *GoSDKClient) Close() error

Close closes the session.

func (*GoSDKClient) ListTools

func (c *GoSDKClient) ListTools() error

ListTools calls ListTools on the underlying session and caches the result.

type OAuthCallbackResult

type OAuthCallbackResult struct {
	Code  string
	State string
}

type OAuthCallbackServer

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

func StartOAuthCallbackServer

func StartOAuthCallbackServer(redirectURI string) (*OAuthCallbackServer, error)

func (*OAuthCallbackServer) Close

func (s *OAuthCallbackServer) Close()

func (*OAuthCallbackServer) Wait

type OAuthConfig

type OAuthConfig struct {
	ClientID              string
	ClientURI             string
	ClientSecret          string
	RedirectURI           string
	Scopes                []string
	AuthServerMetadataURL string
	TokenFile             string
}

func BuildOAuthConfig

func BuildOAuthConfig(workspace, server, serverURL string, oauth *mcp_config.OAuthT) OAuthConfig

type OAuthUIHooks

type OAuthUIHooks struct {
	OpenBrowser               func(string)
	PromptCallbackURL         func() (string, error)
	OnAutoCallbackUnavailable func(error)
}

Jump to

Keyboard shortcuts

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