Documentation
¶
Index ¶
- func GetMapping(clientID string) (*types.MappingData, bool)
- func LoadMapping(clientID string, dsl *types.ClientDSL, mappingBasePath string) (*types.MappingData, error)
- func LoadMappingFromFile(filePath string, clientID string, dsl *types.ClientDSL) (*types.MappingData, error)
- func LoadMappingFromSource(clientID string, dsl *types.ClientDSL, mappingData *types.MappingData) (*types.MappingData, error)
- func RemoveMapping(clientID string)
- func RemoveMappingItems(clientID string, toolNames []string, resourceNames []string, ...) error
- func SetMapping(clientID string, mapping *types.MappingData)
- func UpdateMapping(clientID string, tools map[string]*types.ToolSchema, ...) error
- type AuthorizedProvider
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, arguments interface{}, ...) (*types.CallToolResponse, error)
- func (c *Client) CallTools(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
- func (c *Client) CallToolsParallel(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
- func (c *Client) CancelRequest(ctx context.Context, requestID interface{}) error
- func (c *Client) ClearAllHandlers()
- func (c *Client) CompleteProgress(ctx context.Context, token uint64) error
- func (c *Client) Connect(ctx context.Context, options ...types.ConnectionOptions) error
- func (c *Client) CreateProgress(ctx context.Context, total uint64) (uint64, error)
- func (c *Client) Disconnect(ctx context.Context) error
- func (c *Client) GetEventHandlers() map[string]int
- func (c *Client) GetLogLevel() types.LogLevel
- func (c *Client) GetMetaInfo() gouTypes.MetaInfo
- func (c *Client) GetNotificationHandlers() map[string]int
- func (c *Client) GetProgress(token uint64) (*types.Progress, error)
- func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*types.GetPromptResponse, error)
- func (c *Client) GetSample(ctx context.Context, itemType types.SampleItemType, itemName string, index int) (*types.SampleData, error)
- func (c *Client) Info() *types.ClientInfo
- func (c *Client) Initialize(ctx context.Context) (*types.InitializeResponse, error)
- func (c *Client) Initialized(ctx context.Context) error
- func (c *Client) IsConnected() bool
- func (c *Client) ListProgress() map[uint64]*types.Progress
- func (c *Client) ListPrompts(ctx context.Context, cursor string) (*types.ListPromptsResponse, error)
- func (c *Client) ListResources(ctx context.Context, cursor string) (*types.ListResourcesResponse, error)
- func (c *Client) ListSamples(ctx context.Context, itemType types.SampleItemType, itemName string) (*types.ListSamplesResponse, error)
- func (c *Client) ListTools(ctx context.Context, cursor string) (*types.ListToolsResponse, error)
- func (c *Client) OnError(handler types.ErrorHandler)
- func (c *Client) OnEvent(eventType string, handler func(event types.Event))
- func (c *Client) OnNotification(method string, handler types.NotificationHandler)
- func (c *Client) ReadResource(ctx context.Context, uri string) (*types.ReadResourceResponse, error)
- func (c *Client) RemoveEventHandler(eventType string, handler func(event types.Event))
- func (c *Client) RemoveNotificationHandler(method string, handler types.NotificationHandler)
- func (c *Client) SetLogLevel(ctx context.Context, level types.LogLevel) error
- func (c *Client) State() types.ConnectionState
- func (c *Client) SubscribeResource(ctx context.Context, uri string) error
- func (c *Client) TriggerErrorStandard(ctx context.Context, err error)
- func (c *Client) TriggerEvent(event types.Event)
- func (c *Client) TriggerNotification(ctx context.Context, notification types.Message)
- func (c *Client) UnsubscribeResource(ctx context.Context, uri string) error
- func (c *Client) UpdateProgress(ctx context.Context, token uint64, progress uint64) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMapping ¶
func GetMapping(clientID string) (*types.MappingData, bool)
GetMapping gets the mapping data for a specific client
func LoadMapping ¶
func LoadMapping(clientID string, dsl *types.ClientDSL, mappingBasePath string) (*types.MappingData, error)
LoadMapping loads mapping data (tools, resources, prompts) for a process-based MCP client
func LoadMappingFromFile ¶
func LoadMappingFromFile(filePath string, clientID string, dsl *types.ClientDSL) (*types.MappingData, error)
LoadMappingFromFile loads mapping data based on MCP client file path Examples:
mcps/dsl.mcp.yao -> clientID: "dsl", mapping: mcps/mapping/dsl/ mcps/foo/bar.mcp.yao -> clientID: "foo.bar", mapping: mcps/mapping/foo/bar/ assistants/expense/mcps/tools.mcp.yao -> clientID: "tools", mapping: assistants/expense/mcps/mapping/tools/
func LoadMappingFromSource ¶
func LoadMappingFromSource(clientID string, dsl *types.ClientDSL, mappingData *types.MappingData) (*types.MappingData, error)
LoadMappingFromSource loads mapping data from in-memory DSL and optional mapping data
func RemoveMapping ¶
func RemoveMapping(clientID string)
RemoveMapping removes the mapping data for a specific client
func RemoveMappingItems ¶
func RemoveMappingItems(clientID string, toolNames []string, resourceNames []string, promptNames []string) error
RemoveMappingItems removes specific tools/resources/prompts from the mapping registry
func SetMapping ¶
func SetMapping(clientID string, mapping *types.MappingData)
SetMapping sets the mapping data for a specific client
func UpdateMapping ¶
func UpdateMapping(clientID string, tools map[string]*types.ToolSchema, resources map[string]*types.ResourceSchema, prompts map[string]*types.PromptSchema) error
UpdateMapping updates specific tools/resources/prompts in the mapping registry
Types ¶
type AuthorizedProvider ¶
type AuthorizedProvider interface {
// GetAuthorizedMap returns authorized information as a map
// The map should contain fields like: user_id, team_id, tenant_id, etc.
GetAuthorizedMap() map[string]interface{}
}
AuthorizedProvider is an interface for objects that can provide authorized information This allows agent context (from yao) to pass authorization info to process calls Agent context should implement this interface to pass authorization to MCP tool calls
type Client ¶
type Client struct {
DSL *types.ClientDSL
InitResult *types.InitializeResponse
// contains filtered or unexported fields
}
Client implements MCP Client interface using Yao Process calls
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, arguments interface{}, extraArgs ...interface{}) (*types.CallToolResponse, error)
CallTool invokes a specific tool by calling the mapped Yao process extraArgs are optional additional arguments that will be appended to the process call
func (*Client) CallTools ¶
func (c *Client) CallTools(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
CallTools calls multiple tools in sequence Tools are executed one by one, ensuring order and avoiding race conditions extraArgs are optional additional arguments that will be appended to each tool's process call
func (*Client) CallToolsParallel ¶
func (c *Client) CallToolsParallel(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
CallToolsParallel calls multiple tools concurrently All tools are executed in parallel for better performance Note: Results order matches the input order, but execution is concurrent extraArgs are optional additional arguments that will be appended to each tool's process call
func (*Client) CancelRequest ¶
CancelRequest cancels a specific request
func (*Client) ClearAllHandlers ¶
func (c *Client) ClearAllHandlers()
ClearAllHandlers removes all registered handlers
func (*Client) CompleteProgress ¶
CompleteProgress marks a progress token as complete and removes it
func (*Client) CreateProgress ¶
CreateProgress creates a progress token for tracking
func (*Client) Disconnect ¶
Disconnect closes the connection to the MCP server
func (*Client) GetEventHandlers ¶
GetEventHandlers returns a copy of current event handlers (for debugging/inspection)
func (*Client) GetLogLevel ¶
GetLogLevel returns the current log level
func (*Client) GetMetaInfo ¶
GetMetaInfo returns the meta information of the client
func (*Client) GetNotificationHandlers ¶
GetNotificationHandlers returns a copy of current notification handlers (for debugging/inspection)
func (*Client) GetProgress ¶
GetProgress returns the current progress for a given token
func (*Client) GetPrompt ¶
func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*types.GetPromptResponse, error)
GetPrompt gets a specific prompt with given arguments and renders the template
func (*Client) GetSample ¶
func (c *Client) GetSample(ctx context.Context, itemType types.SampleItemType, itemName string, index int) (*types.SampleData, error)
GetSample retrieves a specific sample by index itemType: types.SampleTool or types.SampleResource
func (*Client) Info ¶
func (c *Client) Info() *types.ClientInfo
Info returns basic client information
func (*Client) Initialize ¶
Initialize initializes the MCP client and exchanges capabilities with the server
func (*Client) Initialized ¶
Initialized sends the initialized notification to the server
func (*Client) IsConnected ¶
IsConnected checks if the client is connected to the server
func (*Client) ListProgress ¶
ListProgress returns all active progress tokens
func (*Client) ListPrompts ¶
func (c *Client) ListPrompts(ctx context.Context, cursor string) (*types.ListPromptsResponse, error)
ListPrompts lists all available prompts
func (*Client) ListResources ¶
func (c *Client) ListResources(ctx context.Context, cursor string) (*types.ListResourcesResponse, error)
ListResources lists all available resources
func (*Client) ListSamples ¶
func (c *Client) ListSamples(ctx context.Context, itemType types.SampleItemType, itemName string) (*types.ListSamplesResponse, error)
ListSamples lists available training samples for a tool or resource from .jsonl files itemType: types.SampleTool or types.SampleResource
func (*Client) OnError ¶
func (c *Client) OnError(handler types.ErrorHandler)
OnError registers an error handler
func (*Client) OnNotification ¶
func (c *Client) OnNotification(method string, handler types.NotificationHandler)
OnNotification registers a notification handler for a specific method
func (*Client) ReadResource ¶
ReadResource reads a specific resource by calling the mapped Yao process
func (*Client) RemoveEventHandler ¶
RemoveEventHandler removes an event handler for a specific event type
func (*Client) RemoveNotificationHandler ¶
func (c *Client) RemoveNotificationHandler(method string, handler types.NotificationHandler)
RemoveNotificationHandler removes a notification handler for a specific method
func (*Client) SetLogLevel ¶
SetLogLevel sets the log level for the server
func (*Client) State ¶
func (c *Client) State() types.ConnectionState
State returns the current connection state
func (*Client) SubscribeResource ¶
SubscribeResource is not supported in process transport
func (*Client) TriggerErrorStandard ¶
TriggerErrorStandard triggers all registered error handlers with a standard error
func (*Client) TriggerEvent ¶
TriggerEvent triggers all registered event handlers for a specific event type
func (*Client) TriggerNotification ¶
TriggerNotification triggers all registered notification handlers for a specific method
func (*Client) UnsubscribeResource ¶
UnsubscribeResource is not supported in process transport