You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -226,14 +226,36 @@ All resources, tools, and prompts support an optional `title` field for better U
226
226
227
227
**Note:** The `register*` methods (`registerTool`, `registerPrompt`, `registerResource`) are the recommended approach for new code. The older methods (`tool`, `prompt`, `resource`) remain available for backwards compatibility.
228
228
229
+
#### Title Precedence for Tools
230
+
231
+
For tools specifically, there are two ways to specify a title:
232
+
-`title` field in the tool configuration
233
+
-`annotations.title` field (when using the older `tool()` method with annotations)
234
+
235
+
The precedence order is: `title` → `annotations.title` → `name`
236
+
237
+
```typescript
238
+
// Using registerTool (recommended)
239
+
server.registerTool("my_tool", {
240
+
title: "My Tool", // This title takes precedence
241
+
annotations: {
242
+
title: "Annotation Title"// This is ignored if title is set
243
+
}
244
+
}, handler);
245
+
246
+
// Using tool with annotations (older API)
247
+
server.tool("my_tool", "description", {
248
+
title: "Annotation Title"// This is used as title
249
+
}, handler);
250
+
```
229
251
230
252
When building clients, use the provided utility to get the appropriate display name:
0 commit comments