#!/usr/bin/env bash # Writes the MCP tools page from idx-mcp's tools golden # (crates/idx-mcp/tests/golden/tools.json). `nix flake check` fails when the # committed page is out of date. # # web/scripts/gen-mcp-tools.sh crates/idx-mcp/tests/golden/tools.json > web/src/content/docs/mcp/tools.md set -euo pipefail tools=${1:?usage: gen-mcp-tools.sh } cat <<'EOF' --- title: Tools description: Every idx-mcp tool and its inputs, generated from the server's tool list. --- idx-mcp serves these tools. `ownership_sync` is listed only when the server starts with `--allow-sync`. Results that come from a live provider are wrapped as `{data, source, fetched_at, stale}`; failures return `{error, code, message}` with `isError` set. EOF jq -r ' def typ($defs): if .["$ref"] then ($defs[.["$ref"] | sub("^#/\\$defs/"; "")] | .enum | map("`" + . + "`") | join(" / ")) elif .enum then (.enum | map("`" + tostring + "`") | join(" / ")) elif (.type | type) == "array" then (.type | map(select(. != "null")) | join(" | ")) + (if .items then " of " + (.items | typ($defs)) else "" end) elif .type == "array" and .items then "array of " + (.items | typ($defs)) else (.type // "any") end; [.[] | .inputSchema as $s | ($s["$defs"] // {}) as $defs | ($s.required // []) as $req | "## `\(.name)`\n\n\(.description)\n\n" + (if ($s.properties // {}) == {} then "No inputs.\n" else "| Input | Type | Required | Description |\n| --- | --- | --- | --- |\n" + ([$s.properties | to_entries[] | .key as $k | "| `\($k)` | \(.value | typ($defs)) | \(if ($req | index($k)) then "yes" else "no" end) | \((.value.description // "") | gsub("\\|"; "\\|") | gsub("\n"; " ")) |"] | join("\n")) + "\n" end)] | join("\n") ' "$tools" | sed '${/^$/d}'