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
  },
})

In-depth guides

The Tools documentation is split into focused pages so the table of contents stays scannable.

Schema, handler & returns

Zod inputSchema / outputSchema, handler return types, and media helpers.

Annotations & input examples

Hints for clients, inputExamples for model-friendly samples.

Errors & response caching

H3 and plain errors, Nitro cache options.

Groups, files & dynamic registration

group / tags, layout on disk, enabled guards, next steps.
Copyright © 2026