converters

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package converters provides bidirectional conversion between toolhive registry formats and the upstream MCP (Model Context Protocol) ServerJSON format.

The package supports two conversion directions:

  • toolhive → upstream: ImageMetadata/RemoteServerMetadata → ServerJSON (this file)
  • upstream → toolhive: ServerJSON → ImageMetadata/RemoteServerMetadata (upstream_to_toolhive.go)

Toolhive-specific fields (permissions, provenance, metadata) are stored in the upstream format's publisher extensions under "io.github.stacklok", allowing additional metadata while maintaining compatibility with the standard MCP registry format.

Package converters provides conversion functions from upstream MCP ServerJSON format to toolhive ImageMetadata/RemoteServerMetadata formats.

Package converters provides utility functions for conversion between upstream and toolhive formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildReverseDNSName

func BuildReverseDNSName(simpleName string) string

BuildReverseDNSName builds a reverse-DNS format name from a simple name Example: "fetch" -> "io.github.stacklok/fetch"

func ExtractServerName

func ExtractServerName(reverseDNSName string) string

ExtractServerName extracts the simple server name from a reverse-DNS format name Example: "io.github.stacklok/fetch" -> "fetch"

func ImageMetadataToServerJSON

func ImageMetadataToServerJSON(name string, imageMetadata *registry.ImageMetadata) (*upstream.ServerJSON, error)

ImageMetadataToServerJSON converts toolhive ImageMetadata to an upstream ServerJSON The name parameter is deprecated and should match imageMetadata.Name. It's kept for backward compatibility.

func NewUpstreamRegistryFromToolhiveRegistry added in v0.6.6

func NewUpstreamRegistryFromToolhiveRegistry(toolhiveReg *types.Registry) (*types.UpstreamRegistry, error)

NewUpstreamRegistryFromToolhiveRegistry creates a UpstreamRegistry from ToolHive Registry. This converts ToolHive format to upstream ServerJSON using the converters package. Used when ingesting data from ToolHive-format sources (Git, File, API).

func RemoteServerMetadataToServerJSON

func RemoteServerMetadataToServerJSON(name string, remoteMetadata *registry.RemoteServerMetadata) (*upstream.ServerJSON, error)

RemoteServerMetadataToServerJSON converts toolhive RemoteServerMetadata to an upstream ServerJSON The name parameter is deprecated and should match remoteMetadata.Name. It's kept for backward compatibility.

func ServerJSONToImageMetadata

func ServerJSONToImageMetadata(serverJSON *upstream.ServerJSON) (*types.ImageMetadata, error)

ServerJSONToImageMetadata converts an upstream ServerJSON (with OCI packages) to toolhive ImageMetadata This function only handles OCI packages and will error if there are multiple OCI packages

func ServerJSONToRemoteServerMetadata

func ServerJSONToRemoteServerMetadata(serverJSON *upstream.ServerJSON) (*types.RemoteServerMetadata, error)

ServerJSONToRemoteServerMetadata converts an upstream ServerJSON (with remotes) to toolhive RemoteServerMetadata This function extracts remote server data and reconstructs RemoteServerMetadata format

Types

This section is empty.

Jump to

Keyboard shortcuts

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