feat: add optional resource annotations (#954)
Co-authored-by: Konstantin Konstantinov <konstantin@mach5technology.com>
This commit is contained in:
parent
6dd7cd4e16
commit
4b5c25d592
1 changed files with 128 additions and 11 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue