Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v0.6.16 Latest Latest
Warning

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

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

Documentation

Overview

Package server provides the MCP (Model Context Protocol) server implementation for ToolHive.

Index

Constants

View Source
const (
	// DefaultMCPPort is the default port for the MCP server
	// 4483 represents "HIVE" on a phone keypad (4=HI, 8=V, 3=E)
	DefaultMCPPort = "4483"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host string
	Port string
}

Config holds the configuration for the MCP server

type Handler

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

Handler handles MCP tool requests for ToolHive

func NewHandler

func NewHandler(ctx context.Context) (*Handler, error)

NewHandler creates a new ToolHive handler

func (*Handler) GetServerLogs

func (h *Handler) GetServerLogs(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

GetServerLogs gets logs from a running MCP server

func (*Handler) ListSecrets added in v0.3.8

func (h *Handler) ListSecrets(ctx context.Context, _ mcp.CallToolRequest) (*mcp.CallToolResult, error)

ListSecrets lists all available secrets. The request parameter is required by the MCP tool handler interface but not used by this handler since list_secrets takes no arguments.

func (*Handler) ListServers

func (h *Handler) ListServers(ctx context.Context, _ mcp.CallToolRequest) (*mcp.CallToolResult, error)

ListServers lists all running MCP servers

func (*Handler) RemoveServer

func (h *Handler) RemoveServer(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

RemoveServer removes a stopped MCP server

func (*Handler) RunServer

func (h *Handler) RunServer(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

RunServer runs an MCP server

func (*Handler) SearchRegistry

func (h *Handler) SearchRegistry(_ context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

SearchRegistry searches the ToolHive registry

func (*Handler) SetSecret added in v0.3.8

func (h *Handler) SetSecret(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

SetSecret sets a secret by reading its value from a file

func (*Handler) StopServer

func (h *Handler) StopServer(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error)

StopServer stops a running MCP server

type Info

type Info struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Transport   string   `json:"transport"`
	Image       string   `json:"image,omitempty"`
	Args        []string `json:"args,omitempty"`
	Tools       []string `json:"tools,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

Info represents server information returned by search

type ListSecretsResponse added in v0.3.8

type ListSecretsResponse struct {
	Secrets []SecretInfo `json:"secrets"`
}

ListSecretsResponse represents the response from listing secrets

type ListServersResponse added in v0.2.14

type ListServersResponse struct {
	Servers []WorkloadInfo `json:"servers"`
}

ListServersResponse represents the response from listing servers

type SearchRegistryResponse added in v0.2.14

type SearchRegistryResponse struct {
	Servers []Info `json:"servers"`
}

SearchRegistryResponse represents the response from searching the registry

type SecretInfo added in v0.3.8

type SecretInfo struct {
	Key string `json:"key"`
	// Description is populated by secrets providers that support it (e.g., 1Password
	// provides "Vault :: Item :: Field" descriptions). Will be empty for providers
	// that don't support descriptions (e.g., encrypted provider).
	Description string `json:"description,omitempty"`
}

SecretInfo represents secret information returned by list

type SecretMapping added in v0.3.8

type SecretMapping struct {
	Name   string `json:"name"`
	Target string `json:"target"`
}

SecretMapping represents a secret name and its target environment variable. Note: Description is not included because it's only relevant for listing/discovery (see SecretInfo). When mapping secrets to a running server, only the name and target environment variable are needed.

type Server

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

Server represents the ToolHive MCP server

func New

func New(ctx context.Context, config *Config) (*Server, error)

New creates a new ToolHive MCP server

func (*Server) GetAddress

func (s *Server) GetAddress() string

GetAddress returns the server address

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the MCP server

func (*Server) Start

func (s *Server) Start() error

Start starts the MCP server

type SetSecretResponse added in v0.3.8

type SetSecretResponse struct {
	Status string `json:"status"`
	Name   string `json:"name"`
}

SetSecretResponse represents the response from setting a secret

type WorkloadInfo

type WorkloadInfo struct {
	Name      string `json:"name"`
	Server    string `json:"server,omitempty"`
	Status    string `json:"status"`
	CreatedAt string `json:"created_at"`
	URL       string `json:"url,omitempty"`
}

WorkloadInfo represents workload information returned by list

Jump to

Keyboard shortcuts

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