From 6dc1efadb920b75625eda6a9351f6fcbe9628280 Mon Sep 17 00:00:00 2001 From: Michelangelo Mori <328978+blkt@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:16:58 +0200 Subject: [PATCH 1/2] Add docs for new `thv run --tools` flag. This change adds a small section under the "Run MCP servers" page documenting how to filter tools exposed by a server. Fixes stacklok/toolhive#1007 --- docs/toolhive/guides-cli/run-mcp-servers.mdx | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/toolhive/guides-cli/run-mcp-servers.mdx b/docs/toolhive/guides-cli/run-mcp-servers.mdx index e8b4535..a6b1cfc 100644 --- a/docs/toolhive/guides-cli/run-mcp-servers.mdx +++ b/docs/toolhive/guides-cli/run-mcp-servers.mdx @@ -142,6 +142,36 @@ specific proxy port instead, use the `--proxy-port` flag: thv run --proxy-port ``` +### Run a server exposing only selected tools + +ToolHive can filter the tools returned to the client as result of a `tools/list` +command as well as block calls to tools that the user did not want to expose. + +This can help reduce the amount of tools sent to the LLM while still using the +same MCP server, but it is not meant as a security feature. + +To filter the list of tools, use the `--tools` flag either once + +```bash +thv run --tools , +``` + +Or multiple times + +```bash +thv run --tools --tools +``` + +For example: + +```bash +thv run --tools list_issues,get_issue github +``` + +If the server comes from the registry, ToolHive can validate the tool names +against the list advertised in the image reference. An error is returned in case +ToolHive cannot find one of the tools specified by the user. + ## Run a custom MCP server To run an MCP server that isn't in the registry, you can use a From fb6dd428dddf64ad3d6923d43acb1bdfb4cfe731 Mon Sep 17 00:00:00 2001 From: Dan Barr Date: Mon, 28 Jul 2025 10:12:48 -0400 Subject: [PATCH 2/2] Apply suggestions from code review --- docs/toolhive/guides-cli/run-mcp-servers.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/toolhive/guides-cli/run-mcp-servers.mdx b/docs/toolhive/guides-cli/run-mcp-servers.mdx index a6b1cfc..419b2f0 100644 --- a/docs/toolhive/guides-cli/run-mcp-servers.mdx +++ b/docs/toolhive/guides-cli/run-mcp-servers.mdx @@ -145,7 +145,7 @@ thv run --proxy-port ### Run a server exposing only selected tools ToolHive can filter the tools returned to the client as result of a `tools/list` -command as well as block calls to tools that the user did not want to expose. +command as well as block calls to tools that you don't want to expose. This can help reduce the amount of tools sent to the LLM while still using the same MCP server, but it is not meant as a security feature. @@ -170,7 +170,7 @@ thv run --tools list_issues,get_issue github If the server comes from the registry, ToolHive can validate the tool names against the list advertised in the image reference. An error is returned in case -ToolHive cannot find one of the tools specified by the user. +ToolHive cannot find one of the specified tools. ## Run a custom MCP server