Documentation
¶
Overview ¶
Package mcp provides functionality for managing Model Context Protocol (MCP) clients within the Seshat application.
Index ¶
- func Close(ctx context.Context) error
- func DisableSingle(cfg *config.ConfigStore, name string) error
- func GetPromptMessages(ctx context.Context, cfg *config.ConfigStore, clientName, promptName string, ...) ([]string, error)
- func GetStates() map[string]ClientInfo
- func Initialize(ctx context.Context, permissions permission.Service, cfg *config.ConfigStore)
- func InitializeSingle(ctx context.Context, name string, cfg *config.ConfigStore) error
- func Prompts() iter.Seq2[string, []*Prompt]
- func RefreshPrompts(ctx context.Context, name string)
- func RefreshResources(ctx context.Context, name string)
- func RefreshTools(ctx context.Context, cfg *config.ConfigStore, name string)
- func Resources() iter.Seq2[string, []*Resource]
- func SubscribeEvents(ctx context.Context) <-chan pubsub.Event[Event]
- func Tools() iter.Seq2[string, []*Tool]
- func WaitForInit(ctx context.Context) error
- type ClientInfo
- type ClientSession
- type Counts
- type Event
- type EventType
- type Prompt
- type Resource
- type ResourceContents
- type State
- type Tool
- type ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableSingle ¶
func DisableSingle(cfg *config.ConfigStore, name string) error
DisableSingle disables and closes a single MCP client by name.
func GetPromptMessages ¶
func GetPromptMessages(ctx context.Context, cfg *config.ConfigStore, clientName, promptName string, args map[string]string) ([]string, error)
GetPromptMessages retrieves the content of an MCP prompt with the given arguments.
func GetStates ¶
func GetStates() map[string]ClientInfo
GetStates returns the current state of all MCP clients
func Initialize ¶
func Initialize(ctx context.Context, permissions permission.Service, cfg *config.ConfigStore)
Initialize initializes MCP clients based on the provided configuration.
func InitializeSingle ¶
InitializeSingle initializes a single MCP client by name.
func RefreshPrompts ¶
RefreshPrompts gets the updated list of prompts from the MCP and updates the global state.
func RefreshResources ¶
RefreshResources gets the updated list of resources from the MCP and updates the global state.
func RefreshTools ¶
func RefreshTools(ctx context.Context, cfg *config.ConfigStore, name string)
RefreshTools gets the updated list of tools from the MCP and updates the global state.
func SubscribeEvents ¶
SubscribeEvents returns a channel for MCP events
func WaitForInit ¶
WaitForInit blocks until MCP initialization is complete. If Initialize was never called, this returns immediately.
Types ¶
type ClientInfo ¶
type ClientInfo struct {
Name string
State State
Error error
Client *ClientSession
Counts Counts
ConnectedAt time.Time
}
ClientInfo holds information about an MCP client's state
func GetState ¶
func GetState(name string) (ClientInfo, bool)
GetState returns the state of a specific MCP client
type ClientSession ¶
type ClientSession struct {
*mcp.ClientSession
// contains filtered or unexported fields
}
ClientSession wraps an mcp.ClientSession with a context cancel function so that the context created during session establishment is properly cleaned up on close.
func (*ClientSession) Close ¶
func (s *ClientSession) Close() error
Close cancels the session context and then closes the underlying session.
type Resource ¶
func ListResources ¶
ListResources returns the current resources for an MCP server.
type ResourceContents ¶
type ResourceContents = mcp.ResourceContents
func ReadResource ¶
func ReadResource(ctx context.Context, cfg *config.ConfigStore, name, uri string) ([]*ResourceContents, error)
ReadResource reads the contents of a resource from an MCP server.
type ToolResult ¶
ToolResult represents the result of running an MCP tool.
func RunTool ¶
func RunTool(ctx context.Context, cfg *config.ConfigStore, name, toolName string, input string) (ToolResult, error)
RunTool runs an MCP tool with the given input parameters.