Help us shape the future of Go! Take the 2026 Go Developer Survey

process

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

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 New

func New(dsl *types.ClientDSL) (*Client, error)

New creates a new Process-based MCP Client

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

func (c *Client) CancelRequest(ctx context.Context, requestID interface{}) error

CancelRequest cancels a specific request

func (*Client) ClearAllHandlers

func (c *Client) ClearAllHandlers()

ClearAllHandlers removes all registered handlers

func (*Client) CompleteProgress

func (c *Client) CompleteProgress(ctx context.Context, token uint64) error

CompleteProgress marks a progress token as complete and removes it

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, options ...types.ConnectionOptions) error

Connect establishes connection to the MCP server via Yao Process

func (*Client) CreateProgress

func (c *Client) CreateProgress(ctx context.Context, total uint64) (uint64, error)

CreateProgress creates a progress token for tracking

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context) error

Disconnect closes the connection to the MCP server

func (*Client) GetEventHandlers

func (c *Client) GetEventHandlers() map[string]int

GetEventHandlers returns a copy of current event handlers (for debugging/inspection)

func (*Client) GetLogLevel

func (c *Client) GetLogLevel() types.LogLevel

GetLogLevel returns the current log level

func (*Client) GetMetaInfo

func (c *Client) GetMetaInfo() gouTypes.MetaInfo

GetMetaInfo returns the meta information of the client

func (*Client) GetNotificationHandlers

func (c *Client) GetNotificationHandlers() map[string]int

GetNotificationHandlers returns a copy of current notification handlers (for debugging/inspection)

func (*Client) GetProgress

func (c *Client) GetProgress(token uint64) (*types.Progress, error)

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

func (c *Client) Initialize(ctx context.Context) (*types.InitializeResponse, error)

Initialize initializes the MCP client and exchanges capabilities with the server

func (*Client) Initialized

func (c *Client) Initialized(ctx context.Context) error

Initialized sends the initialized notification to the server

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected checks if the client is connected to the server

func (*Client) ListProgress

func (c *Client) ListProgress() map[uint64]*types.Progress

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) ListTools

func (c *Client) ListTools(ctx context.Context, cursor string) (*types.ListToolsResponse, error)

ListTools requests a list of available tools from the server

func (*Client) OnError

func (c *Client) OnError(handler types.ErrorHandler)

OnError registers an error handler

func (*Client) OnEvent

func (c *Client) OnEvent(eventType string, handler func(event types.Event))

OnEvent registers an event handler for a specific event type

func (*Client) OnNotification

func (c *Client) OnNotification(method string, handler types.NotificationHandler)

OnNotification registers a notification handler for a specific method

func (*Client) ReadResource

func (c *Client) ReadResource(ctx context.Context, uri string) (*types.ReadResourceResponse, error)

ReadResource reads a specific resource by calling the mapped Yao process

func (*Client) RemoveEventHandler

func (c *Client) RemoveEventHandler(eventType string, handler func(event types.Event))

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

func (c *Client) SetLogLevel(ctx context.Context, level types.LogLevel) error

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

func (c *Client) SubscribeResource(ctx context.Context, uri string) error

SubscribeResource is not supported in process transport

func (*Client) TriggerErrorStandard

func (c *Client) TriggerErrorStandard(ctx context.Context, err error)

TriggerErrorStandard triggers all registered error handlers with a standard error

func (*Client) TriggerEvent

func (c *Client) TriggerEvent(event types.Event)

TriggerEvent triggers all registered event handlers for a specific event type

func (*Client) TriggerNotification

func (c *Client) TriggerNotification(ctx context.Context, notification types.Message)

TriggerNotification triggers all registered notification handlers for a specific method

func (*Client) UnsubscribeResource

func (c *Client) UnsubscribeResource(ctx context.Context, uri string) error

UnsubscribeResource is not supported in process transport

func (*Client) UpdateProgress

func (c *Client) UpdateProgress(ctx context.Context, token uint64, progress uint64) error

UpdateProgress updates the progress for a given token

Jump to

Keyboard shortcuts

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