Tools
Create MCP tools with Zod validation and type safety.

What are Tools?

Tools are functions that AI assistants can call to perform actions or retrieve information. They accept validated input parameters and return structured results.

Scaffold a new MCP tool

Basic Tool Definition

Here's a simple tool that echoes back a message:

server/mcp/tools/echo.ts
import { z } from 'zod'
import { defineMcpTool } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpTool({
  name: 'echo',
  description: 'Echo back a message',
  inputSchema: {
    message: z.string().describe('The message to echo back'),
  },
  handler: async ({ message }) => `Echo: ${message}`,
})

Auto-Generated Name and Title

You can omit name and title - they will be automatically generated from the filename:

server/mcp/tools/list-documentation.ts
import { defineMcpTool } from '@nuxtjs/mcp-toolkit/server'

export default defineMcpTool({
  // name and title are auto-generated from filename:
  // name: 'list-documentation'
  // title: 'List Documentation'
  description: 'List all documentation files',
  handler: async () => {
    // ...
  },
})

The filename list-documentation.ts automatically becomes:

  • name: list-documentation (kebab-case)
  • title: List Documentation (title case)

You can still provide name or title explicitly to override the auto-generated values.

Tool Structure

A tool definition consists of:

export default defineMcpTool({
  name: 'tool-name',        // Unique identifier (optional - auto-generated from filename)
  inputSchema: { ... },      // Zod schema for input validation
  handler: async (args) => {
    return 'result'          // string, number, boolean, object, or CallToolResult
  },
})

Going further

Once you've authored a few tools, branch out:

Integrate external APIs

Call third-party services, use useEvent(), and cache responses with Nitro.

Authenticate clients

Bearer tokens, Better Auth API keys, and per-tool enabled guards.

Use Code Mode

Let the LLM orchestrate multiple tool calls in a single sandboxed JS execution.

Multi-handler organization

Attribute tools to dedicated MCP routes via the handlers/<name>/ folder convention.
Copyright © 2026