dsh-tool-gateway: Consolidating the DSH Tool Catalog into find_tools / call_tool / call_tools

Introduction

After connecting MCP servers, installing plugins, and switching presets in DSH, the number of tools in the registry grows steadily. On the model side, you typically only see a truncated or condensed tool list: when the list is long, the model picks wrong tools easily; when it’s truncated, tools not present in the list are ignored, and the model falls back to repeatedly using a few familiar tools.

Additionally, tool definitions usually appear at the very beginning of every request. Any change to the tool list invalidates the entire prefix cache, causing recomputation costs and increased time-to-first-token—yet the tool list is precisely the most frequently changing part.

Below we introduce the community plugin dsh-tool-gateway (maintainer leolee9086), which consolidates the model-visible tool list into a small set of “meta-tools,” while all other tools remain callable through these meta-tools. It also provides session toggles, a toolbox panel, tool groups, and a hard-disable list. Classified as workflow; the repository currently has 0 stars. Directory page: https://www.skillhub.cn/plugins/leolee9086/dsh-tool-gateway, source: https://github.com/leolee9086/dsh-tool-gateway.

What Is This

dsh-tool-gateway hooks into the DSH profile layer (root scope), applying the same gateway logic to both presets and sessions (except for the session-level master switch). It does two things:

  1. Visibility: Filters assembled.tools during system prompt assembly, so the model-visible tool list primarily contains find_tools, call_tool, and call_tools (when conditions are met).
  2. Execution guard: Rejects the model’s direct calls to other tools; calls made through call_tool (sub-dispatch with parent) still go through ctx.tools.execute(), with approval, guards, sandbox, and session logging consistent with direct calls.

Thus, the long list no longer piles up in front of the model. Instead, the workflow becomes: first find_tools to query, then call_tool to invoke. When plugins are installed or panel toggles change, the bytes of the model-visible tool list can remain unchanged—only the retrieval index and guard decisions change.

The Three Meta-Tools

Tool Purpose When to use
find_tools Search by name, description, Chinese, or pinyin; returns full parameter schema When you don’t know what tools exist, or aren’t sure about parameter format
call_tool Call a single tool with {tool_name, arguments} When calling one at a time
call_tools Batch-call via a TypeScript program When making multiple consecutive calls where intermediate results don’t need to enter the conversation

find_tools results are token-estimated and truncated (default budget 10000, configurable); individual schemas are not truncated. When truncation occurs, use the returned offset to continue querying with the same query. Normal queries do not list tools disabled in the session; to see disabled tools, use find_tools({scope: "disabled"})—this path requires approval every time and is rejected directly under danger-full-access.

call_tools executes model-written programs in the DSH PTC runtime. Inside the program, you can only call tools.find_tools({query}) and tools.call_tool({tool_name, arguments}); only the return value goes back into the conversation. Parameters and outputs align with the official PTC run_code (including required description, structured output, and CodeRunFailedError), but the SDK declaration retains only these two, avoiding feeding the entire registry to the model again.

When call_tools is not mounted:

  • PTC mode is already enabled (mode: 'ptc' or 'both'), and run_code is already in the visible set.
  • The deployment does not provide ctx.ptcRuntime.

Detection is per-session; when unavailable, it conservatively does not mount call_tools.

Session Toggles, Toolbox, and Tool Groups

Session-Level Master Switch

The Web session title bar has a “Toolbox On / Toolbox Off” chip that controls whether the current session applies gateway constraints, defaulting to on. The state is persisted in $DSH_HOME/storages/tool_gateway/sessions; sub-agents inherit the parent session’s state. When off, the model sees the full tool list and can call any tool directly; the execution guard takes effect immediately, and the tool list and prompt sections take effect in the next request. Switching injects a user-visible notification via agent.inject(). Headless deployments without webServer have no UI, and the switch is fixed at the default “on.”

Toolbox Panel

The right sidebar “Tools” panel lists all tools visible in the session (including those collapsed by the gateway). Each tool has three states: unset (follows group default), explicitly on, explicitly off. When off, the tool disappears from find_tools results, and direct calls are rejected by the guard; the three meta-tools cannot be disabled. Panel changes also notify the model. When the gateway is on, toggles only change the catalog index and guard—not the visible tool list via restrict()—to avoid breaking prefix caching.

Tool Groups

Registrants can declare a batch of tools to be off by default, preventing the panel from overflowing when registering hundreds of tools at once. Example (from README):

const gateway = ctx.get('toolGateway')
if (gateway !== undefined) {
  const group = gateway.registerGroup({
    id: 'siyuan-http',
    title: '思源 HTTP 端点',
    origin: 'dsh-plugin-siyuan',
    defaultEnabled: false,
  })
  ctx.effect(() => () => group.dispose(), 'siyuan: gateway group')
  for (const tool of tools) {
    ctx.tools.register(tool)
    group.add(tool.name)
  }
}

When the gateway is not installed, ctx.get('toolGateway') is undefined; the plugin should register tools as usual, just without the “default off” semantics.

Hard-Disable List

Certain tools are never allowed to execute in any session or through any path (including call_tool sub-dispatch). ask_user_question is disabled by default. Configuring ban: { deny: [] } explicitly clears the deny list; only when deny is completely absent does the default list apply. Names in the deny configuration also cannot be toggled in the panel.

Installation and Activation

The plugin runs with the current DSH process privileges. Please review the source code and MIT license before installing. Requires Node >=22.19.0.

dsh plugin --profile web add github:leolee9086/dsh-tool-gateway#v0.3.0

Installation appends to dsh.profile.bundles based on the package’s dsh.bundle.patch, so no manual edits to the profile’s cordis.patch.yml are needed. The repository commits lib/ artifacts, so installing from git does not require pnpm build authorization. Restart DSH to take effect; no preset changes needed.

Typical Usage (Model Side)

When the gateway is on and the session constraint is “on,” the model-side workflow can be summarized as:

  1. Use find_tools to search by task keywords, using offset to paginate if needed, obtaining the full schema of the target tool.
  2. Use call_tool with tool_name and arguments to execute.
  3. If multiple consecutive steps are needed and intermediate results don’t need to enter the context, when PTC is available and doesn’t conflict with the official run_code, use call_tools to write a short program that internally only calls tools.find_tools and tools.call_tool.

Humans can turn off the session constraint via the title bar chip in the Web interface, or toggle tools/groups in the toolbox panel. To view disabled tools, use find_tools({scope: "disabled"}) (subject to approval policy).

Applicable Scenarios and Caveats

Suitable for: DSH users with many tools, frequently connecting MCP or hot-swappable plugins, who want the model to “query first, then call” and maintain stable prefix caching; plugin authors who want large batches of tools off by default, opened by users on demand.

Caveats:

  • Plugin versions are based on installation tags (v0.3.0 in the documentation); pinning versions can replace #v0.3.0 with a commit sha.
  • The hard-disable and restrictions on scope: "disabled" under danger-full-access are security designs; deployments need to understand the approval service behavior.
  • The community directory SkillHub has no official affiliation with DeepSeek/Hunyuan; the DSH ecosystem is “everything is a plugin,” and all facts in this article come from the repository README and package.json mentioned above.

Conclusion

dsh-tool-gateway uses visibility filtering plus execution guards to collapse tool entry points into retrieval and invocation meta-tools, and manages “who can be found and who can be executed” via panels and tool groups, while striving to keep the model-visible tool list stable. For more information, see the directory page https://www.skillhub.cn/plugins/leolee9086/dsh-tool-gateway and GitHub https://github.com/leolee9086/dsh-tool-gateway.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye