DubStack
Guides

MCP Server

Connect MCP-aware agents to DubStack stack tools, gated by a per-repo security model.

DubStack includes a stdio Model Context Protocol server so agents can inspect and (optionally) drive a tracked repository without shelling out to free-form commands.

Install

From any shell where dub is available:

claude mcp add dubstack dub mcp

Then ask your MCP-aware agent about the current repository:

Show me the current DubStack stack.

The agent can call dubstack.log and receive structured JSON for the tracked stack tree.

Read-only tools

ToolDescription
dubstack.logReturns the tracked stack tree as JSON
dubstack.doctorReturns health issues and remediation steps
dubstack.statusReturns current branch, tracking info, PR state, and drift
dubstack.parentReturns the direct parent for a branch
dubstack.childrenReturns direct children for a branch
dubstack.trunkReturns the trunk/root branch for a branch
dubstack.historyReturns recent Dub command history
dubstack.branchReturns single-branch stack metadata
dubstack.diffReturns a branch diff vs its parent or an explicit base
dubstack.readyReturns a pre-submit readiness checklist
dubstack.merge_checkReturns a PR/branch/stack mergeability snapshot

AI-cooperative tools

These tools call the configured AI provider but do not mutate git, DubStack state, or GitHub. They are available in every MCP mode when the repo has dub config ai-assistant on and a provider configured.

ToolDescription
dubstack.propose_branch_nameSuggests a branch name from a diff
dubstack.propose_commit_messageSuggests a Conventional Commit message from a diff
dubstack.propose_pr_descriptionSuggests PR markdown from branch/base/message/diff context

Mutating tools

ToolDescription
dubstack.createCreate a stacked branch (optionally with a commit message or --ai)
dubstack.modifyAmend the current tip or commit new changes, then restack children
dubstack.submitPush the current path or stack and create/update GitHub PRs
dubstack.syncSync tracked branches with the remote and reconcile divergence
dubstack.checkoutSwitch to a tracked branch (stack-aware)
dubstack.backReturn to a previously checked-out branch (steps optional)
dubstack.deleteDelete a local branch and update DubStack metadata
dubstack.reorderReorder or drop commits on the current tracked branch from a supplied todo
dubstack.freezeMark a branch or stack scope as frozen
dubstack.unfreezeClear the frozen marker from a branch or stack scope
dubstack.splitSplit the current branch by file, commit, or AI proposal (by-hunk remains terminal-only)
dubstack.absorbDistribute fixup commits to their targets
dubstack.squashCollapse branch commits into one commit
dubstack.foldCombine the current branch into its parent
dubstack.popPop recent commits into staged changes
dubstack.renameRename a tracked branch and update stack metadata
dubstack.moveMove a branch before/after another branch in the stack
dubstack.unlinkDetach a branch from its parent without deleting branches
dubstack.revertCreate a tracked revert branch on trunk
dubstack.stashCreate a branch-aware stash entry
dubstack.stash-popPop the most recent branch-aware stash

Mutating tools are gated by the configured MCP mode (see below).

Return shapes

Read-only and AI-cooperative tools return JSON as both MCP text content and structuredContent:

{
  "content": [{ "type": "text", "text": "{ ... }" }],
  "structuredContent": {
    "branch": "feat/example",
    "base": "main",
    "diff": "..."
  }
}

Mutating tools wrap the command result and captured terminal output:

{
  "content": [{ "type": "text", "text": "{ ... }" }],
  "structuredContent": {
    "result": { "branch": "feat/example" },
    "output": "..."
  }
}

Refusals and user-facing command failures return isError: true with a text payload suitable for agent display.

Security model

Choose how aggressive the agent's automation is for this repository:

dub config mcp-mode read-only    # only read tools work; mutating tools return a refusal payload
dub config mcp-mode interactive  # mutating tools require explicit y/n confirmation in the dub mcp terminal (DEFAULT)
dub config mcp-mode trusted      # mutating tools run without confirmation

Run dub config mcp-mode with no argument to inspect the current value.

read-only

Mutating tools return a structured refusal that the agent can surface cleanly:

{
  "isError": true,
  "content": [{
    "type": "text",
    "text": "dubstack.create refused: repo is in read-only MCP mode. Run `dub config mcp-mode interactive` to enable mutating tools."
  }]
}

interactive (default)

When the MCP server receives a mutating tool call, it opens the controlling terminal (/dev/tty) where dub mcp is running, prints a confirmation prompt, and waits for y/n. If no controlling terminal is available, the tool refuses with a clear message asking you to switch to trusted or read-only mode.

This is the right default for workflows like Claude Code, where dub mcp runs in a known terminal pane.

trusted

Mutating tools execute immediately without confirmation. Use this only when you fully trust the agent driving DubStack.

Audit history

Every MCP tool invocation — successful, refused, or failed — is appended to dub history:

dub history

For mutating tools, the audit command includes redacted arguments plus an args_sha256 fingerprint so reviewers can compare what an agent passed without exposing secrets in history.

Protocol

dub mcp uses MCP stdio transport. Clients write newline-delimited JSON-RPC messages to stdin, and DubStack writes JSON-RPC responses to stdout.

The server supports:

  • initialize
  • tools/list
  • tools/call
  • ping
  • notifications/initialized

On this page