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.
npx next-ai-ready initCreates:
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 apinghealth check.
Use --force to overwrite existing files.
`next-ai-ready build`
Scans content, compiles the semantic graph, and emits all artifacts.
npx next-ai-ready buildWhat 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## FAQwhenquestionsexist 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:
{
"scripts": {
"build": "next-ai-ready build && next build"
}
}`next-ai-ready doctor`
Validates your config, action exposure rules, and route wiring.
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. Config — ai-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 stubs — app/_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 quality — noai 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:
# .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.
npx next-ai-ready mcpOptions:
| Flag | Description |
|---|---|
--no-resources | Skip page resource registration (faster startup). |
Use with Claude Desktop:
{
"mcpServers": {
"my-site": {
"command": "npx",
"args": ["next-ai-ready", "mcp"]
}
}
}Exit codes
| Code | Meaning |
|---|---|
0 | Success. |
1 | Error (missing config, invalid actions, build failure). |
2 | Unknown command. |