Test MCP servers
ToolHive includes several commands to help you test and validate MCP servers. These commands ensure that your servers are functioning correctly. This is useful for:
- Validating new MCP server installations
- Troubleshooting existing MCP servers
- Testing custom MCP servers during development
MCP Inspector
The MCP Inspector is an interactive tool for testing and debugging MCP servers.
You can quickly launch the MCP Inspector and connect it to an MCP server running
with ToolHive using the thv inspector command:
thv inspector <SERVER_NAME>
ToolHive downloads and runs the official Inspector container image and outputs the URL to open it in your web browser with the target MCP server's details pre-populated.
Example:
thv run fetch
thv inspector fetch
The output will look like this:
2:52PM INFO Pulling image: ghcr.io/modelcontextprotocol/inspector:0.17.0
2:52PM INFO Pull complete for image: ghcr.io/modelcontextprotocol/inspector:0.17.0
2:52PM INFO Waiting for MCP Inspector to be ready...
2:52PM INFO Connected to MCP server: fetch
2:52PM INFO Inspector UI is now available at http://localhost:6274?transport=streamable-http&serverUrl=http://host.docker.internal:21309/mcp&MCP_PROXY_AUTH_TOKEN=<RANDOM_TOKEN>
Open the provided URL in your web browser to access the MCP Inspector UI, where you can interactively test the MCP server's tools, prompts, and resources.
thv mcp commands
ToolHive also includes several thv mcp commands
to test and validate MCP servers. You can list the MCP server's tools, prompts,
and resources:
thv mcp list tools --server <SERVER_NAME_OR_URL>
thv mcp list prompts --server <SERVER_NAME_OR_URL>
thv mcp list resources --server <SERVER_NAME_OR_URL>
Replace <SERVER_NAME_OR_URL> with either the MCP server name or its ToolHive
proxy URL. You can find both values in the output of thv list.
Add the --format json flag to get the output in JSON format.
Currently, the thv mcp commands only support using server names for local MCP
servers. For remote servers, you must use the full URL instead of the server
name. You can track
this issue on GitHub.
To use URLs instead of names, get the server URL from thv list and use it
directly, like thv mcp list tools --server http://localhost:12345/mcp.
Invoke a tool
thv mcp list shows what a server exposes, but not how it behaves. To invoke
a tool directly from the CLI and inspect its result without opening the
Inspector, use thv mcp call:
thv mcp call <TOOL_NAME> --server <SERVER_NAME_OR_URL>
Pass arguments as a JSON object via --args (inline) or --args-file (file
path; use - to read from stdin). The two flags are mutually exclusive, and the
parsed value must be a JSON object. If you supply neither flag, the tool is
called with no arguments.
For example, to call the fetch tool on a fetch MCP server:
thv mcp call fetch --server fetch --args '{"url":"https://example.com"}'
By default, the command exits non-zero when the tool reports an error
(CallToolResult.IsError=true); pass --ignore-tool-error to exit zero in that
case. Transport and protocol failures always exit non-zero.
Add --format json to print the full CallToolResult instead of the default
text rendering. This is useful for piping output into other tools or capturing
structured content in scripts.
The --transport and --timeout flags work the same way as for thv mcp list.
Check server readiness
To confirm that a server accepts MCP connections without listing or invoking
anything, use thv mcp check. It connects, performs only the MCP initialize
handshake, and closes the connection. This makes it a good fit for readiness
gates and CI preflight steps, and it works for servers that intentionally expose
no tools, resources, or prompts.
thv mcp check --server <SERVER_NAME_OR_URL>
When the handshake succeeds, the command prints the negotiated details and exits zero:
Status: ready
Transport: streamable-http
Protocol: 2025-06-18
Latency: 42ms
Server: mcp-fetch 1.0.0
When the connection or the initialize handshake fails, the command prints the
error and exits non-zero. With the default --transport auto, ToolHive tries
streamable HTTP first and then SSE, and the error includes the cause from each
attempt, so you can tell an authentication failure from a server that isn't up
yet.
The default timeout for the connection and handshake is 5 seconds; change it
with --timeout (for example, --timeout 30s). If you pass a server name, the
workload must be in the running state.
Add --format json to get a machine-readable result on success. The object
contains status (always ready), latency_ms, transport,
protocol_version, server_info, and the server's capabilities from the
initialize response:
{
"status": "ready",
"latency_ms": 42,
"transport": "streamable-http",
"protocol_version": "2025-06-18",
"server_info": {
"name": "mcp-fetch",
"version": "1.0.0"
},
"capabilities": {
"tools": {
"listChanged": false
}
}
}
For example, to wait in a CI job until a server you just started is ready:
thv run fetch
until thv mcp check --server fetch; do sleep 2; done
ToolHive playground
While the MCP Inspector and thv mcp commands are great for basic functional
testing and validating spec compliance, you may want to experiment with MCP
servers in a more interactive way. It's also important to see how MCP servers
perform in real-world scenarios with actual AI models.
The playground in the ToolHive UI lets you test different tools interactively and see how your MCP server responds to various prompts.
See Test MCP servers in the ToolHive UI to learn about the playground's features and how to get started.
Next steps
- Build MCP containers to package your tested servers for deployment
- Set up CI/CD patterns to automate testing in your pipeline
- Secure your servers with authentication and authorization