Index of every page on this site: llms.txt
All skills
stacklok avatar

/toolhive-cli-user

@740e467
by stacklokstacklok/toolhive2.4k stars
336
Run it yourself

Guide for using ToolHive CLI (thv) to run and manage MCP servers, skills, and AI-client plugins. Use when managing `thv ai-plugin` installs, project sync or upgrades, or plugin publishing for Claude Code or Codex; also use for MCP server and skill lifecycle commands. Covers server lifecycle, registries, secrets, client registration, builds, permissions, skills, and AI plugins. NOT for Kubernetes operator usage, ToolHive development/contributing, or general AI-client configuration unrelated to ToolHive.

Use this Skill: https://skilld.dev/gh/stacklok/toolhive/toolhive-cli-user

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesEXAMPLES.md

≈3.9k tokens on demand. Your agent reads this file only when SKILL.md points to it.

ToolHive CLI Usage Examples

Basic Workflows

Quick Start with Registry Server

# Run fetch server
thv run fetch

# Check it's running
thv list

# Get detailed status
thv status fetch

# View capabilities
thv mcp list tools --server fetch

# View logs
thv logs fetch

# Stop when done
thv stop fetch

# Clean up
thv rm fetch

Run Server with Custom Configuration

# Named server with environment variables
thv run github \
  --name my-github \
  -e GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxxx \
  -- --toolsets repos

# Server with volume mount
thv run <server> \
  --name project-fs \
  -v /home/user/projects:/workspace:ro

# Server with multiple labels
thv run fetch \
  --name docs-fetch \
  -l env=production \
  -l team=backend \
  -l version=1.0

Protocol Scheme Examples

Python (uvx)

# From PyPI
thv run uvx://mcp-server-git

# With version
thv run uvx://mcp-server-git@1.0.0

# With arguments
thv run uvx://mcp-server-sqlite -- --db-path /data/mydb.sqlite

Node.js (npx)

# From npm
thv run npx://@modelcontextprotocol/server-everything

# Scoped package
thv run npx://@modelcontextprotocol/server-filesystem

# With arguments
thv run npx://@modelcontextprotocol/server-filesystem -- /allowed/path

Go

# From module
thv run go://github.com/example/mcp-server@latest

# Local project
thv run go://./my-mcp-server

# Parent directory
thv run go://../shared/mcp-server

Secrets Management Examples

Initial Setup

# Configure encrypted provider (recommended)
thv secret setup
# Select: encrypted
# Enter password when prompted

# Or use 1Password
export OP_SERVICE_ACCOUNT_TOKEN=your-token
thv secret setup
# Select: 1password

Store and Use Secrets

# Store interactively
thv secret set GITHUB_TOKEN
# Enter token when prompted

# Store via pipe
echo "ghp_xxxxxxxxxxxx" | thv secret set GITHUB_TOKEN

# List stored secrets
thv secret list

# Use secret when running server
thv run github --secret GITHUB_TOKEN,target=GITHUB_PERSONAL_ACCESS_TOKEN

# Multiple secrets
thv run myserver \
  --secret API_KEY,target=API_KEY \
  --secret DB_PASSWORD,target=DATABASE_PASSWORD

Group Management Examples

Environment-Based Groups

# Create environment groups
thv group create development
thv group create staging
thv group create production

# Run servers in specific groups
thv run fetch --name dev-fs --group development
thv run fetch --name prod-fs --group production

# List servers by group
thv list --group development
thv list --group production

# Stop all servers in a group
thv stop --group development

Client Group Restrictions

# Register client with group restriction
thv client register claude-code --group development

# Now this client only sees servers in development group

Restart Servers

# Restart a single server
thv start fetch
thv restart fetch          # Same thing (alias)

# Restart all servers in a group
thv start --group development

# Restart all servers
thv start --all

Deploy Registry Groups

# Registry defines groups like "kubernetes", "devops", etc.
# Run all servers from a registry group
thv group run kubernetes

Remote Server Examples

Basic Remote Server

