mcp

package
v0.99.15 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mcp holds shared MCP catalog rules: deny-list, include/exclude matching, tool naming, JSON Schema mapping, and self-connect detection.

Index

Constants

View Source
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."
)

Variables

This section is empty.

Functions

func AgentToolName

func AgentToolName(server, remote string) string

AgentToolName builds mcp_<server>_<remote> for the chat agent registry.

func Denied

func Denied(capability, operation string) bool

Denied reports whether capability.operation is never exposed on /mcp.

func IsAgentTool

func IsAgentTool(name string) bool

IsAgentTool reports whether name is an outbound MCP agent tool (mcp_<server>_*).

func IsSelfMCP

func IsSelfMCP(rawURL, listen, apiPath string) bool

IsSelfMCP reports whether rawURL would reach this process's /mcp endpoint.

func Match

func Match(include, exclude []string, group, toolName string) bool

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 PermissionKey

func PermissionKey(server string) string

PermissionKey returns mcp.<server> for permission evaluation.

func SchemaFromFields

func SchemaFromFields(fields []Field) map[string]any

SchemaFromFields builds a JSON Schema object for MCP / agent tool parameters.

func ServerFromAgentTool

func ServerFromAgentTool(tool string) (string, bool)

ServerFromAgentTool extracts the server id from an mcp_<server>_<remote> name.

func ValidServerName

func ValidServerName(name string) bool

ValidServerName reports whether name is a safe MCP server id (no underscores).

func ValidateServerName

func ValidateServerName(name string) error

ValidateServerName returns an error when name is empty or illegal.

Types

type Field

type Field struct {
	Name        string
	Type        string
	Description string
	Required    bool
}

Field is one JSON-object property used to build an MCP input schema.

Jump to

Keyboard shortcuts

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