api reference

CLI

Command-line interface — init, build, doctor, and mcp.

next-ai-ready provides four CLI commands for building, validating, and running your AI-ready site.

Commands

`next-ai-ready init`

Scaffolds handler stubs and config into your project.

bash
npx next-ai-ready init

Creates:

  • ai-ready.config.mjs — site configuration with placeholder values.
  • app/_ai-ready/ — route handler stubs (one-line re-exports).
  • app/api/actions/[name]/route.ts — action execution endpoint.
  • app/api/mcp/[transport]/route.ts — MCP server endpoint.
  • actions/index.mjs — starter action file with a ping health check.

Use --force to overwrite existing files.

`next-ai-ready build`

Scans content, compiles the semantic graph, and emits all artifacts.

bash
npx next-ai-ready build

What it produces:

  • .next-ai-ready/graph.json — the SemanticGraph.
  • .next-ai-ready/actions.manifest.json — action manifest with JSON Schemas.
  • public/llms.txt — site-wide LLM index.
  • public/llms-full.txt — full content dump (page bodies plus ## FAQ when questions exist in frontmatter).
  • public/openapi.json — OpenAPI 3.1 spec.
  • public/tools.json — tool definitions.
  • public/.well-known/ai-plugin.json — plugin manifest.
  • public/robots.txt — AI-bot policy.

Use --silent to suppress console output (useful in CI).

Typical package.json setup:

json
{
  "scripts": {
    "build": "next-ai-ready build && next build"
  }
}

`next-ai-ready doctor`

Validates your config, action exposure rules, and route wiring.

bash
npx next-ai-ready doctor
npx next-ai-ready doctor --score   # 0–100 AI-readiness score + top fixes
npx next-ai-ready doctor --json    # machine-readable report (includes actionItems)

Checks include:

1. Configai-ready.config.mjs with required site.name, site.baseUrl, and site.description.

2. Actions — public vs private counts; warns if public actions lack whenToUse.

3. Build artifacts — graph, OpenAPI, package.json prebuild script.

4. Route stubsapp/_ai-ready/* handler files and withAiReady() in next.config.

5. Robots — static public/robots.txt or app/robots.ts (when emit.robots: false, doctor does not warn about a missing static file).

6. MCP — warns if NEXT_AI_READY_MCP_TOKEN is unset in production.

7. Content qualitynoai meta, JSON-LD helpers, updatedAt / author coverage in the graph.

Exits with code 1 if any errors are found. Warnings do not cause a non-zero exit.

With --score, the CLI prints Top fixes (e.g. add prebuild, set MCP token, add updatedAt to frontmatter).

Use in CI:

yaml
# .github/workflows/ci.yml
- run: npx next-ai-ready doctor --score

`next-ai-ready mcp`

Starts an MCP server over stdio for local desktop clients.

bash
npx next-ai-ready mcp

Options:

FlagDescription
--no-resourcesSkip page resource registration (faster startup).

Use with Claude Desktop:

json
{
  "mcpServers": {
    "my-site": {
      "command": "npx",
      "args": ["next-ai-ready", "mcp"]
    }
  }
}

Exit codes

CodeMeaning
0Success.
1Error (missing config, invalid actions, build failure).
2Unknown command.