conversion

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package conversion provides utilities for converting between MCP SDK types and vmcp wrapper types. This package centralizes conversion logic to ensure consistency and eliminate duplication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContentArrayToMap

func ContentArrayToMap(content []vmcp.Content) map[string]any

ContentArrayToMap converts a vmcp.Content array to a map for template variable substitution. This is used by composite tool workflows and backend result handling.

Conversion rules:

  • First text content: key="text"
  • Subsequent text content: key="text_1", "text_2", etc.
  • Image content: key="image_0", "image_1", etc.
  • Audio content: ignored (not supported for template substitution)
  • Resource content: ignored (handled separately, not converted to map)
  • Unknown content types: ignored (warnings logged at conversion boundaries)

This ensures consistent behavior between client response handling and workflow step output processing.

func FromMCPMeta

func FromMCPMeta(meta *mcp.Meta) map[string]any

FromMCPMeta converts MCP SDK meta to map[string]any for vmcp wrapper types. This preserves the _meta field from backend MCP server responses.

Returns nil if meta is nil or empty, following the MCP specification that _meta is optional and should be omitted when empty.

func ToMCPMeta

func ToMCPMeta(meta map[string]any) *mcp.Meta

ToMCPMeta converts vmcp meta map to MCP SDK meta for forwarding to clients. This reconstructs the _meta field when sending responses back through the MCP protocol.

Returns nil if meta is nil or empty, following the MCP specification that _meta is optional and should be omitted when empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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