# Simple remote server
thv run https://api.example.com/mcp --name remote-api

Remote with OIDC Authentication

# Full OIDC setup
thv run https://api.example.com/mcp --name secure-api \
  --remote-auth-issuer https://auth.example.com \
  --remote-auth-client-id my-client-id \
  --remote-auth-client-secret-file /path/to/secret \
  --remote-auth-scopes "openid profile"

# Dynamic client registration (no credentials needed)
thv run https://api.example.com/mcp --name auto-api \
  --remote-auth \
  --remote-auth-issuer https://auth.example.com

Remote with OAuth2 (non-OIDC)

thv run https://api.example.com/mcp --name oauth-api \
  --remote-auth-authorize-url https://auth.example.com/oauth/authorize \
  --remote-auth-token-url https://auth.example.com/oauth/token \
  --remote-auth-client-id my-client-id \
  --remote-auth-client-secret my-secret

Remote with Bearer Token

# From file (recommended)
thv run https://api.example.com/mcp --name token-api \
  --remote-auth-bearer-token-file /path/to/token.txt

# Direct (less secure)
thv run https://api.example.com/mcp --name token-api \
  --remote-auth-bearer-token "your-token-here"

Building Containers

Pre-build for Kubernetes

# Build with custom tag
thv build --tag my-registry.io/mcp/filesystem:v1.0.0 \
  npx://@modelcontextprotocol/server-filesystem

# Push to registry (standard docker)
docker push my-registry.io/mcp/filesystem:v1.0.0

Build with Embedded Arguments

# Arguments baked into ENTRYPOINT
thv build --tag launchdarkly:latest \
  npx://@launchdarkly/mcp-server -- start

Generate Dockerfile Only

# Output Dockerfile for inspection/modification
thv build --dry-run --output Dockerfile.mcp \
  uvx://mcp-server-git

# Review and customize
cat Dockerfile.mcp

# Build manually
docker build -f Dockerfile.mcp -t my-mcp:custom .

Export and Import Examples

Backup Configuration

# Export to JSON
thv export my-server ./backup/my-server.json

# Export to Kubernetes YAML
thv export my-server ./k8s/my-server.yaml --format k8s

Migrate Configuration

# Export from one machine
thv export production-server ./config.json

# Transfer file to new machine, then import
thv run --from-config ./config.json

Share Configuration

# Export team's standard setup
thv export team-toolkit ./team-config.json

# Team member imports
thv run --from-config ./team-config.json --name my-toolkit

Tool Filtering and Overrides

Filter Available Tools

# Only expose specific tools
thv run github --tools list_issues,get_issue,create_issue

# Multiple tools comma-separated
thv run fetch --tools fetch,fetch_html

Override Tool Names/Descriptions

Create overrides.json:

{
  "toolsOverride": {
    "fetch": {
      "name": "docs-fetch",
      "description": "Fetches content from documentation websites only"
    },
    "list_issues": {
      "name": "get-github-issues",
      "description": "Lists issues from the main repository"
    }
  }
}

Apply:

thv run fetch --tools-override overrides.json

Debugging Examples

Inspect Server Capabilities

# List tools
thv mcp list tools --server fetch

# List resources
thv mcp list resources --server fetch

# List prompts
thv mcp list prompts --server fetch

# JSON output for parsing
thv mcp list tools --server fetch --format json

Invoke a Tool

# Inline JSON args
thv mcp call fetch --server fetch --args '{"url":"https://example.com"}'

# Args from a file
thv mcp call fetch --server fetch --args-file ./args.json

# Args from stdin
echo '{"url":"https://example.com"}' | thv mcp call fetch --server fetch --args-file -

# JSON output (full CallToolResult, includes content + structuredContent + isError)
thv mcp call fetch --server fetch --args '{"url":"https://example.com"}' --format json

# Tool-reported errors normally exit non-zero; flip with --ignore-tool-error
thv mcp call fetch --server fetch --args '{"url":"not-a-url"}' --ignore-tool-error

