adapters

package
v0.15.0 Latest Latest
Warning

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

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

Documentation

Overview

Package adapters provides tools that call out to external systems.

MCPTool wraps a single MCP server tool and exposes it to the LLM executor as a first-class tool. Phase 1 names use the "<server>__ <tool>" namespacing scheme (decision §3.7 of the recommendations doc); this is enforced by tools.Registry.Register, which only admits "__" in names belonging to types that implement tools.MCPSource.

Package adapters provides tools that integrate with external services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOpenAPICallTool

func NewOpenAPICallTool() tools.Tool

NewOpenAPICallTool creates an OpenAPI call tool.

func NewWebhookCallTool

func NewWebhookCallTool() tools.Tool

NewWebhookCallTool creates a webhook call tool.

Types

type MCPTool

type MCPTool struct {
	// contains filtered or unexported fields
}

MCPTool implements tools.Tool by delegating to an mcp.Client.

Name format: "<server>__<tool>" — the double-underscore separator is reserved for MCP namespacing. Builtins cannot use it.

Audit invariant: Execute emits EventMCPToolCall before invocation and EventMCPToolResult after, carrying ONLY sizes, durations, and reason codes — never the argument bytes or result content.

func NewMCPTool

func NewMCPTool(opts MCPToolOpts) (*MCPTool, error)

NewMCPTool constructs an MCPTool from a discovered descriptor.

Returns an error when the descriptor name is empty or contains the "__" namespace separator (review B9). The registry's contains-"__" admission check accepts ambiguous names like "<server>__" or "<server>____foo" otherwise; failing at construction means the adapter is never created and the caller can audit the rejection.

func (*MCPTool) Category

func (m *MCPTool) Category() tools.Category

Category is always CategoryAdapter — MCP tools are external adapters by definition.

func (*MCPTool) Description

func (m *MCPTool) Description() string

Description forwards the MCP server's description.

func (*MCPTool) Execute

func (m *MCPTool) Execute(ctx context.Context, args json.RawMessage) (string, error)

Execute invokes the MCP tool over the per-server Client. Emits mcp_tool_call / mcp_tool_result audit events that carry NO byte payload — only sizes, duration, and reason codes.

func (*MCPTool) InputSchema

func (m *MCPTool) InputSchema() json.RawMessage

InputSchema returns the JSON Schema from discovery, byte-for-byte. The Server's Discovering state has already validated it, so the LLM-function-calling layer can trust it without re-parsing.

func (*MCPTool) MCPSource

func (m *MCPTool) MCPSource()

MCPSource marks this tool as MCP-sourced — required so tools.Registry admits "__" in the name.

func (*MCPTool) Name

func (m *MCPTool) Name() string

Name returns "<server>__<tool>".

type MCPToolOpts

type MCPToolOpts struct {
	// Server is the MCP server name from forge.yaml (e.g. "linear").
	Server string

	// Descriptor is the tool's discovery payload from tools/list.
	Descriptor mcp.MCPToolDescriptor

	// Client is the per-server JSON-RPC client. Required.
	Client mcp.Client

	// MaxResultChars truncates tool results above this size. 0 ⇒ default.
	MaxResultChars int

	// Audit emits mcp_tool_call / mcp_tool_result events. May be nil
	// for tests; production wiring always passes one.
	Audit *runtime.AuditLogger
}

MCPToolOpts configures a new MCPTool.

Jump to

Keyboard shortcuts

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