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 ¶
- func New(cfg Config, deps Deps) (capacp.SessionMCPProvider, error)
- type Config
- type Deps
- type HeaderBind
- type Provider
- func (p *Provider) BeginMCPTurn(ctx context.Context) (context.Context, func() error, error)
- func (p *Provider) Close() error
- func (p *Provider) Refresh(ctx context.Context) error
- func (p *Provider) ReleaseMCPSession(ctx context.Context)
- func (p *Provider) SessionMCPServers(ctx context.Context) ([]capacp.SessionMCPServer, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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) Refresh ¶
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 (*Provider) SessionMCPServers ¶
SessionMCPServers implements capacp.SessionMCPProvider.