Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckToolApproval ¶
CheckToolApproval is called from the tool provider before executing a tool. If the context carries an SSE writer (web chat) and the tool requires approval, it blocks until the user responds. External MCP clients have no SSE writer and skip the check entirely.
func SetManager ¶
func SetManager(m *Manager)
Types ¶
type Event ¶
type Event struct {
RequestID string `json:"request_id"`
InstanceID string `json:"instance_id"`
ToolName string `json:"tool_name"`
Arguments map[string]any `json:"arguments,omitempty"`
ExpiresAt int64 `json:"expires_at"`
}
Event is the JSON payload sent as a tool_approval SSE comment.
type EventWriter ¶
EventWriter is satisfied by rest.StreamWriter (and mcpopenai.SSEEventWriter).
type Forwarder ¶
type Forwarder interface {
ForwardToolApproval(req *ResponseRequest) (bool, error)
}
Forwarder forwards an approval response to the originating instance via gossip.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager tracks pending tool approvals in memory. Each approval is owned by the instance that started the tool call. When a response arrives on a different instance behind a load balancer it is forwarded via gossip.
func GetManager ¶
func GetManager() *Manager
func NewManager ¶
func NewManager() *Manager
func (*Manager) HandleResponse ¶
func (m *Manager) HandleResponse(w http.ResponseWriter, r *http.Request)
HandleResponse is the HTTP handler for POST /v1/chat/tool-approvals.
func (*Manager) Request ¶
func (m *Manager) Request(ctx context.Context, writer EventWriter, userID, toolName string, args map[string]any) error
Request writes a tool_approval SSE event and blocks until the user responds, the timeout expires, or the context is cancelled.
func (*Manager) Respond ¶
func (m *Manager) Respond(req *ResponseRequest) bool
Respond delivers an approval/denial to the waiting Request. Returns false if no matching pending request exists or the user does not own it.