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 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) GetActiveResources(ctx context.Context) ([]ai.Resource, 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) GetResourceNameWithNamespace(resourceName 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
- func (s *GenkitMCPServer) Close() error
- func (s *GenkitMCPServer) GetServer() *server.MCPServer
- func (s *GenkitMCPServer) ListRegisteredResources() []string
- func (s *GenkitMCPServer) ListRegisteredTools() []string
- func (s *GenkitMCPServer) Serve(transport interface{}) error
- func (s *GenkitMCPServer) ServeStdio() error
- type MCPClientOptions
- type MCPHost
- func (h *MCPHost) Connect(ctx context.Context, g *genkit.Genkit, serverName string, ...) error
- func (h *MCPHost) Disconnect(ctx context.Context, serverName string) error
- func (h *MCPHost) GetActiveResources(ctx context.Context) ([]ai.Resource, error)
- func (h *MCPHost) GetActiveTools(ctx context.Context, gk *genkit.Genkit) ([]ai.Tool, error)
- func (h *MCPHost) GetPrompt(ctx context.Context, gk *genkit.Genkit, serverName, promptName string, ...) (ai.Prompt, error)
- func (h *MCPHost) Reconnect(ctx context.Context, serverName string) error
- type MCPHostOptions
- type MCPServerConfig
- type MCPServerOptions
- type SSEConfig
- type ServerRef
- type StdioConfig
- type StreamableHTTPConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) GetActiveResources ¶ added in v1.0.0
GetActiveResources fetches resources from the MCP server
func (*GenkitMCPClient) GetActiveTools ¶
GetActiveTools retrieves all tools available from the MCP server
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) GetResourceNameWithNamespace ¶ added in v1.0.0
func (c *GenkitMCPClient) GetResourceNameWithNamespace(resourceName string) string
GetResourceNameWithNamespace returns a resource 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, prompts, and resources
func NewMCPServer ¶
func NewMCPServer(g *genkit.Genkit, options MCPServerOptions) *GenkitMCPServer
NewMCPServer creates a new GenkitMCPServer with the provided options
func (*GenkitMCPServer) Close ¶ added in v1.0.0
func (s *GenkitMCPServer) Close() error
Close shuts down the MCP server
func (*GenkitMCPServer) GetServer ¶ added in v1.0.0
func (s *GenkitMCPServer) GetServer() *server.MCPServer
GetServer returns the underlying MCP server instance
func (*GenkitMCPServer) ListRegisteredResources ¶ added in v1.0.0
func (s *GenkitMCPServer) ListRegisteredResources() []string
ListRegisteredResources returns the names of all discovered resources
func (*GenkitMCPServer) ListRegisteredTools ¶
func (s *GenkitMCPServer) ListRegisteredTools() []string
ListRegisteredTools returns the names of all discovered tools
func (*GenkitMCPServer) Serve ¶ added in v1.0.0
func (s *GenkitMCPServer) Serve(transport interface{}) error
Serve starts the MCP server with a custom transport
func (*GenkitMCPServer) ServeStdio ¶
func (s *GenkitMCPServer) ServeStdio() error
ServeStdio starts the MCP server using stdio transport
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 MCPHost ¶ added in v1.0.0
type MCPHost struct {
// contains filtered or unexported fields
}
MCPHost manages connections to multiple MCP servers This matches the naming convention used in the JavaScript implementation
func NewMCPHost ¶ added in v1.0.0
func NewMCPHost(g *genkit.Genkit, options MCPHostOptions) (*MCPHost, error)
NewMCPHost creates a new MCPHost with the given options
func (*MCPHost) Connect ¶ added in v1.0.0
func (h *MCPHost) Connect(ctx context.Context, g *genkit.Genkit, serverName string, config MCPClientOptions) error
Connect connects to a single MCP server with the provided configuration and automatically registers tools, prompts, and resources from the server
func (*MCPHost) Disconnect ¶ added in v1.0.0
Disconnect disconnects from a specific MCP server
func (*MCPHost) GetActiveResources ¶ added in v1.0.0
GetActiveResources retrieves detached resources from all connected and enabled MCP clients
func (*MCPHost) GetActiveTools ¶ added in v1.0.0
GetActiveTools retrieves all tools from all connected and enabled MCP clients
type MCPHostOptions ¶ added in v1.0.0
type MCPHostOptions struct { // Name for this host instance - used for logging and identification Name string // Version number for this host (defaults to "1.0.0" if empty) Version string // MCPServers is an array of server configurations MCPServers []MCPServerConfig }
MCPHostOptions holds configuration for MCPHost
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 for this server instance - used for MCP identification Name string // Version number for this server (defaults to "1.0.0" if empty) Version string }
MCPServerOptions holds configuration for GenkitMCPServer
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.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
fixtures
|
|
basic_server
command
|
|
content_server
command
|
|
policy_server
command
|
|
server_a
command
|
|
server_b
command
|