conversions

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package conversions provides bidirectional type conversion between Go values and Starlark values, MCP result parsing, and tool name sanitization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoToStarlark

func GoToStarlark(v interface{}) (starlark.Value, error)

GoToStarlark converts a Go value to a Starlark value.

func ParseToolResult

func ParseToolResult(result *mcp.CallToolResult) (interface{}, error)

ParseToolResult converts an mcp.CallToolResult into a Go value suitable for Starlark consumption.

It handles multiple response formats:

  • Structured content with the mcp-go SDK {"result": v} wrapper pattern
  • Structured content without the wrapper
  • Text content parsed as JSON
  • Plain text returned as-is
  • Multi-item responses (first text item used)
  • Error results returned as an error

func SanitizeName

func SanitizeName(name string) string

SanitizeName converts an MCP tool name into a valid Starlark identifier. Characters that are not alphanumeric or underscore are replaced with underscores. Leading digits get a prefix underscore.

func StarlarkToGo

func StarlarkToGo(v starlark.Value) interface{}

StarlarkToGo converts a Starlark value to a Go value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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