@Tool({...}) or as a function via tool().
Minimal tool (class)
Inline tool (function builder)
Tool metadata
annotationshint model & UI behavior (read-only, idempotent, etc.).hideFromDiscoverykeeps a tool callable but offtool/list.- Tools can attach per-tool hooks (see Advanced → Hooks).
rawInputSchemalets you share a JSON Schema version of the input (handy for the Inspector or adapters) while still passing a raw Zod shape toinputSchema.
Input & output schema shapes
inputSchema can be a full z.object({...}) or just the raw shape ({ name: z.string() }). The SDK wraps raw shapes into an object internally, so you can keep declarations terse and still get proper validation.
Set rawInputSchema when you also want to expose the JSON Schema equivalent of your input — the OpenAPI adapter and Inspector will reuse it without needing to reverse-engineer your Zod types.
outputSchema accepts:
- Literal primitives (
'string','number','boolean','date') when you return scalars. 'image','audio','resource', or'resource_link'when you emit MCP resource descriptors.- Any Zod schema (objects, unions, arrays, discriminated unions, etc.).
- An array of the above to build tuple-like responses; each entry becomes a separate structured content item in the MCP response.
Return values
- Return primitives, structured objects, tuples, or MCP resources. When
outputSchemais provided (literal, array, or Zod), the SDK validates the response and propagates the right metadata to clients. - Errors are surfaced via MCP error responses; you can also throw typed errors inside executors.

