@@ -60,13 +60,21 @@ const EXAMPLE_COMPLETIONS = {
6060
6161const GetTinyImageSchema = z . object ( { } ) ;
6262
63+ const AnnotatedMessageSchema = z . object ( {
64+ messageType : z . enum ( [ "error" , "success" , "debug" ] )
65+ . describe ( "Type of message to demonstrate different annotation patterns" ) ,
66+ includeImage : z . boolean ( ) . default ( false )
67+ . describe ( "Whether to include an example image" )
68+ } ) ;
69+
6370enum ToolName {
6471 ECHO = "echo" ,
6572 ADD = "add" ,
6673 LONG_RUNNING_OPERATION = "longRunningOperation" ,
6774 PRINT_ENV = "printEnv" ,
6875 SAMPLE_LLM = "sampleLLM" ,
6976 GET_TINY_IMAGE = "getTinyImage" ,
77+ ANNOTATED_MESSAGE = "annotatedMessage" ,
7078}
7179
7280enum PromptName {
@@ -329,6 +337,11 @@ export const createServer = () => {
329337 description : "Returns the MCP_TINY_IMAGE" ,
330338 inputSchema : zodToJsonSchema ( GetTinyImageSchema ) as ToolInput ,
331339 } ,
340+ {
341+ name : ToolName . ANNOTATED_MESSAGE ,
342+ description : "Demonstrates how annotations can be used to provide metadata about content" ,
343+ inputSchema : zodToJsonSchema ( AnnotatedMessageSchema ) as ToolInput ,
344+ } ,
332345 ] ;
333346
334347 return { tools } ;
@@ -436,6 +449,57 @@ export const createServer = () => {
436449 } ;
437450 }
438451
452+ if ( name === ToolName . ANNOTATED_MESSAGE ) {
453+ const { messageType, includeImage } = AnnotatedMessageSchema . parse ( args ) ;
454+
455+ const content = [ ] ;
456+
457+ // Main message with different priorities/audiences based on type
458+ if ( messageType === "error" ) {
459+ content . push ( {
460+ type : "text" ,
461+ text : "Error: Operation failed" ,
462+ annotations : {
463+ priority : 1.0 , // Errors are highest priority
464+ audience : [ "user" , "assistant" ] // Both need to know about errors
465+ }
466+ } ) ;
467+ } else if ( messageType === "success" ) {
468+ content . push ( {
469+ type : "text" ,
470+ text : "Operation completed successfully" ,
471+ annotations : {
472+ priority : 0.7 , // Success messages are important but not critical
473+ audience : [ "user" ] // Success mainly for user consumption
474+ }
475+ } ) ;
476+ } else if ( messageType === "debug" ) {
477+ content . push ( {
478+ type : "text" ,
479+ text : "Debug: Cache hit ratio 0.95, latency 150ms" ,
480+ annotations : {
481+ priority : 0.3 , // Debug info is low priority
482+ audience : [ "assistant" ] // Technical details for assistant
483+ }
484+ } ) ;
485+ }
486+
487+ // Optional image with its own annotations
488+ if ( includeImage ) {
489+ content . push ( {
490+ type : "image" ,
491+ data : MCP_TINY_IMAGE ,
492+ mimeType : "image/png" ,
493+ annotations : {
494+ priority : 0.5 ,
495+ audience : [ "user" ] // Images primarily for user visualization
496+ }
497+ } ) ;
498+ }
499+
500+ return { content } ;
501+ }
502+
439503 throw new Error ( `Unknown tool: ${ name } ` ) ;
440504 } ) ;
441505
0 commit comments