naming

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package naming turns operations into MCP tool names, IDs and descriptions (SPEC §3.5 rules 1 and 2). It is pure and deterministic: the same input always yields the same names, whatever order it arrives in.

Index

Constants

View Source
const DefaultMaxDescription = 1024

DefaultMaxDescription caps tool descriptions, in runes.

View Source
const MaxNameLen = 64

MaxNameLen is the longest MCP tool name PlugIt produces.

Variables

This section is empty.

Functions

func Assign

func Assign(cands []Candidate, prefix string) map[model.OpKey]string

Assign names every candidate: optional prefix, sanitize, truncate to MaxNameLen, then dedupe case-insensitively with _2, _3, ... suffixes (truncating the base so the suffix fits). Candidates are processed in sorted OpKey order, so results don't depend on input order. Duplicate keys are named once.

func BaseName

func BaseName(operationID, method, path string) string

BaseName is the unprefixed, sanitized name for an operation: its operationId, or "{method}_{path}" with braces removed.

func CleanText

func CleanText(s string, maxRunes int) string

CleanText applies Describe's cleaning to arbitrary spec text (parameter and schema descriptions, titles, warnings) and caps it at maxRunes (DefaultMaxDescription when maxRunes <= 0). It may return "".

func Describe

func Describe(summary, description, method, path string, maxRunes int) string

Describe picks a tool description: summary, then description, then "METHOD /path". Text is cleaned (HTML and markdown links stripped, control, bidi and other invisible format characters removed, whitespace collapsed) and capped at maxRunes (DefaultMaxDescription when maxRunes <= 0).

func Hidden

func Hidden(s string) string

Hidden says what cleaning would silently remove from s that a reader never sees but a model might act on: invisible or bidi format characters, control characters (other than line breaks and tabs) or an HTML comment. It returns "" when there is nothing of the sort.

func Sanitize

func Sanitize(s string) string

Sanitize maps s onto [A-Za-z0-9_-]: other characters become '_', runs of '_' collapse, and leading or trailing '_' are trimmed. An empty result becomes "tool".

func ToolID

func ToolID(key model.OpKey) string

ToolID returns the first 8 hex characters of sha256(key).

Types

type Candidate

type Candidate struct {
	Key         model.OpKey
	OperationID string
}

Candidate is one operation to name.

Jump to

Keyboard shortcuts

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