thvclient

package
v0.20260306.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package thvclient provides a client for interacting with the ToolHive CLI to run MCP servers and discover their available tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRunCommand

func BuildRunCommand(
	sf *serverjson.ServerFile,
	ext *registry.ServerExtensions,
	tempName, image string,
) []string

BuildRunCommand builds thv run arguments from a ServerFile and extensions.

func ParseToolDefinitions

func ParseToolDefinitions(output string) ([]mcp.Tool, error)

ParseToolDefinitions parses JSON output from thv mcp list tools --format json into full mcp.Tool definitions. Returns nil (not an error) if the output is text-only, since text format contains only tool names.

func ParseToolsJSON

func ParseToolsJSON(output string) ([]string, error)

ParseToolsJSON parses JSON output from thv mcp list tools --format json. Falls back to text parsing if JSON parsing fails.

func ParseToolsText

func ParseToolsText(output string) ([]string, error)

ParseToolsText parses text output from thv mcp list (fallback parser).

Types

type Client

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

Client interacts with the ToolHive CLI (thv) to run MCP servers and discover their available tools.

func NewClient

func NewClient(thvPath string, verbose bool) (*Client, error)

NewClient creates a new ToolHive client. If thvPath is empty, it searches PATH.

func (*Client) ListToolDefinitions

func (c *Client) ListToolDefinitions(serverName string) ([]mcp.Tool, error)

ListToolDefinitions queries a running MCP server for full tool definitions. Returns nil (not an error) if the output is text-only.

func (*Client) ListTools

func (c *Client) ListTools(serverName string) ([]string, error)

ListTools queries a running MCP server for its tools.

func (*Client) Logs

func (c *Client) Logs(serverName string) (string, error)

Logs retrieves logs from a running MCP server.

func (*Client) RunServer

func (c *Client) RunServer(sf *serverjson.ServerFile, serverName string) (string, error)

RunServer starts a temporary MCP server from a server.json file. Returns the temporary server name for subsequent operations.

func (*Client) StopServer

func (c *Client) StopServer(serverName string) error

StopServer stops a running MCP server.

type CommandBuilder

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

CommandBuilder helps build command line arguments for thv.

func NewCommandBuilder

func NewCommandBuilder(command string) *CommandBuilder

NewCommandBuilder creates a new command builder with the given base command.

func (*CommandBuilder) AddBoolFlag

func (b *CommandBuilder) AddBoolFlag(flag string, value bool) *CommandBuilder

AddBoolFlag adds a boolean flag when value is true.

func (*CommandBuilder) AddEnvVar

func (b *CommandBuilder) AddEnvVar(name, value string) *CommandBuilder

AddEnvVar adds an environment variable flag (-e NAME=value).

func (*CommandBuilder) AddFlag

func (b *CommandBuilder) AddFlag(flag, value string) *CommandBuilder

AddFlag adds a flag with a value. No-op if value is empty.

func (*CommandBuilder) AddPositional

func (b *CommandBuilder) AddPositional(value string) *CommandBuilder

AddPositional adds a positional argument.

func (*CommandBuilder) Build

func (b *CommandBuilder) Build() []string

Build returns the built command arguments.

Jump to

Keyboard shortcuts

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