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 NewAPITool ¶ added in v0.18.1
NewAPITool builds a per-op API tool.
func NewWebhookCallTool ¶
NewWebhookCallTool creates a webhook call tool.
Types ¶
type AuthGate ¶ added in v0.18.1
AuthGate turns "this user has no grant yet" from a hard failure into a pause-and-resume. When resolving the per-user connection returns mcp.ErrNoToken, Execute calls Await instead of failing; the runtime implementation parks the executor on the authgate engine, delivers a consent prompt, and returns once a grant exists (→ nil, Execute re-resolves and proceeds) or the wait ends without one (→ error, Execute gives up). Implemented in forge-cli/runtime; nil in core/tests.
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 ¶
Category is always CategoryAdapter — MCP tools are external adapters by definition.
func (*MCPTool) Description ¶
Description forwards the MCP server's description.
func (*MCPTool) Execute ¶
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.
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. Used when Resolver is nil.
Client mcp.Client
// Resolver selects the Client per call (#317). Preferred over Client
// when set; the runtime passes the ToolHandle's resolver so a
// per-subject-pool server routes each call to the requesting user's
// connection. Optional — nil falls back to Client.
Resolver mcp.ClientResolver
// AuthGate parks a delegated call lacking a grant until the requesting
// user consents (#330). Optional — nil disables gating (ErrNoToken fails
// the call as before). The runtime passes its authgate-backed impl for
// type=user servers.
AuthGate AuthGate
// 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.