tool-handler-development

A development guide for adding or changing Bazel MCP tool handlers. Bazel is a build system, and MCP tools are callable actions exposed to an AI agent.

In plain words
What is it for?
It helps developers add tool definitions, connect tool names to handler code, support Bazel commands, and update handler tests.
Why use it?
It defines the required structure and registration steps so new tools are recognized and handle requests consistently.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/debugswift/xcodebazelmcp/tool-handler-development
Any agent
npx skills add DebugSwift/XcodeBazelMCP --skill tool-handler-development
Clone the repo
git clone --depth 1 https://github.com/DebugSwift/XcodeBazelMCP

Made for: Claude Code, Codex.

Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 689 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00037 $0.00689
Opus 5 $0.00018 $0.00345
Sonnet 5 $0.00007 $0.00138
Haiku 4.5 $0.00004 $0.00069

Measured yesterday against content hash 9ae9784fe77f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tool-handler-development scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/tool-handler-development/SKILL.md · 69 lines

How it starts

The opening of the file, as written. The whole thing — 69 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Tool Handler Development

Handler Contract

Every handler file under src/tools/handlers/ must export:

export const definitions: ToolDefinition[] = [...]
export function canHandle(name: string): boolean { ... }
export function handle(name: string, args: Record<string, unknown>): Promise<ToolResult | undefined>
  • canHandle returns true for tool names this handler owns.
  • handle returns undefined for unknown tools (not an error).
  • definitions is an array of tool definitions with name, description, inputSchema, and optional startupArgs, streaming, required fields.

Adding a New Tool

  1. Pick the right handler file based on domain (build, simulator, device, etc.) or create a new one.
  2. Add the tool definition to definitions.
  3. Add the case to handle().
  4. If it's a new handler file, register it in src/tools/bazel-tools.ts (import + add to the aggregated arrays).
  5. Update the expected tool count in handlers/handlers.test.ts.
  6. If the tool uses Bazel commands, include startupArgs in the schema.

Tool Definition Schema

{
  name: 'bazel_ios_<action>',
  description: 'One-line description of what the tool does',
  inputSchema: {
    type: 'object',
    properties: { ... },
    required: ['target'],
  },
  startupArgs: true,    // if tool accepts --startup_arg flags
  streaming: true,      // if tool supports streaming output
}

Workflow Categories

Tools belong to one of 19 workflows: build, test, simulator, app_lifecycle, capture, ui_automation, deep_links, device, lldb, macos, tvos, watchos, visionos, spm, project, scaffold, session, daemon, update.

Assign the workflow in the handler or the workflow mapping. bazel_list_workflows and bazel_toggle_workflow are always included regardless of filtering.

Common Patterns

  • Use asStringArray(args.configs, 'configs') for array params — don't double-wrap with configArgs().
  • Use resolveSimulatorFromArgs(args) for simulator resolution (returns { sim, warning }).
  • Use prependWarning(message, warning) to attach resolution warnings to output.
  • Wrap readBundleId calls in try/catch — they can throw after a successful build+install.
  • Escape quotes in --predicate strings: .replace(/"/g, '\\"') on interpolated values.

Read the full file on GitHub · 69 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 69 lines · 37 tokens per session scan A 9ae9784fe77f

Subscribe to this mod's changes

tool-handler-development is a skill published in the GitHub repository DebugSwift/XcodeBazelMCP (7 stars, last pushed 1mo ago), licensed MIT. It adds 37 tokens to every session and 689 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.