Skip to content

Agent integration

Kevin Straub edited this page Aug 1, 2026 · 7 revisions

The point of mduct is that an agent can reach a hundred tools while carrying one line per server in its context. That line has to get in there somehow.

The prompt block

mduct index
MCP tools via `mduct` CLI (list+args: mduct tools <server>; call: mduct call <server> <tool> key=value key:=<json>):
  gitlab       — GitLab: MRs, pipelines, issues, repos
  notes        — shared notes
CLI tools via `mduct` CLI (run: mduct run <tool> [args…]):
  kubectl      — read-only cluster access

Paste it into a system prompt, a CLAUDE.md, an AGENTS.md, whatever your harness reads. The note field of each entry is what shows up here, so write notes for the reader who has to choose a tool from this list and nothing else.

Claude Code

mduct hook install claude          # --remove to undo

Two hooks land in ~/.claude/settings.json:

  • SessionStart — prints mduct index, so the block is present without you maintaining it by hand. It also warns if a server is attached directly to Claude while mduct serves it too (you'd be paying for the schemas anyway).
  • PreToolUse — matches mcp__* and answers with the replacement command: mduct call <server> <tool> key=value. Only for servers mduct actually serves; anything else passes through untouched.

Foreign hooks in the same file are preserved. Re-running the install replaces only mduct's own entries.

The installer writes the path of the binary you ran it with, so install first, then run mduct hook install claude from the installed binary — not from a source checkout, unless you want your hooks pinned to your working tree.

Everything else

There is no plugin API and there doesn't need to be one. Any agent that can run a shell command can use mduct:

  1. Put mduct index output in the system prompt.
  2. Let the agent run mduct tools <server> when it needs the tool list, and mduct schema <server> <tool> when it needs the fields.
  3. Calls are mduct call <server> <tool> key=value.

Three commands. If your harness has a bash tool, it already supports mduct.

Teaching the pipe habit

An agent that runs mduct call srv list_things gets the whole list in its context. An agent that runs it with --json | jq -c 'map({id,title})' gets what it asked for. The difference is real money, so the index block mentions it and mduct help shows worked examples.

The warnAbove default is the backstop: an oversized result prints a warning with a ready-made jq projection instead of quietly costing 40k characters.

mduct config warnAbove 25000

Isolating an agent

Give it a profile and it gets its own config, secrets, OAuth tokens and daemon:

MDUCT_PROFILE=research mduct add notes --url https://mcp.example.com/mcp
MDUCT_PROFILE=research mduct call notes search q=neutrinos

One agent cannot see or use another's servers or credentials. Combine with a guard per server and the blast radius of a confused agent is bounded by something other than its own good judgement.

Nudging it toward the better tool

If a server keeps losing to a habit — an index server losing to grep, an API losing to curl — it can say so at the moment of the call. See Shadowing.

Clone this wiki locally