Skip to main content

Auto-generation of MCP tools

When you create a function with define(), it is automatically exposed as an MCP (Model Context Protocol) tool. Your AI agents can discover and invoke your function as a tool without additional configuration.

Example

For this function:
index.ts
The /mcp endpoint exposes this schema:

The description field: the most important thing for MCP

The description field of your define() is what the AI agent reads to decide when to invoke your tool. If the description is vague, the agent will not know when to use it — or worse, will use it at the wrong time.

.describe() annotations on fields

Zod .describe() annotations become parameter descriptions in the MCP tool. This is what AI agents see when they discover your function:
Write clear and specific descriptions in .describe(). AI agents use these descriptions to decide what values to pass to your function.

Testing the MCP endpoint

Start the local server with jelou functions dev and query the MCP schema:
Invoke the function directly:
In production:

Disabling MCP

If your function should not be discoverable as a tool (for example, a webhook that only receives callbacks), disable MCP:
When MCP is disabled, the /mcp endpoint returns 404.

How agents use it

When you configure an AI agent in Jelou Brain Studio and assign functions as tools, the agent:
  1. Discovers available tools via the /mcp endpoint
  2. Reads the name, description, and input schema
  3. Decides when to invoke the tool based on the user’s conversation
  4. Sends validated parameters to your function
  5. Receives the response and incorporates it into the conversation
All of this happens automatically — you only need to write the function with define() and assign it to the agent.

Multi-tool MCP

When you use app(), a single MCP server at /mcp automatically registers all tools. Each tool appears as an independent tool with its name, description, and schema. To exclude a specific tool from the MCP registry, use mcp: false in its config:
In this example, AI agents discover queryBalance via MCP but paymentWebhook is only accessible via direct HTTP at /payment-webhook.
See the full multi-tool guide for more details about auto-generated routes and config combination.