Launch Inspector UI

# Default ports
thv inspector fetch
# UI at http://localhost:6274

# Custom ports
thv inspector fetch --ui-port 7000 --mcp-proxy-port 7001

View Logs

# Container logs
thv logs fetch

# Follow in real-time
thv logs fetch --follow

# Proxy logs (for debugging HTTP/auth issues)
thv logs fetch --proxy

Verify Runtime

# Check container runtime is accessible
thv runtime check

Client Registration Examples

Check Available Clients

# See all supported clients and their status
thv client status

Interactive Setup

# Guided setup for detected clients
thv client setup

Register Specific Clients

# Register Claude Code
thv client register claude-code

# Register VS Code
thv client register vscode

# Register with group restriction
thv client register cursor --group development

Manage Registrations

# List registered clients
thv client list-registered

# Remove a client
thv client remove cursor

Permissions and Network Isolation

Permission Profiles

# No extra permissions (most restrictive)
thv run myserver --permission-profile none

# Network access only (no filesystem)
thv run myserver --permission-profile network

# Custom profile from JSON file
thv run myserver --permission-profile ./my-permissions.json

Network Isolation (Egress Proxy)

# Isolate network — only allowlisted hosts can be reached
thv run myserver --isolate-network

# Combined with custom permissions
thv run myserver --isolate-network --permission-profile ./restricted.json

.thvignore — Hide Sensitive Files

Place .thvignore in mounted directories to hide matching files from the container:

# Create .thvignore in project root
cat > /home/user/projects/.thvignore << 'EOF'
.env
.git/
*.pem
secrets/
EOF

# Mount the directory — .thvignore patterns are applied automatically
thv run <server> -v /home/user/projects:/workspace:ro

Global patterns at ~/.config/toolhive/thvignore apply to all mounts. Disable with --ignore-globally=false.

Skills Management Examples

Install and Use Skills

# Install a skill for the current user
thv skill install code-review

# Install targeting a specific client
thv skill install code-review --clients claude-code

# Install into a project (requires --project-root)
thv skill install code-review --scope project --project-root /home/user/myproject

# Force reinstall (overwrites existing)
thv skill install code-review --force

# Install and assign to a group
thv skill install code-review --group development

# Install by OCI reference
thv skill install ghcr.io/stacklok/skills/code-review:v1.0

List and Inspect Skills

# List all installed skills
thv skill list

# Short alias
thv skill ls

# JSON output for scripting
thv skill list --format json

# Filter by scope, client, or group
thv skill ls --scope user
thv skill ls --client claude-code
thv skill ls --group development

# Detailed info about a skill
thv skill info code-review
thv skill info code-review --format json

Remove Skills

# Uninstall user-scoped skill
thv skill uninstall code-review

# Uninstall project-scoped skill
thv skill uninstall code-review --scope project --project-root /home/user/myproject

Author and Publish Skills

# Validate a skill directory before building
thv skill validate ./my-skill

# JSON validation output
thv skill validate ./my-skill --format json

# Build into an OCI artifact
thv skill build ./my-skill

# Build with a specific tag
thv skill build ./my-skill --tag ghcr.io/myorg/my-skill:v1.0

# Push to a remote registry
thv skill push ghcr.io/myorg/my-skill:v1.0

Typical Authoring Workflow

# 1. Create and validate
thv skill validate ./my-skill

# 2. Build the artifact
thv skill build ./my-skill --tag ghcr.io/myorg/my-skill:v1.0

# 3. Push to registry
thv skill push ghcr.io/myorg/my-skill:v1.0

# 4. Install from registry to verify
thv skill install ghcr.io/myorg/my-skill:v1.0 --clients claude-code

# 5. Confirm installation
thv skill info my-skill

Network Configuration Examples

Host Networking

# Use host network (container shares host network namespace)
thv run myserver --network host

Custom Docker Network

# Create network first
docker network create mcp-network

# Run server in that network
thv run myserver --network mcp-network

Access Host Services from Container

