Skip to main content
Glama
soriat

MCP Elicitations Demo Server

by soriat

annotatedMessage

Demonstrate how annotations add metadata to content, supporting error, success, or debug message types with optional image inclusion, in the MCP elicitation demo server.

Instructions

Demonstrates how annotations can be used to provide metadata about content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
includeImageNoWhether to include an example image
messageTypeYesType of message to demonstrate different annotation patterns

Implementation Reference

  • The handler function executes the tool logic: parses input arguments using the schema, constructs annotated text and optional image content based on messageType (error, success, debug), and returns structured content with priority and audience annotations.
    handler: async (args: any) => { const { messageType, includeImage } = AnnotatedMessageSchema.parse(args); const content: any[] = []; // Main message with different priorities/audiences based on type if (messageType === "error") { content.push({ type: "text" as const, text: "Error: Operation failed", annotations: { priority: 1.0, // Errors are highest priority audience: ["user", "assistant"], // Both need to know about errors }, }); } else if (messageType === "success") { content.push({ type: "text" as const, text: "Operation completed successfully", annotations: { priority: 0.7, // Success messages are important but not critical audience: ["user"], // Success mainly for user consumption }, }); } else if (messageType === "debug") { content.push({ type: "text" as const, text: "Debug: Cache hit ratio 0.95, latency 150ms", annotations: { priority: 0.3, // Debug info is low priority audience: ["assistant"], // Technical details for assistant }, }); } // Optional image with its own annotations if (includeImage) { content.push({ type: "image" as const, data: MCP_TINY_IMAGE, mimeType: "image/png", annotations: { priority: 0.5, audience: ["user"], // Images primarily for user visualization }, }); } return { content }; },
  • Zod schema defining the input parameters: messageType (enum: error, success, debug) and optional includeImage (boolean, default false). Converted to JSON schema for the tool inputSchema.
    const AnnotatedMessageSchema = z.object({ messageType: z .enum(["error", "success", "debug"]) .describe("Type of message to demonstrate different annotation patterns"), includeImage: z .boolean() .default(false) .describe("Whether to include an example image"), });
  • The annotatedMessageTool is imported (line 13) and included in the allTools array, which is used by getTools() to list tool specifications and getToolHandler() to dispatch calls to the correct handler during MCP server setup.
    const allTools = [ echoTool, addTool, longRunningOperationTool, printEnvTool, sampleLlmTool, sampleWithPreferencesTool, sampleMultimodalTool, sampleConversationTool, sampleAdvancedTool, getTinyImageTool, annotatedMessageTool, getResourceReferenceTool, elicitationTool, getResourceLinksTool, ];

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/soriat/soria-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server