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 mcp buildServerInstructions

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

Overview

Generates the server `initialize` instructions from the published tool set, so a pruned server never advertises tools it won't answer.

Description

buildServerInstructions returns the prose an agent reads on connection. When all six tools are published it reproduces the historic static text byte-for-byte; a pruned set describes only the tools that exist, with the correct kind ("read-only research" vs "research and bookmark"), tool enumeration, routing guidance, and output-bounding advice. registerTools registers only the published tools via `mcpsdk.AddTool`. inputSchema (in mcp/schema.go) applies provider-registry description overrides to the typed input schema.

Usage

Called once in `NewServer`. The instructions and the registered tools always agree because both are derived from the same resolved `tools` list.

Code Reference

Source Location

  • Repository: ketch
  • File: mcp/server.go, mcp/schema.go

Signature

// buildServerInstructions returns the initialize-result instructions for the
// published tool set.
func buildServerInstructions(tools []string) string

// registerTools registers each published tool. Unlisted tools are never registered.
func (s *Server) registerTools()

// inputSchema builds a typed input schema with description overrides.
func inputSchema[In any](descriptions map[string]string) *jsonschema.Schema

Import

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

I/O Contract

Inputs

Name Type Required Description
tools []string Yes Resolved, canonical-ordered tool list

Outputs

Name Type Description
return string Server instructions prose

Usage Examples

Pruned Server

tools := []string{"search", "scrape"} // mcp_tools=["search,scrape"]
instructions := buildServerInstructions(tools)
// Describes only search and scrape; never mentions code/docs/crawl/tag.

Related Pages

Implements Principle

Page Connections

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