Documentation
¶
Overview ¶
Package mcpclient lets each user connect their own third-party MCP servers and use those servers' tools inside Chat.
The integration rests on two decisions documented in doc/mcp-client-prd.md: tool definitions are a snapshot the user has explicitly accepted (they are never a live view of the upstream server), and no upstream connection outlives the call that opened it. Together they mean assembling tools for a Chat run performs no network I/O at all.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasEnabledTools ¶
HasEnabledTools reports whether the actor currently has any remote tool in play. Chat uses it to add the external-content trust rules to the system prompt only for the users those rules apply to.
func Register ¶
Register attaches the MCP server management routes.
Reading and deleting a server use PocketBase's own collection rules. Writes go through these routes because they enforce the two invariants the feature rests on: credentials stay write-only, and tool definitions only ever come from a refresh the user accepted.
func SeedPresets ¶
SeedPresets gives an account the preset endpoints, disabled and with no tool definitions. The user still has to refresh each server and choose tools, so a preset reaches Chat only after the same review every other server goes through. Slugs already present are left alone, so this is safe to re-run.
func Tools ¶
Tools returns the assistant tools an actor's MCP servers contribute.
This is called while a Chat run is being assembled and performs no network I/O: every definition comes from the database. An unreachable server therefore cannot delay a run's first token or take the built-in workspace tools down with it.
Types ¶
type Server ¶
type Server struct {
ID string
Name string
Slug string
Transport string
URL string
Headers map[string]string
ApprovalPolicy string
Enabled bool
Tools []ToolDefinition
}
Server is the decoded form of an mcp_servers record.
func (Server) EnabledTools ¶
func (s Server) EnabledTools() []ToolDefinition
EnabledTools returns the definitions this server contributes to a Chat run. A disabled server contributes nothing regardless of what it has stored.
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters map[string]any `json:"parameters"`
Required []string `json:"required"`
Enabled bool `json:"enabled"`
Approval string `json:"approval"`
Hash string `json:"hash"`
// Stale marks a definition that a call indicated no longer matches
// upstream. It is a suspicion raised for the user, not a confirmed change.
Stale bool `json:"stale"`
}
ToolDefinition is one locked tool. It is the complete description the assistant is given: nothing is read from upstream when a call is made.
func (ToolDefinition) RequiresApproval ¶
func (t ToolDefinition) RequiresApproval() bool
RequiresApproval reports whether a call must pass the Chat approval gate. Only the stored value is consulted; upstream annotations are advisory input at review time and never affect runtime behaviour.