Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:1broseidon Ketch config NormalizeMCPTools

From Leeroopedia
Knowledge Sources
Domains MCP, Configuration
Last Updated 2026-10-27 00:00 GMT

Overview

Validates and normalizes the `mcp_tools` allowlist: trims/lowercases, rejects blank/unknown/duplicate names, and returns the result in canonical order so server instructions stay deterministic.

Description

NormalizeMCPTools is the fail-loud validation for the `mcp_tools` config key. Entries are trimmed and lowercased; blank, unknown, and duplicate names are rejected (the error lists the valid names). The result is returned in canonical registration order, regardless of input order. A nil/empty list means "no restriction" and returns nil (publish all six). MCPToolNames returns a copy of the canonical list. Validation runs at `config set`, on the `KETCH_MCP_TOOLS` env override, and at server startup.

Usage

Called by `NewServer` and by the `config set`/env overlay validation paths. Unlisted tools are never registered; `serverInstructions` is generated from the enabled set so a pruned server never advertises what it won't answer.

Code Reference

Source Location

  • Repository: ketch
  • File: config/mcp_tools.go

Signature

var mcpToolNames = []string{"search", "code", "docs", "scrape", "crawl", "tag"}

// MCPToolNames returns a copy of the canonical tool list, in registration order.
func MCPToolNames() []string

// NormalizeMCPTools validates an operator-configured mcp_tools allowlist.
// A nil/empty list means "no restriction" and returns nil.
func NormalizeMCPTools(list []string) ([]string, error)

Import

import "github.com/1broseidon/ketch/config"

I/O Contract

Inputs

Name Type Required Description
list []string No Raw allowlist (JSON array or comma-separated); empty = publish all

Outputs

Name Type Description
return []string Canonical-ordered allowlist, or nil (publish all)
return error error Blank, unknown, or duplicate entry (error lists valid names)

Usage Examples

Validation At Server Startup

tools, err := config.NormalizeMCPTools(cfg.MCPTools)
if err != nil { return err } // [precondition]
if len(tools) == 0 {
	tools = config.MCPToolNames() // publish all six
}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment