Documentation
¶
Overview ¶
Package mcp provides a client for integration with the Model Context Protocol.
Package mcp provides a client for integration with the Model Context Protocol.
Package mcp provides a client for integration with the Model Context Protocol.
Package mcp provides a client for integration with the Model Context Protocol.
Index ¶
- func ContentToText(contentList []mcp.Content) string
- func ExtractTextFromContent(content mcp.Content) string
- type GenkitMCPClient
- func (c *GenkitMCPClient) Disable()
- func (c *GenkitMCPClient) Disconnect() error
- func (c *GenkitMCPClient) GetActivePrompts(ctx context.Context) ([]mcp.Prompt, error)
- func (c *GenkitMCPClient) GetActiveTools(ctx context.Context, g *genkit.Genkit) ([]ai.Tool, error)
- func (c *GenkitMCPClient) GetPrompt(ctx context.Context, g *genkit.Genkit, promptName string, ...) (*ai.Prompt, error)
- func (c *GenkitMCPClient) GetPromptNameWithNamespace(promptName string) string
- func (c *GenkitMCPClient) GetToolNameWithNamespace(toolName string) string
- func (c *GenkitMCPClient) IsEnabled() bool
- func (c *GenkitMCPClient) Name() string
- func (c *GenkitMCPClient) Reenable()
- func (c *GenkitMCPClient) Restart(ctx context.Context) error
- type GenkitMCPServer
- type MCPClientOptions
- type MCPManager
- func (m *MCPManager) Connect(ctx context.Context, serverName string, config MCPClientOptions) error
- func (m *MCPManager) Disconnect(ctx context.Context, serverName string) error
- func (m *MCPManager) GetActiveTools(ctx context.Context, gk *genkit.Genkit) ([]ai.Tool, error)
- func (m *MCPManager) GetPrompt(ctx context.Context, gk *genkit.Genkit, serverName, promptName string, ...) (*ai.Prompt, error)
- type MCPManagerOptions
- type MCPServerConfig
- type MCPServerOptions
- type SSEConfig
- type ServerRef
- type StdioConfig
- type StreamableHTTPConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentToText ¶
ContentToText extracts text content from MCP Content
func ExtractTextFromContent ¶
ExtractTextFromContent extracts text content from MCP Content
Types ¶
type GenkitMCPClient ¶
type GenkitMCPClient struct {
// contains filtered or unexported fields
}
GenkitMCPClient represents a client for interacting with MCP servers.
func NewGenkitMCPClient ¶
func NewGenkitMCPClient(options MCPClientOptions) (*GenkitMCPClient, error)
NewGenkitMCPClient creates a new GenkitMCPClient with the given options. Returns an error if the initial connection fails.
func (*GenkitMCPClient) Disable ¶
func (c *GenkitMCPClient) Disable()
Disable temporarily disables the client by closing the connection
func (*GenkitMCPClient) Disconnect ¶
func (c *GenkitMCPClient) Disconnect() error
Disconnect closes the connection to the MCP server
func (*GenkitMCPClient) GetActivePrompts ¶
GetActivePrompts retrieves all prompts available from the MCP server
func (*GenkitMCPClient) GetActiveTools ¶
GetActiveTools retrieves all tools available from the MCP server and returns them as Genkit ToolAction objects
func (*GenkitMCPClient) GetPrompt ¶
func (c *GenkitMCPClient) GetPrompt(ctx context.Context, g *genkit.Genkit, promptName string, args map[string]string) (*ai.Prompt, error)
GetPrompt retrieves a prompt from the MCP server
func (*GenkitMCPClient) GetPromptNameWithNamespace ¶
func (c *GenkitMCPClient) GetPromptNameWithNamespace(promptName string) string
GetPromptNameWithNamespace returns a prompt name prefixed with the client's namespace
func (*GenkitMCPClient) GetToolNameWithNamespace ¶
func (c *GenkitMCPClient) GetToolNameWithNamespace(toolName string) string
GetToolNameWithNamespace returns a tool name prefixed with the client's namespace
func (*GenkitMCPClient) IsEnabled ¶
func (c *GenkitMCPClient) IsEnabled() bool
IsEnabled returns whether the client is enabled
func (*GenkitMCPClient) Reenable ¶
func (c *GenkitMCPClient) Reenable()
Reenable re-enables a previously disabled client by reconnecting
type GenkitMCPServer ¶
type GenkitMCPServer struct {
// contains filtered or unexported fields
}
GenkitMCPServer represents an MCP server that exposes Genkit tools
func NewMCPServer ¶
func NewMCPServer(g *genkit.Genkit, options MCPServerOptions) *GenkitMCPServer
NewMCPServer creates a new MCP server instance that can expose Genkit tools
func (*GenkitMCPServer) ListRegisteredTools ¶
func (s *GenkitMCPServer) ListRegisteredTools() []string
ListRegisteredTools returns the names of all discovered tools
func (*GenkitMCPServer) ServeSSE ¶
func (s *GenkitMCPServer) ServeSSE(ctx context.Context, addr string) error
ServeSSE starts the MCP server with SSE transport (for web clients)
func (*GenkitMCPServer) ServeStdio ¶
func (s *GenkitMCPServer) ServeStdio(ctx context.Context) error
ServeStdio starts the MCP server with stdio transport (primary MCP transport)
func (*GenkitMCPServer) Stop ¶
func (s *GenkitMCPServer) Stop() error
Stop gracefully stops the MCP server
type MCPClientOptions ¶
type MCPClientOptions struct { // Name for this client instance - ideally a nickname for the server Name string // Version number for this client (defaults to "1.0.0" if empty) Version string // Disabled flag to temporarily disable this client Disabled bool // Stdio contains config for starting a local server process using stdio transport Stdio *StdioConfig // SSE contains config for connecting to a remote server via SSE transport SSE *SSEConfig // StreamableHTTP contains config for connecting to a remote server via Streamable HTTP transport StreamableHTTP *StreamableHTTPConfig }
MCPClientOptions holds configuration for the MCPClient.
type MCPManager ¶
type MCPManager struct {
// contains filtered or unexported fields
}
MCPManager manages connections to multiple MCP servers
func NewMCPManager ¶
func NewMCPManager(options MCPManagerOptions) (*MCPManager, error)
NewMCPManager creates a new MCPManager with the given options
func (*MCPManager) Connect ¶
func (m *MCPManager) Connect(ctx context.Context, serverName string, config MCPClientOptions) error
Connect connects to a single MCP server with the provided configuration
func (*MCPManager) Disconnect ¶
func (m *MCPManager) Disconnect(ctx context.Context, serverName string) error
Disconnect disconnects from a specific MCP server
func (*MCPManager) GetActiveTools ¶
GetActiveTools retrieves all tools from all connected and enabled MCP clients
type MCPManagerOptions ¶
type MCPManagerOptions struct { // Name for this manager instance - used for logging and identification Name string // Version number for this manager (defaults to "1.0.0" if empty) Version string // MCPServers is an array of server configurations MCPServers []MCPServerConfig }
MCPManagerOptions holds configuration for MCPManager
type MCPServerConfig ¶
type MCPServerConfig struct { // Name for this server - used as the key for lookups Name string // Config holds the client configuration options Config MCPClientOptions }
MCPServerConfig holds configuration for a single MCP server
type MCPServerOptions ¶
type MCPServerOptions struct { // Name is the server name advertised to MCP clients Name string // Version is the server version (defaults to "1.0.0" if empty) Version string // Tools is an optional list of specific tools to expose. // If provided, only these tools will be exposed (no auto-discovery). // If nil or empty, all tools will be auto-discovered from the registry. Tools []ai.Tool }
MCPServerOptions holds configuration for creating an MCP server
type SSEConfig ¶
type SSEConfig struct { BaseURL string Headers map[string]string HTTPClient *http.Client // Optional custom HTTP client }
SSEConfig contains options for the SSE transport
type StdioConfig ¶
StdioConfig holds configuration for a stdio-based MCP server process.