Documentation
¶
Overview ¶
Package thvclient provides a client for interacting with the ToolHive CLI to run MCP servers and discover their available tools.
Index ¶
- func BuildRunCommand(sf *serverjson.ServerFile, ext *registry.ServerExtensions, ...) []string
- func ParseToolDefinitions(output string) ([]mcp.Tool, error)
- func ParseToolsJSON(output string) ([]string, error)
- func ParseToolsText(output string) ([]string, error)
- type Client
- func (c *Client) ListToolDefinitions(serverName string) ([]mcp.Tool, error)
- func (c *Client) ListTools(serverName string) ([]string, error)
- func (c *Client) Logs(serverName string) (string, error)
- func (c *Client) RunServer(sf *serverjson.ServerFile, serverName string) (string, error)
- func (c *Client) StopServer(serverName string) error
- type CommandBuilder
- func (b *CommandBuilder) AddBoolFlag(flag string, value bool) *CommandBuilder
- func (b *CommandBuilder) AddEnvVar(name, value string) *CommandBuilder
- func (b *CommandBuilder) AddFlag(flag, value string) *CommandBuilder
- func (b *CommandBuilder) AddPositional(value string) *CommandBuilder
- func (b *CommandBuilder) Build() []string
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 ¶
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 ¶
ParseToolsJSON parses JSON output from thv mcp list tools --format json. Falls back to text parsing if JSON parsing fails.
func ParseToolsText ¶
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 (*Client) ListToolDefinitions ¶
ListToolDefinitions queries a running MCP server for full tool definitions. Returns nil (not an error) if the output is text-only.
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 ¶
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.