Documentation
¶
Overview ¶
Package mcp holds shared MCP catalog rules: deny-list, include/exclude matching, tool naming, JSON Schema mapping, result envelopes, and self-connect detection.
Index ¶
- Constants
- func AgentToolName(server, remote string) string
- func AttachTrace(result any, trace map[string]any, wrapItems bool) (any, error)
- func Denied(capability, operation string) bool
- func ErrorEnvelope(errObj, trace map[string]any) map[string]any
- func IsAgentTool(name string) bool
- func IsListTool(group, op string) bool
- func IsSelfMCP(rawURL, listen, apiPath string) bool
- func Match(include, exclude []string, group, toolName string) bool
- func OpenWorld(group string) bool
- func OutputSchema(group, op string) map[string]any
- func PermissionKey(server string) string
- func SchemaFromFields(fields []Field) map[string]any
- func ServerFromAgentTool(tool string) (string, bool)
- func Title(group, description string) string
- func ValidServerName(name string) bool
- func ValidateOutput(schema, instance any) error
- func ValidateServerName(name string) error
- type Client
- type Field
- type Snippet
- type SnippetOptions
Constants ¶
const ( // AgentToolPrefix is the chat-agent tool name prefix for external MCP tools. AgentToolPrefix = "mcp_" // PermissionKeyPrefix is the permission key prefix for one MCP server. PermissionKeyPrefix = "mcp." )
const ServerInstructions = "" /* 427-byte string literal not displayed */
ServerInstructions is the MCP initialize instructions string.
Variables ¶
This section is empty.
Functions ¶
func AgentToolName ¶
AgentToolName builds mcp_<server>_<remote> for the chat agent registry.
func AttachTrace ¶
AttachTrace adds trace beside a successful tool result. wrapItems is true only for pipeline.list, workflow.list, function.list, and hub.apps. Those slices become {"items", "trace"}. Objects gain a trace field. A nil result becomes {"trace": trace}.
func ErrorEnvelope ¶
ErrorEnvelope builds the failed structuredContent object.
func IsAgentTool ¶
IsAgentTool reports whether name is an outbound MCP agent tool (mcp_<server>_*).
func IsListTool ¶
IsListTool reports whether group.op is a paged list on /mcp.
func Match ¶
Match reports whether toolName survives include/exclude. An empty include list means all tools. Exclude always wins. A filter item matching the group (capability or MCP server name) or the full tool name is a hit. Callers that expose /mcp must also apply Denied; outbound MCP clients must not.
func OpenWorld ¶
OpenWorld reports whether tools in group may affect systems outside this process. hub, pipeline, workflow, and example stay closed.
func OutputSchema ¶
OutputSchema returns the MCP outputSchema for a tool, or nil when v1.0 does not publish one. Listed tools are pipeline, workflow, and function list/get/run/get_run, hub apps and health, and capability operations whose name contains "list".
func PermissionKey ¶
PermissionKey returns mcp.<server> for permission evaluation.
func SchemaFromFields ¶
SchemaFromFields builds a JSON Schema object for MCP / agent tool parameters.
func ServerFromAgentTool ¶
ServerFromAgentTool extracts the server id from an mcp_<server>_<remote> name.
func ValidServerName ¶
ValidServerName reports whether name is a safe MCP server id (no underscores).
func ValidateOutput ¶
ValidateOutput checks instance against a tool outputSchema.
func ValidateServerName ¶
ValidateServerName returns an error when name is empty or illegal.
Types ¶
type Client ¶
type Client string
Client is a supported MCP client snippet target.
const ( // ClientCodex renders a Codex config.toml table. ClientCodex Client = "codex" // ClientClaude renders a claude mcp add command. ClientClaude Client = "claude" // ClientCursor renders a Cursor mcp.json fragment. ClientCursor Client = "cursor" // ClientGeneric renders a transport-neutral JSON fragment. ClientGeneric Client = "generic" )
type Snippet ¶
type Snippet struct {
Client string `json:"client"`
Target string `json:"target"`
Snippet string `json:"snippet"`
}
Snippet is one printable client configuration.
func RenderSnippet ¶
func RenderSnippet(client Client, opt SnippetOptions) (Snippet, error)
RenderSnippet builds a paste-ready client snippet. The token value is never included.
type SnippetOptions ¶
type SnippetOptions struct {
// Name is the MCP server id. Empty uses flowbot.
Name string
// URL is the Streamable HTTP endpoint.
URL string
// TokenEnv is the environment variable that holds the bearer token. Empty uses FLOWBOT_MCP_TOKEN.
TokenEnv string
// Scope is project or user. Empty uses user for Claude and project for Cursor.
Scope string
// Approval is the Codex default_tools_approval_mode. Empty uses writes. Only Codex accepts it.
Approval string
}
SnippetOptions are the inputs for a client config snippet.