Skip to main content
The backend API is built with tRPC, providing end-to-end type safety from server to client. Every procedure is a typed function with input validation, access control, and metadata — making the API self-documenting and available as an AI agent tool.

Task routes

The task tracker needs routes to create, list, and update tasks. Create src/server/routes/tasks.ts:
Key points:
  • scopedProcedure([]) requires authentication — any logged-in user can call the procedure
  • scopedProcedure(['tasks:viewAll']) additionally requires the tasks:viewAll scope
  • Every procedure must include .meta({ description }) — the build fails without it. The description is used by the AI agent, HTTP API docs, MCP server, and built-in docs pages.
  • Input is validated with Zod — invalid input returns a 400 error before the handler executes
  • ctx.userId identifies the authenticated user — never accept user identity as input

Registering routers

Register the new tasksRouter with the app in src/server/router.ts:
Always include all system routers. The built-in admin pages, docs pages, and monitoring pages depend on them.
For the full context object, procedure type variants, streaming procedures, and MCP exclusion, see the Procedures reference.