Implementation:1broseidon Ketch mcp buildServerInstructions
| 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.