AGENTS.md
+44 −16
https://raw.githubusercontent.com/grinv/anilist-mcp-server/HEAD/AGENTS.md
− agent. `CLAUDE.md` only links here (`@AGENTS.md`); keep all shared guidance in− this file, not in CLAUDE.md. (For end-user/runtime docs, see [README.md](README.md).)− # result, graphql (the GraphQL request/error-mapping layer)− # login.ts, guard.ts (never-throw wrapper), outputSchemas.ts− npm run build # tsc --noEmit + tsup → dist/index.js (single ESM bundle)− stripping on by default (what runs the tests and `scripts/*.ts`), also required by tsup 9.− tsup targets `node22.18`; `tsconfig.json` uses `module: "node20"` with an− - Tool failures return `{ isError: true }` results (via `guard()` / `result.ts`),− never thrown — the agent should get an actionable message. Mutation/personal− tools are gated by `ctx.requireAuth()` (defined in `clients/anilist/context.ts`,− function that needs it — it throws an actionable `ApiError` before any− network call rather than making a doomed authenticated request.− (`allowImportingTsExtensions`; tsup bundles them the same way). `eslint.config.mjs`− pass. These, plus `tsup.config.ts`, are type-checked via a separate− (`2.3.1`, pinned exact — not a `^range`) ahead of the sibling servers− (`mal-mcp`/`tmdb-mcp`/`steam-games-mcp`, all still on v1). Re-run the full+ agent; Claude Code reads it directly too, so there is no `CLAUDE.md`. If one is+ ever added, it must import this file (`@AGENTS.md`): Claude Code reads+ AGENTS.md on its own only when no CLAUDE.md exists. (For+ end-user/runtime docs, see [README.md](README.md).)+ # result, cancel (the call's AbortSignal), graphql (the+ # GraphQL request/error-mapping layer)+ # login.ts, register.ts (the one tool-registration wrapper),+ # outputSchemas.ts+ # audit-bundle.ts (CI: npm audit over the inlined packages),+ npm run build # tsc --noEmit + tsdown → dist/index.js (single ESM bundle)+ stripping on by default (what runs the tests and `scripts/*.ts`).+ tsdown reads its target from `engines.node`; `tsconfig.json` uses `module: "node20"` with an+ - **Tool failures: throw, never build an error result.** Every tool is+ registered through `tools/register.ts`'s `tool(name, config, handler)`+ (each `registerXTools()` gets it instead of the McpServer); it runs the+ handler with the call's cancellation signal, checks a success against the+ tool's own `outputSchema` (a mismatch is `internal`) and turns any throw+ into an `isError` result via `lib/result.ts`. Throw `ApiError` for an+ upstream failure (facts: code, status, AniList's own `detail`, and this+ server's one-sentence `note` naming the occurrence) and+ `ToolError` for this server's own decisions (`invalid_arguments`,+ `login_required`, `not_configured`) with the sentence the model should+ read; anything else is `internal`. `toProblem()` is the only place+ tool-facing prose is written: the text is the problem's `detail`, and the+ RFC 9457 problem rides in `_meta["io.github.Grinv.anilist-mcp-server/problem"]`+ with no `structuredContent`. A new code needs a `PROBLEMS` entry and a+ `docs/errors.md` section (a test checks both). Mutation/personal tools are+ gated by `ctx.requireAuth()` (defined in `clients/anilist/context.ts`,+ function that needs it — it throws `login_required` before any network+ call rather than making a doomed authenticated request.+ Runtime packages (`@modelcontextprotocol/server`, `zod`) live in+ `devDependencies`, not `dependencies`: tsdown inlines them into+ `dist/index.js`, so `npx` installs nothing. A new runtime package must be+ added to `tsdown.config.ts`'s `bundledDeps` or the build fails; CI audits+ the bundled packages with `scripts/audit-bundle.ts`.+ - `manifest.json` lists no `prompts`, only `prompts_generated: true`: mcpb's+ static prompt text can't express the argument handling in `src/prompts.ts`+ (e.g. a numeric user ID vs a quoted username), so clients take the prompts+ from the server's own `prompts/list`. Its `tools` list stays hand-written+ (short descriptions) and is checked against the registered tools.