-
Notifications
You must be signed in to change notification settings - Fork 689
Expand file tree
/
Copy pathAnnotatedMessageTool.cs
More file actions
53 lines (48 loc) · 1.72 KB
/
AnnotatedMessageTool.cs
File metadata and controls
53 lines (48 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using ModelContextProtocol.Protocol;
using ModelContextProtocol.Server;
using System.ComponentModel;
using System.Text;
namespace EverythingServer.Tools;
[McpServerToolType]
public class AnnotatedMessageTool
{
public enum MessageType
{
Error,
Success,
Debug,
}
[McpServerTool(Name = "annotatedMessage"), Description("Generates an annotated message")]
public static IEnumerable<ContentBlock> AnnotatedMessage(MessageType messageType, bool includeImage = true)
{
List<ContentBlock> contents = messageType switch
{
MessageType.Error => [new TextContentBlock
{
Text = "Error: Operation failed",
Annotations = new() { Audience = [Role.User, Role.Assistant], Priority = 1.0f }
}],
MessageType.Success => [new TextContentBlock
{
Text = "Operation completed successfully",
Annotations = new() { Audience = [Role.User], Priority = 0.7f }
}],
MessageType.Debug => [new TextContentBlock
{
Text = "Debug: Cache hit ratio 0.95, latency 150ms",
Annotations = new() { Audience = [Role.Assistant], Priority = 0.3f }
}],
_ => throw new ArgumentOutOfRangeException(nameof(messageType), messageType, null)
};
if (includeImage)
{
contents.Add(new ImageContentBlock
{
Data = Encoding.UTF8.GetBytes(TinyImageTool.MCP_TINY_IMAGE.Split(",").Last()),
MimeType = "image/png",
Annotations = new() { Audience = [Role.User], Priority = 0.5f }
});
}
return contents;
}
}