Skip to main content

Basic Usage

Signature

Type Safety

The @Tool decorator provides compile-time type checking:
  • Input validation: The execute() parameter type must exactly match the inputSchema. Mismatches produce a descriptive error at compile time.
  • Output validation: When outputSchema is provided, the execute() return type must be assignable to the inferred output type.
  • Context check: The decorated class must extend ToolContext. Using @Tool on a plain class produces a compile error.
  • Invalid options: Typos in decorator options (e.g., concurrency: { maxConcurrensst: 5 }) are caught at compile time with specific error messages, without losing autocomplete on other fields.

Configuration Options

Required Properties

Optional Properties

Output Types

Authorization

Annotations

Examples

UI Configuration

The ui.template field accepts a builder function, an HTML/MDX string, a React component, or a FileSource (for client-side transpilation):
See the Tool UI guide for the full ToolUIConfig shape (CSP, sanitization, helpers, etc.).

Function-Based Alternative

For simpler tools, use the tool() function:

Context Methods

The ToolContext base class provides:

Dependency Injection

Notifications

Elicitation (Interactive Input)

Platform Detection

Authentication

HTTP Requests

Error Handling

Type Inference

FrontMCP provides helper types for extracting input/output types:

Full Example

ToolContext

Context class details

ToolRegistry

Tool registry API

Tool Errors

Tool-related errors

@Resource

Define resources