sessionmcptools

package
v0.4.44 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package sessionmcptools exposes a ToolProvider or ToolRuntime to an external ACP agent as a loopback streamable-http MCP server. Runtime mode preserves turn state and the policy/approval pipeline through cap/acp's turn lifecycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cfg Config, deps Deps) (capacp.SessionMCPProvider, error)

New registers acp/session-mcp-tools: streamable-http MCP over a tool provider or runtime.

Types

type Config

type Config struct {
	// APIToken enables a loopback Bearer check. Empty disables it (local only).
	APIToken string `json:"apiToken,omitempty"`
	// ServerName is the MCP server name announced to the agent.
	ServerName string `json:"serverName,omitempty"`
	// Headers are static extra headers for the ACP session/new spec.
	Headers map[string]string `json:"headers,omitempty"`
	// Bind maps turn-context fields to session headers and restores them on
	// inbound tool calls, preserving the session, user, workspace and route.
	Bind map[string]HeaderBind `json:"bind,omitempty"`
}

Config configures the loopback MCP endpoint.

type Deps

type Deps struct {
	// Provider is the legacy direct-tool backend; mutually exclusive with Runtime.
	Provider agentkit.ToolProvider `json:"provider,omitempty"`
	// Runtime preserves visibility, policy, approval, and execution semantics.
	Runtime   agentkit.ToolRuntime `json:"runtime,omitempty"`
	Workspace workspace.Service    `json:"workspace,omitempty"`
}

Deps selects exactly one tool source and the workspace used to resolve paths.

type HeaderBind

type HeaderBind struct {
	From string `json:"from"`
	In   string `json:"in"`
	Name string `json:"name"`
}

HeaderBind mirrors the header-bind shape hosts already use: From is a ctx: source, In is the transport slot, Name the wire name.

type Provider

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

Provider implements SessionMCPProvider and the optional turn lifecycle.

func (*Provider) BeginMCPTurn added in v0.4.40

func (p *Provider) BeginMCPTurn(ctx context.Context) (context.Context, func() error, error)

BeginMCPTurn keeps transport identity stable while replacing execution state. Peers without a per-request turn ID are routed by session; a late request that arrives during the next turn cannot be distinguished from that turn's work.

func (*Provider) Close

func (p *Provider) Close() error

Close stops the loopback server.

func (*Provider) Refresh

func (p *Provider) Refresh(ctx context.Context) error

Refresh re-reads the provider's tools into the MCP registry. Call it after a runtime change (an OpenAPI reload, an MCP client discovery); it is safe to call concurrently with in-flight calls.

func (*Provider) ReleaseMCPSession added in v0.4.40

func (p *Provider) ReleaseMCPSession(ctx context.Context)

func (*Provider) SessionMCPServers

func (p *Provider) SessionMCPServers(ctx context.Context) ([]capacp.SessionMCPServer, error)

SessionMCPServers implements capacp.SessionMCPProvider.

Jump to

Keyboard shortcuts

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