toolname

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package toolname provides shared tool name conversion between original namespaced format (serverID__toolName) and JavaScript-friendly camelCase format (serverIdToolName).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNamespaced

func IsNamespaced(name string) bool

IsNamespaced checks if a tool name is in namespaced format (contains "__").

func ParseNamespacedName

func ParseNamespacedName(name string) (serverID, toolName string, ok bool)

ParseNamespacedName parses a namespaced tool name (serverID__toolName) into its parts. Returns serverID, toolName, and true if the name contains "__". Returns "", name, false if the name is not namespaced.

func ToJSName

func ToJSName(name string) string

ToJSName converts a tool name to a valid JS method name (camelCase). Examples:

  • github__search_repos -> githubSearchRepos
  • get_code_context_exa -> getCodeContextExa
  • my-tool-name -> myToolName

Types

type Mapper

type Mapper struct {
	// contains filtered or unexported fields
}

Mapper maintains bidirectional mapping between original and JS method names.

func NewMapper

func NewMapper(tools []*mcp.Tool) *Mapper

NewMapper creates a mapper from a list of tools.

func NewMapperWithCollisionCheck

func NewMapperWithCollisionCheck(tools []*mcp.Tool) (*Mapper, error)

NewMapperWithCollisionCheck creates a mapper and returns an error if any tool names would collide after JS name conversion.

func (*Mapper) Resolve

func (m *Mapper) Resolve(name string) (string, bool)

Resolve attempts to resolve a tool name to its original format. It accepts both JS names (camelCase) and original names (serverID__toolName). Returns the original name and true if found, or the input and false if not found.

func (*Mapper) ToJSName

func (m *Mapper) ToJSName(original string) string

ToJSName converts an original tool name to its JS method name.

func (*Mapper) ToOriginal

func (m *Mapper) ToOriginal(jsName string) string

ToOriginal converts a JS method name back to its original tool name. Returns the input unchanged if not found (allows pass-through for original names).

Jump to

Keyboard shortcuts

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