Documentation
¶
Index ¶
- Variables
- func RunServeFromRoot(ctx context.Context, cmd *ucli.Command) error
- type ConfigClient
- func (c *ConfigClient) CallTool(ctx context.Context, namespacedName string, params json.RawMessage) (*mcp.CallToolResult, error)
- func (c *ConfigClient) Close() error
- func (c *ConfigClient) GetTool(ctx context.Context, namespacedName string) (*mcp.Tool, error)
- func (c *ConfigClient) ListTools(ctx context.Context) ([]*mcp.Tool, error)
- type RemoteClient
- func (c *RemoteClient) CallTool(ctx context.Context, name string, params json.RawMessage) (*mcp.CallToolResult, error)
- func (c *RemoteClient) Close() error
- func (c *RemoteClient) GetTool(ctx context.Context, name string) (*mcp.Tool, error)
- func (c *RemoteClient) ListTools(ctx context.Context) ([]*mcp.Tool, error)
- type RemoteClientOpts
- type StdioClient
- func (c *StdioClient) CallTool(ctx context.Context, name string, params json.RawMessage) (*mcp.CallToolResult, error)
- func (c *StdioClient) Close() error
- func (c *StdioClient) GetTool(ctx context.Context, name string) (*mcp.Tool, error)
- func (c *StdioClient) ListTools(ctx context.Context) ([]*mcp.Tool, error)
- type StdioClientOpts
Constants ¶
This section is empty.
Variables ¶
var CurrentVersion string
CurrentVersion is set from main.go
var ExecCmd = &ucli.Command{
Name: "exec",
Usage: "Execute JavaScript code to orchestrate multiple MCP tool calls",
ArgsUsage: "<code | ->",
Description: `Execute JavaScript code that can call multiple MCP tools with logic.
Use this when you need to:
- Chain multiple tool calls
- Process data between calls
- Use conditionals or loops
- Aggregate results
For single tool calls, use 'invoke' instead.
The 'mcp.callTool(name, params)' function is available to call tools.
Tool names can be in either format:
- JS name (camelCase): githubSearchRepos
- Original name: github__search_repos
Examples:
# Chain tool calls (config mode)
mh -c config.json exec 'const user = mcp.callTool("dbGetUser", {id: 1}); mcp.callTool("emailSend", {to: user.email})'
# Read code from stdin
cat script.js | mh -c config.json exec -
# With remote server (use tool names directly)
mh -u http://localhost:3000 exec 'const a = mcp.callTool("add", {x: 1, y: 2}); mcp.callTool("multiply", {x: a, y: 3})'
# With stdio server (use tool names directly)
mh --stdio exec 'mcp.callTool("echo", {message: "hello"})' -- npx @modelcontextprotocol/server-everything
# JSON output
mh -c config.json exec --json 'mcp.callTool("githubListRepos", {})'`,
Action: runExec,
}
ExecCmd is the exec subcommand that executes JavaScript code against MCP tools
var InspectCmd = &ucli.Command{
Name: "inspect",
Usage: "Inspect a tool from an MCP service",
ArgsUsage: "<tool-name>",
Description: `Show detailed information about a specific tool from an MCP service.
Provide --url (-u) for a remote MCP service, --config (-c) to load local
stdio/http/sse servers from config, or --stdio to spawn a subprocess.
Takes tool name as a required positional argument.
Tool names can be in either format:
- JS name (camelCase): githubSearchRepos
- Original name: github__search_repos
Examples:
# Inspect a tool
mh -u http://localhost:3000 inspect myTool
# Inspect a tool with JSON output
mh -u http://localhost:3000 inspect myTool --json
# Inspect a tool using SSE transport
mh -u http://localhost:3000 -t sse inspect myTool
# Inspect a tool from config (stdio/http/sse)
mh -c config.json inspect githubSearchRepos
# Inspect a tool from a stdio MCP server
mh --stdio inspect echo -- npx @modelcontextprotocol/server-everything`,
Action: runInspect,
}
InspectCmd is the inspect subcommand that shows details of a specific tool
var InvokeCmd = &ucli.Command{
Name: "invoke",
Usage: "Invoke a tool on an MCP service",
ArgsUsage: "<tool-name> [params-json | -]",
Description: `Invoke a tool on an MCP service with optional JSON parameters.
Provide --url (-u) for a remote MCP service, --config (-c) to load local
stdio/http/sse servers from config, or --stdio to spawn a subprocess.
Takes tool name as a required positional argument.
Parameters can be provided as:
- A JSON string argument
- "-" to read JSON from stdin
- Omitted for tools with no required parameters
Tool names can be in either format:
- JS name (camelCase): githubSearchRepos
- Original name: github__search_repos
Examples:
# Invoke a tool with no parameters
mh -u http://localhost:3000 invoke myTool
# Invoke a tool with JSON parameters
mh -u http://localhost:3000 invoke myTool '{"key": "value"}'
# Invoke a tool with parameters from stdin
echo '{"key": "value"}' | mh -u http://localhost:3000 invoke myTool -
# Invoke a tool with JSON output
mh -u http://localhost:3000 invoke myTool '{"key": "value"}' --json
# Invoke a tool from config (stdio/http/sse)
mh -c config.json invoke githubSearchRepos '{"query": "mcp"}'
# Invoke a tool from a stdio MCP server
mh --stdio invoke echo '{"message": "hello"}' -- npx @modelcontextprotocol/server-everything`,
Action: runInvoke,
}
InvokeCmd is the invoke subcommand that invokes a tool on an MCP service
var ListCmd = &ucli.Command{ Name: "list", Usage: "List tools from an MCP service", Description: `List all available tools from an MCP service. Provide --url (-u) for a remote MCP service, --config (-c) to load local stdio/http/sse servers from config, or --stdio to spawn a subprocess. Examples: # List tools from a remote server mh -u http://localhost:3000 list # List tools with JSON output mh -u http://localhost:3000 list --json # List tools using SSE transport mh -u http://localhost:3000 -t sse list # List tools from config (stdio/http/sse) mh -c config.json list # List tools filtered by server mh -c config.json list --server github # List tools filtered by keywords mh -c config.json list --query "search,file" # List tools from a stdio MCP server mh --stdio list -- npx @modelcontextprotocol/server-everything`, Flags: []ucli.Flag{ &ucli.StringFlag{ Name: "server", Usage: "filter tools by server name", }, &ucli.StringFlag{ Name: "query", Usage: "comma-separated keywords for search (matches name or description)", }, }, Action: runList, }
ListCmd is the list subcommand that lists tools from an MCP service
var ServeCmd = &ucli.Command{ Name: "serve", Usage: "Start the MCP hub server", Description: `Start the MCP hub server with the specified transport. Transport Types: stdio - Standard input/output (default, for CLI integration) http - HTTP server with StreamableHTTP protocol sse - HTTP server with Server-Sent Events protocol Examples: # Run with stdio transport (default) mh serve -c config.json # Run with HTTP transport on port 8080 mh serve -c config.json -t http -p 8080 # Run with SSE transport on custom host and port mh serve -c config.json -t sse --host 0.0.0.0 -p 3000 # Run with verbose logging mh serve -c config.json -v`, Flags: []ucli.Flag{ &ucli.IntFlag{ Name: "port", Aliases: []string{"p"}, Usage: "port for HTTP/SSE transport", Value: 3000, }, &ucli.StringFlag{ Name: "host", Usage: "host for HTTP/SSE transport", Value: "localhost", }, }, Action: runServe, }
ServeCmd is the serve subcommand that starts the MCP hub server
var UpdateCmd = &ucli.Command{ Name: "update", Usage: "Update mh to the latest version", Description: `Check for updates and upgrade mh to the latest version. Examples: # Check and update to latest mh update # Check only (dry run) mh update --check`, Flags: []ucli.Flag{ &ucli.BoolFlag{ Name: "check", Usage: "only check for updates, don't install", }, }, Action: runUpdate, }
UpdateCmd is the update subcommand that updates hub to the latest version
Functions ¶
Types ¶
type ConfigClient ¶
type ConfigClient struct {
// contains filtered or unexported fields
}
func NewConfigClient ¶
func (*ConfigClient) CallTool ¶
func (c *ConfigClient) CallTool(ctx context.Context, namespacedName string, params json.RawMessage) (*mcp.CallToolResult, error)
func (*ConfigClient) Close ¶
func (c *ConfigClient) Close() error
type RemoteClient ¶
type RemoteClient struct {
// contains filtered or unexported fields
}
RemoteClient connects to remote MCP services
func NewRemoteClient ¶
func NewRemoteClient(ctx context.Context, opts RemoteClientOpts) (*RemoteClient, error)
NewRemoteClient creates a new RemoteClient and connects to the remote MCP service
func (*RemoteClient) CallTool ¶
func (c *RemoteClient) CallTool(ctx context.Context, name string, params json.RawMessage) (*mcp.CallToolResult, error)
CallTool invokes a tool on the remote MCP server
func (*RemoteClient) Close ¶
func (c *RemoteClient) Close() error
Close closes the connection to the remote MCP server
type RemoteClientOpts ¶
type RemoteClientOpts struct {
ServerURL string
Transport string // "http" or "sse"
Headers map[string]string
Timeout int // seconds
Logger *slog.Logger
}
RemoteClientOpts contains options for creating a RemoteClient
type StdioClient ¶
type StdioClient struct {
// contains filtered or unexported fields
}
StdioClient connects to an MCP server via stdio (spawning a subprocess)
func NewStdioClient ¶
func NewStdioClient(ctx context.Context, opts StdioClientOpts) (*StdioClient, error)
NewStdioClient creates a new StdioClient and connects to the spawned MCP server
func (*StdioClient) CallTool ¶
func (c *StdioClient) CallTool(ctx context.Context, name string, params json.RawMessage) (*mcp.CallToolResult, error)
CallTool invokes a tool on the stdio MCP server
func (*StdioClient) Close ¶
func (c *StdioClient) Close() error
Close closes the connection to the stdio MCP server