Documentation
¶
Index ¶
Constants ¶
const ( CodeInstructionsTooLarge = "INSTRUCTIONS_TOO_LARGE" CodeMCPServerUnreachable = "MCP_SERVER_UNREACHABLE" CodeMCPTooManyServers = "MCP_TOO_MANY_SERVERS_ENABLED" CodeMCPTooManyToolsTotal = "MCP_TOO_MANY_TOOLS_TOTAL" CodeMCPServerTooManyTools = "MCP_SERVER_TOO_MANY_TOOLS" CodeMCPToolSchemaBloatTotal = "MCP_TOOL_SCHEMA_BLOAT_TOTAL" CodeMCPToolSchemaBloatServer = "MCP_TOOL_SCHEMA_BLOAT_SERVER" CodeMCPToolNameCollision = "MCP_TOOL_NAME_COLLISION" )
Warning codes.
Variables ¶
var NewMCPClientFunc = func(impl *mcp.Implementation, opts *mcp.ClientOptions) mcpClientInterface { return &realMCPClient{client: mcp.NewClient(impl, opts)} }
NewMCPClientFunc is a mockable function for creating MCP clients.
Functions ¶
func EstimateTokens ¶
EstimateTokens estimates the token count for a given UTF-8 string using a heuristic. Heuristic: T = max(ceil(B/3), ceil(R/4)) * 1.10 where B is the byte length and R is the rune count.
Types ¶
type Connector ¶
type Connector interface {
ConnectAndDiscover(ctx context.Context, server ResolvedMCPServer) DiscoveryResult
}
Connector interface for mocking.
type DiscoveryResult ¶
DiscoveryResult contains the results of discovering tools from an MCP server.
type RealConnector ¶
type RealConnector struct{}
RealConnector implements Connector using the SDK.
func (*RealConnector) ConnectAndDiscover ¶
func (r *RealConnector) ConnectAndDiscover(ctx context.Context, server ResolvedMCPServer) DiscoveryResult
ConnectAndDiscover connects to an MCP server and discovers its tools.
type ResolvedMCPServer ¶
type ResolvedMCPServer struct {
ID string
Transport string
URL string // for http
Headers map[string]string
Command string // for stdio
Args []string
Env map[string]string
}
ResolvedMCPServer holds configuration for an MCP server with environment variables resolved.
type ToolDef ¶
type ToolDef struct {
Name string
}
ToolDef represents a discovered tool from an MCP server.
type Warning ¶
Warning represents a warning message.
func CheckInstructions ¶
CheckInstructions checks if the combined instruction payload exceeds the threshold. rootDir is the project root directory; threshold is the max token count (nil disables warnings). It returns any warnings and an error if the payload cannot be read.
func CheckMCPServers ¶
func CheckMCPServers(ctx context.Context, cfg *config.ProjectConfig, connector Connector) ([]Warning, error)
CheckMCPServers performs discovery on enabled MCP servers and checks against warning thresholds. cfg supplies the configured thresholds; nil thresholds disable the corresponding warnings.