跳转至

Tool search(工具搜索)

Palantir MCP supports on-demand tool discovery through tool search. When tool search is enabled, the server exposes a single tool, search_tools, at startup instead of the full tool catalog. Your agent activates additional tools only as it searches for them, so fewer tool definitions load into your context, which reduces token usage.

How tool search works

By default, all tools load at startup and remain available throughout the session. When tool search is enabled, Palantir MCP starts up exposing only the search_tools tool. From there:

  1. When you prompt the agent, the agent calls search_tools with a short description of your task.
  2. search_tools ranks the catalog locally on tool name, category, and curated keywords, with no extra model call or network round-trip. It then activates the best-matching tools and returns their descriptions.
  3. The agent calls the activated tool directly.

This keeps your context small. Instead of loading dozens of tool definitions up front, the agent loads only the handful relevant to the task.

Activated tools remain in your tool list and your context for the rest of the session. Reconnecting to the server resets your tool list to only search_tools.

:::callout{theme="neutral"} Client requirement: Tool search relies on your MCP client refreshing its tool list when new tools are activated, using the tools/list_changed notification. Clients that do not refresh dynamically will not see newly activated tools. For this reason, Continue does not use tool search. :::

Tool search is opt-in. By default, all tools load at startup. To enable tool search, either:

  • Pass the --tool-search argument to the server, or
  • Set the environment variable PALANTIR_MCP_TOOL_SEARCH=true.

The two options are equivalent; use whichever fits your setup.

Claude Code

When you add Palantir MCP with claude mcp add, pass the --tool-search argument. The argument must go after the -- separator, as an argument to palantir-mcp and not to claude mcp add.

claude mcp add palantir-mcp \
    --scope project \
    -e FOUNDRY_TOKEN=<token> \
    -- npx "-y" "palantir-mcp" "--tool-search" "--foundry-api-url" "https://<your-foundry-hostname>.palantirfoundry.com"

Alternatively, set the environment variable:

claude mcp add palantir-mcp \
    --scope project \
    -e FOUNDRY_TOKEN=<token> \
    -e PALANTIR_MCP_TOOL_SEARCH=true \
    -- npx "-y" "palantir-mcp" "--foundry-api-url" "https://<your-foundry-hostname>.palantirfoundry.com"

Agent Flows (pro-code agents)

In a pro-code agent, add the --tool-search argument to the server configuration:

export const PALANTIR_MCP_CONFIGURATION: McpStdioServerConfig = {
  type: "stdio",
  command: "palantir-mcp",
  args: ["start", "--tool-search", "code-workspaces"],
  env: {
    FOUNDRY_PROXY_URL: `https://${process.env.FOUNDRY_PROXY_URL!}/`,
    FOUNDRY_SERVICE_DISCOVERY_V2: process.env.FOUNDRY_SERVICE_DISCOVERY_V2!,
    FOUNDRY_EXTERNAL_HOST: "https://<your-foundry-hostname>.palantirfoundry.com",
    FOUNDRY_PROXY_TOKEN: process.env.FOUNDRY_PROXY_TOKEN!,
    FOUNDRY_SCOPED_TOKEN: process.env.FOUNDRY_SCOPED_TOKEN!,
    MAESTRO_REPO_RID: process.env.MAESTRO_REPO_RID!,
    NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS!,
  },
};

Alternatively, add PALANTIR_MCP_TOOL_SEARCH: "true" to the env block instead of passing the --tool-search argument.


中文翻译

工具搜索

Palantir MCP 支持通过工具搜索(Tool Search)实现按需发现工具。启用工具搜索后,服务器在启动时仅暴露一个工具 search_tools,而非完整的工具目录。您的智能体(Agent)仅在搜索时激活额外工具,因此加载到上下文中的工具定义更少,从而减少令牌(Token)使用量。

工具搜索的工作原理

默认情况下,所有工具在启动时加载并在整个会话期间保持可用。启用工具搜索后,Palantir MCP 启动时仅暴露 search_tools 工具。具体流程如下:

  1. 当您向智能体发出提示时,智能体会使用您任务的简短描述调用 search_tools
  2. search_tools 根据工具名称、类别和精选关键词在本地对目录进行排序,无需额外的模型调用或网络往返。随后它会激活最匹配的工具并返回其描述。
  3. 智能体直接调用已激活的工具。

这种方式可保持上下文精简。智能体无需预先加载数十个工具定义,仅加载与任务相关的少数几个工具。

已激活的工具会在会话剩余时间内保留在您的工具列表和上下文中。重新连接服务器会将工具列表重置为仅包含 search_tools

:::callout{theme="neutral"} 客户端要求: 工具搜索依赖您的 MCP 客户端在激活新工具时刷新工具列表,使用 tools/list_changed 通知。不支持动态刷新的客户端将无法看到新激活的工具。因此,Continue 不使用工具搜索。 :::

启用工具搜索

工具搜索为可选功能。默认情况下,所有工具在启动时加载。要启用工具搜索,请执行以下任一操作:

  • 向服务器传递 --tool-search 参数,或
  • 设置环境变量 PALANTIR_MCP_TOOL_SEARCH=true

两种方式效果相同,请根据您的配置选择合适的方式。

Claude Code

当您使用 claude mcp add 添加 Palantir MCP 时,请传递 --tool-search 参数。该参数必须放在 -- 分隔符之后,作为 palantir-mcp 的参数,而非 claude mcp add 的参数。

claude mcp add palantir-mcp \
    --scope project \
    -e FOUNDRY_TOKEN=<token> \
    -- npx "-y" "palantir-mcp" "--tool-search" "--foundry-api-url" "https://<your-foundry-hostname>.palantirfoundry.com"

或者,设置环境变量:

claude mcp add palantir-mcp \
    --scope project \
    -e FOUNDRY_TOKEN=<token> \
    -e PALANTIR_MCP_TOOL_SEARCH=true \
    -- npx "-y" "palantir-mcp" "--foundry-api-url" "https://<your-foundry-hostname>.palantirfoundry.com"

Agent Flows(专业代码智能体)

在专业代码智能体中,将 --tool-search 参数添加到服务器配置:

export const PALANTIR_MCP_CONFIGURATION: McpStdioServerConfig = {
  type: "stdio",
  command: "palantir-mcp",
  args: ["start", "--tool-search", "code-workspaces"],
  env: {
    FOUNDRY_PROXY_URL: `https://${process.env.FOUNDRY_PROXY_URL!}/`,
    FOUNDRY_SERVICE_DISCOVERY_V2: process.env.FOUNDRY_SERVICE_DISCOVERY_V2!,
    FOUNDRY_EXTERNAL_HOST: "https://<your-foundry-hostname>.palantirfoundry.com",
    FOUNDRY_PROXY_TOKEN: process.env.FOUNDRY_PROXY_TOKEN!,
    FOUNDRY_SCOPED_TOKEN: process.env.FOUNDRY_SCOPED_TOKEN!,
    MAESTRO_REPO_RID: process.env.MAESTRO_REPO_RID!,
    NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS!,
  },
};

或者,在 env 块中添加 PALANTIR_MCP_TOOL_SEARCH: "true",而非传递 --tool-search 参数。