# For services running on host machine
# Docker Desktop (Mac/Windows):
thv run myserver -e SERVICE_URL=http://host.docker.internal:8080

# Podman:
thv run myserver -e SERVICE_URL=http://host.containers.internal:8080

# Linux (bridge network):
thv run myserver -e SERVICE_URL=http://172.17.0.1:8080

AI Plugin Management Examples

Placeholders: Replace example-plugin, example-org, paths, and versions below with reviewed values. Start thv serve before any thv ai-plugin command.

Inspect and Install

# Inspect installed project plugins before changing them.
thv ai-plugin list --scope project --project-root .
thv ai-plugin info example-plugin --scope project --project-root .

# Install a reviewed OCI plugin into this project and target Claude Code.
thv ai-plugin install ghcr.io/example-org/example-plugin:v1.0 \
  --scope project --project-root . --clients claude-code

# A Git source can select a ref and plugin subdirectory.
thv ai-plugin install git://github.com/example-org/plugin-repo@v1.0#plugins/example-plugin \
  --scope project --project-root . --clients codex

For Codex, then complete the explicit client hand-off; ToolHive does not invoke Codex or edit config.toml:

codex plugin install example-plugin@toolhive

First Install of an Externally Key-Signed OCI Plugin

# Supply the reviewed public key only for the first project install.
# ToolHive pins it in toolhive.lock.yaml and reuses it for sync and upgrade.
thv ai-plugin install ghcr.io/example-org/example-plugin:v1.0 \
  --scope project --project-root . --public-key ./keys/example-plugin.cosign.pub

Check and Restore Project Drift

# CI-safe inspection: no install, lock-file write, or deletion.
thv ai-plugin sync --check --project-root .

# After reviewing the lock entries and prompt, restore missing/drifted plugins.
thv ai-plugin sync --project-root .

Do not use --allow-unsigned for a failed signature: it only records an explicit unsigned exception and cannot validate invalid content. Do not use --prune or --yes unless explicitly approved.

Preview and Apply an Upgrade

# Show mutable-reference changes without persisting them.
thv ai-plugin upgrade --preview --project-root .

# After reviewing repositories and signer identities, confirm at the prompt.
thv ai-plugin upgrade example-plugin --project-root .

--fail-on-changes is the non-mutating CI freshness check. Do not add --allow-ref-change, --allow-signer-change, or --yes without explicit approval.

Validate, Build, and Publish

# Validate before building; an invalid plugin exits non-zero.
thv ai-plugin validate ./example-plugin

# Build into the local OCI store, then inspect the local build.
thv ai-plugin build ./example-plugin --tag ghcr.io/example-org/example-plugin:v1.0
thv ai-plugin builds

# Push signed by default (keyless signing acquires an OIDC token when needed).
thv ai-plugin push ghcr.io/example-org/example-plugin:v1.0

Use thv ai-plugin push --no-sign ... only when intentionally publishing unsigned content under an approved policy; do not recommend it as an installation workaround.

Uninstall Versus Removing a Local Build

# Remove the project installation; this does not delete the local OCI artifact.
thv ai-plugin uninstall example-plugin --scope project --project-root .

# Separately remove a reviewed local build by its tag.
thv ai-plugin builds remove ghcr.io/example-org/example-plugin:v1.0

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts22d3 checks · Risk SAFE
  • Gen Agent Trust Hub22d

    The skill is a comprehensive user guide for the ToolHive CLI (thv), a tool used to manage Model Context Protocol (MCP) servers. It provides instructions for running, managing, and building servers, including security-focused features like secret management, network isolation, and permission profiles. No malicious patterns, such as prompt injection, data exfiltration, or obfuscated payloads, were detected. The skill follows best practices by encouraging the use of managed secrets and isolation tools.

  • Socket22d

    No alerts

  • Snyk22d

    Risk: LOW · No issues

Signed by skilld at 740e467. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 weeks ago
version
0.4.0

README badge

README badge for stacklok/toolhive/toolhive-cli-user