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 ¶
- func BuildReverseDNSName(simpleName string) string
- func ExtractServerName(reverseDNSName string) string
- func ImageMetadataToServerJSON(name string, imageMetadata *registry.ImageMetadata) (*upstream.ServerJSON, error)
- func NewUpstreamRegistryFromToolhiveRegistry(toolhiveReg *types.Registry) (*types.UpstreamRegistry, error)
- func RemoteServerMetadataToServerJSON(name string, remoteMetadata *registry.RemoteServerMetadata) (*upstream.ServerJSON, error)
- func ServerJSONToImageMetadata(serverJSON *upstream.ServerJSON) (*types.ImageMetadata, error)
- func ServerJSONToRemoteServerMetadata(serverJSON *upstream.ServerJSON) (*types.RemoteServerMetadata, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildReverseDNSName ¶
BuildReverseDNSName builds a reverse-DNS format name from a simple name Example: "fetch" -> "io.github.stacklok/fetch"
func ExtractServerName ¶
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.