rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
donhac/dsh-magpie-discovery
On-demand Magpie MCP tool discovery for DeepSeek Harness. One lookup defers 150+ tool schemas, reveals original tools per session, and keeps native execution, approvals, images and structured results. Not a second MCP client or proxy.
PROJECT TOPICS
PROJECT README
On-demand Magpie MCP tool discovery for DeepSeek Harness agents.
Magpie exposes browser, web search, GitHub, DBX databases, SSH and TapTap capabilities through one MCP Hub. DSH's native MCP client registers every tool schema up front, which can put 150+ definitions in every request. This plugin adds one small lookup tool (magpie_tools) and reveals the original Magpie tool only after it has been selected.
It is a visibility layer, not a second MCP client and not a call proxy. Selected tools execute through DSH's original tool pipeline, so images, structured values, errors, approvals and result metadata keep their native behavior.
This is a plugin, not an agent preset. It can be mounted in any preset that needs Magpie tools, or enabled once for every agent. It does not define a coding mode, persona, model route or image workflow.
magpie_tools: search, load by exact name, show status, or reset the current selection.>=0.2.1-rc.5 <0.3.0 (tested with 0.2.1-rc.5).>=22.19.0.tools, systemPrompt, sessionProjections, agentPresets and agents.This plugin does not create a Magpie connection. If no Magpie MCP server is configured, magpie_tools reports an empty catalog and other tools continue to work.
Discovery results now report added, evicted and unchanged. Use names with replace: true to switch a task phase to a complete set of up to 12 tools in one call. Replacement is atomic: an unavailable name fails without clearing the previous selection. The immediately-following-request behavior and original execution/permission pipeline are preserved. See CHANGELOG.md for regression coverage.
From Plugin Manager, choose Install bundle and enter:
github:donhac/dsh-magpie-discovery
Or from the DSH CLI:
dsh plugin --profile <profile> add github:donhac/dsh-magpie-discovery
For a pinned release:
github:donhac/dsh-magpie-discovery#v1.2.0
The installed bundle and plugin row are displayed as dsh-magpie-discovery. The bundle also inserts a disabled Host row named magpie-tool-discovery. Choose one of the two usage modes below.
Add the package to the plugins list of an @deepseek-ai/dsh-agent-preset row:
- id: magpie-tool-discovery
name: dsh-magpie-discovery
config:
presetId: my-preset
presetId must be the id of the preset that contains this row.This mode scopes discovery to agents using that preset. Other presets keep their full Magpie tool set.
In Plugin Manager, enable the installed magpie-tool-discovery row. The plugin then applies to every agent in the profile.
Do not enable the Host row and also mount the package in a preset. That creates two instances registering the same magpie_tools name and projection key.
magpie_tools({ query: 'browser tabs', limit: 2 })
magpie_tools({ query: '数据库表结构' })
magpie_tools({ query: 'dbx list connections sessions read only query', limit: 6 })
magpie_tools({ query: 'nyatermSsh connection_list session_open terminal_execute', limit: 6 })
magpie_tools({ names: ['mcp__magpie__playwright__browser_tabs'] })
magpie_tools({})
magpie_tools({ reset: true })
query searches names and descriptions. English API terms and common Chinese capability words both work.names loads 1–6 exact mcp__magpie__... names incrementally.names, replace: true atomically replaces the complete selection with 1–12 names. All names must exist in the catalog; a failed replacement preserves the old set. Include tools still needed for cleanup. replace cannot accompany query, reset or pagination.added, evicted and unchanged relative to the previous set. Already visible tools can be called directly without another lookup.limit is 1–6 and defaults to 3; offset pages through matches.reset clears the current selection.A recognized service name restricts results to that service. Within that scope, capability and operation terms are alternatives: they can match different tools, but every term must match somewhere in the scoped catalog or the query returns no matches. Ordinary unscoped keyword queries still use AND matching; multiple complete operation names are alternatives. Full exact tool names rank first.
+ is a separator, not an operator. A generic query such as +dbx connection ranks list_connections first. Explicit create/add, duplicate and remove/delete requests still find the corresponding write tools.
Once a successful discovery result commits, the selected tools become visible in the immediately following model request. No extra buffer step or unrelated tool call is needed. Tools already planned in the current assistant step cannot gain definitions retroactively; look first, then call the original tool on the following step.
At most 12 recently selected tools stay loaded. Selecting a tool again refreshes its position; an older selection is evicted when the cap is exceeded.
The plugin inspects global tool names beginning with mcp__magpie__. For each agent it installs one restriction:
deny = current Magpie catalog - tools selected in this session
The restriction affects schema presentation, lookup and dispatch together. It never copies, wraps or re-registers a real Magpie tool, so the tool that runs is still the original definition.
The selection itself is derived from the native session log. magpie_tools writes a versioned marker and the complete post-selection list into the tool result's presentationMeta. A host-only session projection accepts that state only when:
magpie_tools call;A returned value that has not been committed as a tool result does not unlock anything.
After a successful result commits, a synchronous session/event listener reads the projection and refreshes the mask before the next tool-schema assembly. A blank agent selecting a preset attaches when agent-preset/selected commits, before its first model request. Already existing agents are also reconciled when the plugin mounts. The agent/pre-step hook is a defensive fallback, not the normal update path.
Selection, restrictions and listeners are installed in an ordered lifecycle. On unload, agent policies are released first, then listeners and the tool, with the projection last. Preset switches remove the old mask and attach the matching preset's policy at selection commit. These hooks update visibility only; original business execution, approvals, output rendering, metadata and finalizers remain in DSH's native tool pipeline.
| Field | Required | Meaning |
|---|---|---|
presetId |
Recommended for preset mounts | The preset id that owns this instance. Used to detach when an agent switches presets. |
The Host row needs no configuration and behaves globally. A preset mount without presetId falls back to the current preset identity at activation; setting it explicitly is safer and is required if you want deterministic cleanup across composition reloads.
mcp__magpie__ are hidden. Other MCP servers, native tools and image plugins are untouched.tool/call and tool/result events from magpie_tools. A preset that switches to PTC records calls differently and will not update the selection.The plugin is designed for presets that use DSH's native tool presentation. It does not require or provide PTC.
Image generation and editing are intentionally out of scope. Any image plugin installed in the profile continues to register its own tools; this plugin does not import, proxy or modify them.
The package has no runtime dependencies and no build step. Install the pinned development dependencies, then run both the pure core tests and runtime regressions:
npm ci --ignore-scripts
npm test
Core tests cover request validation, Chinese/English ranking, scoped multi-operation searches, unknown-keyword rejection, connection discovery and explicit write intent, exact loading, pagination, the 6/12-tool limits, reset and projection validation.
Runtime tests instantiate DSH's real AgentLoop, preset registry, tool runtime and session projection registry with a scripted LLM adapter and in-memory fixture tools. They inspect actual adapter requests to verify first-request masking after blank-agent preset selection, immediate next-request visibility after discovery, closing without an extra open, preset changes, retained revisions, replay, unload and independent agents. They also check that other deny rules and guards remain effective, while native image definitions, result metadata and finalizers retain their behavior. The suite makes no network, real MCP, model-provider or image-provider calls and consumes no image quota. Dependency installation requires access to the package registry.
To try a local checkout:
dsh plugin --profile <profile> add /absolute/path/to/dsh-magpie-discovery
After changing code, use Plugin Manager to remove and reinstall the bundle; a linked local package loads a fresh module generation only after reinstallation.
Remove the bundle in Plugin Manager, or:
dsh plugin --profile <profile> remove dsh-magpie-discovery
If you mounted the package in a preset, remove that preset row first. New sessions no longer see the discovery tool; existing sessions keep their revision until they end.
MIT. See LICENSE.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: mcp、deepseek、deepseek-harness。