idx-cli/web/scripts/gen-mcp-tools.sh
hermes e6805474f5 feat(web): idx website and user docs (Astro Starlight)
Landing page plus docs for install, quickstart, config, the stocks and
ownership CLI, output and exit codes, the MCP server and per-agent setup,
agent usage, and an agent-led install page (agents/install.md) that a
coding agent follows from a one-line prompt.

- Every docs page is also served as Markdown at <path>.md; llms.txt and
  llms-full.txt come from starlight-llms-txt; a SKILL.md for skill-based
  harnesses is under /skills/idx/.
- The CLI reference and MCP tools pages are generated from idx --help and
  the tools golden; a new web-generated flake check fails when they drift.
- nix develop .#web provides bun; Cloudflare Pages builds web/ on pushes.
- Package homepage metadata points at https://idx.rasyidanaf.com.
- .cloudflare/ (the cf CLI's account cache) is git-ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 05:12:45 +00:00

49 lines
1.9 KiB
Bash
Executable file

#!/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 <tools.json>}
cat <<'EOF'
---
title: Tools
description: Every idx-mcp tool and its inputs, generated from the server's tool list.
---
<!-- Generated by web/scripts/gen-mcp-tools.sh; do not edit by hand. -->
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}'