feat: add optional resource annotations (#954)

Co-authored-by: Konstantin Konstantinov <konstantin@mach5technology.com>
This commit is contained in:
Vincent Horvath 2025-12-03 00:22:20 -05:00 • committed by GitHub
commit 4b5c25d592
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,14 +10,14 @@ import { BaseMetadata } from '../types.js';
* For other objects: title → name
* This implements the spec requirement: "if no title is provided, name should be used for display purposes"
*/
export function getDisplayName(metadata: BaseMetadata & { annotations?: { title?: string } }): string {
export function getDisplayName(metadata: BaseMetadata | (BaseMetadata & { annotations?: { title?: string } })): string {
// First check for title (not undefined and not empty string)
if (metadata.title !== undefined && metadata.title !== '') {
return metadata.title;
}
// Then check for annotations.title (only present in Tool objects)
if (metadata.annotations?.title) {
if ('annotations' in metadata && metadata.annotations?.title) {
return metadata.annotations.title;
}