When to use app() vs define()?
If your project has a single handler, use
define(). If you need to group multiple operations — for example, sending and reading emails from the same service — use app().
Basic example
index.ts
Local testing
Start the server withjelou functions dev and test each tool at its route:
400 with details:
API
AppConfig
Auto-generated routes
Yourtools object keys are automatically converted to kebab-case to generate HTTP routes:
To customize a route, use
config.path in the individual define():
Config combination
The global config ofapp() applies to all tools. Each define() can override specific values:
fast has a 5-second timeout and slow inherits the global 30 seconds. Both share the CORS configuration.
Health endpoint
In app mode,/__health returns information about all tools:
Type guards
UseisEdgeApp() and isEdgeFunction() to identify the export type at runtime:
Multi-tool cron
Each tool insideapp() can have its own independent cron schedules. Cron requests are sent to the specific route of each tool.
Multi-tool MCP
A single MCP server at/mcp automatically registers all tools from the app(). To exclude a tool from the MCP registry, use mcp: false in its config:
publicTool via MCP. internalTool is only accessible via direct HTTP at its /internal-tool route.
Exposed routes (app mode)
Common issues
- 404 on tool route
- Validation fails with 400
- Tool does not appear in MCP
tools keys are converted to kebab-case. If your key is sendEmail, the route is /send-email, not /sendEmail.Verify the actual routes with the health check:Next steps
Testing
Learn to test multi-tool functions with
createMockApp().MCP
Configure the unified MCP server for your AI agents.
Cron
Independent schedules per tool inside
app().