mcp

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcp implements MCP client for executing tool calls on behalf of cloud.

Index

Constants

View Source
const (
	DefaultConnectTimeout = 30 * time.Second
	DefaultCallTimeout    = 60 * time.Second
)

Variables

This section is empty.

Functions

func CallTool

func CallTool(ctx context.Context, server *protocol.MCPServerConfig, toolName string, arguments map[string]any) (*sdk_mcp.CallToolResult, error)

CallTool executes a single MCP tool call using the default manager.

func ExtractContent

func ExtractContent(result *sdk_mcp.CallToolResult) string

ExtractContent extracts text content from MCP CallToolResult.

func ListTools

func ListTools(ctx context.Context, server *protocol.MCPServerConfig) ([]*sdk_mcp.Tool, error)

ListTools lists available tools from an MCP server using the default manager.

func NewStdioTransport

func NewStdioTransport(command string, args []string, env map[string]string) sdk_mcp.Transport

NewStdioTransport creates a new stdio transport for MCP.

func NewStreamableHTTPTransport added in v0.0.15

func NewStreamableHTTPTransport(endpoint string, headers map[string]string, dynamicHeaders map[string]string) sdk_mcp.Transport

NewStreamableHTTPTransport creates a Streamable HTTP transport for MCP.

Despite the historical name, this returns the SDK's StreamableClientTransport (the modern "Streamable HTTP" transport), not the legacy HTTP+SSE client. Both the "streamable-http" and legacy "sse" config labels route here.

Types

type AuthError added in v0.0.12

type AuthError struct {
	StatusCode          int
	WWWAuthenticate     string
	ResourceMetadataURL string
	Underlying          error
}

AuthError wraps a 401 from a remote MCP server with structured metadata for fc-safari to translate into an authorization_required tool result.

func (*AuthError) Error added in v0.0.12

func (e *AuthError) Error() string

func (*AuthError) Unwrap added in v0.0.12

func (e *AuthError) Unwrap() error

type CallToolResult

type CallToolResult = sdk_mcp.CallToolResult

Re-export SDK types for use by other packages.

type ClientManager

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

ClientManager manages MCP server connections and sessions.

func GetDefaultManager

func GetDefaultManager() *ClientManager

GetDefaultManager returns a singleton ClientManager.

func NewClientManager

func NewClientManager() *ClientManager

NewClientManager creates a new ClientManager.

func (*ClientManager) CallTool

func (m *ClientManager) CallTool(ctx context.Context, server *protocol.MCPServerConfig, toolName string, arguments map[string]any, logger *slog.Logger) (*sdk_mcp.CallToolResult, error)

CallTool executes a single MCP tool call using the manager for session persistence.

func (*ClientManager) Close

func (m *ClientManager) Close()

Close closes all active sessions and clients.

func (*ClientManager) GetSession

func (m *ClientManager) GetSession(ctx context.Context, server *protocol.MCPServerConfig, logger *slog.Logger) (*sdk_mcp.ClientSession, error)

GetSession returns or creates an MCP session for the given server. Sessions are cached by server name. If DynamicHeaders change (e.g. a different user or rotated credentials), the stale session is invalidated and recreated.

func (*ClientManager) ListTools

func (m *ClientManager) ListTools(ctx context.Context, server *protocol.MCPServerConfig, logger *slog.Logger) ([]*sdk_mcp.Tool, error)

ListTools lists available tools from an MCP server using the manager for session persistence.

type ImageContent

type ImageContent = sdk_mcp.ImageContent

Re-export SDK types for use by other packages.

type TextContent

type TextContent = sdk_mcp.TextContent

Re-export SDK types for use by other packages.

Jump to

Keyboard shortcuts

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