Documentation
¶
Index ¶
- Constants
- func DecodeToolContent(content mcp.ToolContent) object.Object
- func DecodeToolResponse(response *mcp.ToolResponse) object.Object
- func DictToMap(dict *object.Dict) map[string]interface{}
- func GetMCPClientClass() *object.Class
- func ParseToolSearchResults(response *mcplib.ToolResponse) (*object.List, error)
- func ParseToolSearchResultsFromText(text string) (*object.List, error)
- func Register(registrar interface{ ... })
- func RegisterToolHelpers(registrar interface{ ... })
- func RegisterToon(registrar interface{ ... })
- func RunToolScript(ctx context.Context, sl *scriptling.Scriptling, script string, ...) (response string, exitCode int, err error)
- func WrapClient(c *mcplib.Client) object.Object
- type ClientInstance
Constants ¶
const ( MCPLibraryName = "scriptling.mcp" MCPLibraryDesc = "MCP (Model Context Protocol) tool interaction library" )
const ( // MCPParamsVarName is the environment variable name for MCP tool parameters MCPParamsVarName = "__mcp_params" // MCPResponseVarName is the environment variable name for MCP tool response MCPResponseVarName = "__mcp_response" )
const ( ToonLibraryName = "scriptling.toon" ToonLibraryDesc = "TOON (Token-Oriented Object Notation) encoding/decoding library" )
Variables ¶
This section is empty.
Functions ¶
func DecodeToolContent ¶
func DecodeToolContent(content mcp.ToolContent) object.Object
DecodeToolContent converts a single ToolContent block to a scriptling Object.
func DecodeToolResponse ¶
func DecodeToolResponse(response *mcp.ToolResponse) object.Object
DecodeToolResponse converts an MCP ToolResponse to a scriptling Object. Handles: - Single text content: returns parsed JSON or string - Multiple content blocks: returns list of decoded blocks - Structured content: returns decoded object
func DictToMap ¶
DictToMap converts a scriptling Dict to a Go map[string]interface{}. This is a convenience wrapper around conversion.ToGo for the common case of converting Dict arguments for tool calls.
func GetMCPClientClass ¶
GetMCPClientClass returns the MCP Client class (thread-safe singleton)
func ParseToolSearchResults ¶
func ParseToolSearchResults(response *mcplib.ToolResponse) (*object.List, error)
ParseToolSearchResults extracts tool list from tool_search response. Returns a scriptling List containing tool dicts with name, description, input_schema. The tool_search response is expected to be a ToolResponse with JSON text content containing an array of tool definitions.
func ParseToolSearchResultsFromText ¶
ParseToolSearchResultsFromText parses tool search results from a JSON string. This is a convenience function when you already have the JSON text extracted.
func Register ¶
Register registers the mcp library with the given registrar First call builds the library, subsequent calls just register it
func RegisterToolHelpers ¶
RegisterToolHelpers registers the scriptling.mcp.tool sub-library This is optional and separate from the main MCP library registration
func RegisterToon ¶
Register registers the toon library with the given registrar First call builds the library, subsequent calls just register it
func RunToolScript ¶
func RunToolScript(ctx context.Context, sl *scriptling.Scriptling, script string, params map[string]interface{}) (response string, exitCode int, err error)
RunToolScript is a Go helper that sets up MCP parameters, runs a script, and retrieves the response This simplifies calling MCP tool scripts from Go code
Types ¶
type ClientInstance ¶
type ClientInstance struct {
// contains filtered or unexported fields
}
ClientInstance wraps an MCP client for use in scriptling
func (*ClientInstance) GetClient ¶
func (c *ClientInstance) GetClient() *mcplib.Client
GetClient returns the underlying MCP client