Use a tool when the client is asking your server to do work. In Redop, a tool is defined by the registration call as a whole, not just the handler. That means the tool name, metadata, schemas, annotations, hooks, middleware, and handler should be designed together. This page focuses on tool design and usage. For the exact field-by-field contract, use Tool Definition.Documentation Index
Fetch the complete documentation index at: https://redop.useagents.site/docs/llms.txt
Use this file to discover all available pages before exploring further.
A complete tool usually includes
The registration call has two parts
Every tool starts with:- the tool name, which is the first argument to
.tool(...) - the tool definition object, which is the second argument
Tool name
The tool name is a programmatic identifier exposed to MCP clients. Use a tool name that is:- stable
- action-oriented
- easy for clients to understand
search_docscreate_postlist_usersnotes.listbilling.invoice.create
runhandleprocess
Design the tool as one unit
A good tool definition is coherent from top to bottom:- the name states the action
- the description explains the purpose
- the input schema defines the contract
- the output schema describes the result
- annotations communicate behavior
- hooks and middleware stay tool-specific
- the handler performs the actual work
Metadata
Use metadata to help clients and agents understand the tool before calling it:descriptionshould explain what the tool does in plain languagetitleis only useful when a friendlier display label helpsiconsare optional and only matter for clients that render them
description for meaning. Use title only when a friendlier display label is useful.
Input schema
inputSchema defines the arguments the tool accepts.
Use it when you need:
- runtime validation
- type inference
- JSON Schema exported to MCP clients
inputSchema, the handler receives the raw params object.
See Validation for a full guide to supported schema libraries and runtime behavior.
Output schema
outputSchema describes the structured result shape for clients and agents.
Like inputSchema, it can use any schema format Redop can adapt:
- Standard Schema libraries such as Zod, Valibot, and ArkType
- TypeBox
- plain JSON Schema
outputSchema at runtime.
Use it when clients should understand the response shape before calling the tool.
Annotations
annotations give clients extra behavioral hints. Redop passes these hints through to MCP clients, but it does not enforce them at runtime.
Use annotations when they help a client or agent decide whether and how to call a tool.
How to choose each annotation
| Annotation | Meaning | Use when | Avoid when |
|---|---|---|---|
readOnlyHint | The tool reads data and does not mutate state. | Search, list, inspect, preview, validate, fetch. | The tool creates, updates, deletes, triggers, or mutates anything. |
destructiveHint | The tool may make a hard-to-undo or high-impact change. | Delete, cancel, revoke, overwrite, charge, publish live changes. | Safe reads or routine low-risk updates. |
idempotentHint | Repeating the same call should have the same effect without compounding side effects. | Sync, set, replace, upsert, ensure-state operations. | Retries would duplicate work, create duplicates, or trigger repeated actions. |
openWorldHint | The tool depends on external or live information beyond the server’s local state. | Web search, external APIs, SaaS lookups, live environment inspection. | Fully local deterministic operations over server-owned data. |
Examples
UsereadOnlyHint for tools such as:
search_docslist_postspreview_invoice
destructiveHint for tools such as:
delete_postcancel_deploymentrevoke_api_key
idempotentHint for tools such as:
sync_customerset_feature_flagupsert_contact
openWorldHint for tools such as:
search_webfetch_github_issuelookup_stripe_customer
Combining annotations
Annotations are independent hints, so a tool can use more than one. Common combinations:readOnlyHint: trueandidempotentHint: truefor local search or lookup toolsreadOnlyHint: trueandopenWorldHint: truefor external search or live fetch toolsdestructiveHint: trueandopenWorldHint: truefor tools that change remote systems
readOnlyHint: true with destructiveHint: true.
Hooks and middleware
Tool definitions can include per-tool execution logic around the handler:beforeruns before middleware and the handlerafterruns after a successful result and may replace itafterResponseruns after the response is written and cannot replace the resultmiddlewarewraps only that tool
afterResponse for:
- analytics
- logging
- metrics
- search impressions
after instead when the logic must still be able to inspect or replace the result before the client receives it.
Handler
handler is the tool implementation. It is the only required field.
The handler receives:
inputctxrequesttoolemit.progress(...)signal
Task support
UsetaskSupport only when you are designing around task-aware clients. Most tools can leave it unset.