|
1 | | -using ModelContextProtocol; |
2 | | -using Microsoft.Extensions.Hosting; |
| 1 | +using Microsoft.Extensions.Hosting; |
3 | 2 | using ModelContextProtocol.Protocol.Types; |
4 | | -using EverythingServer.Tools; |
5 | 3 | using EverythingServer; |
6 | 4 | using ModelContextProtocol.Server; |
7 | 5 | using Microsoft.Extensions.AI; |
8 | 6 | using Microsoft.Extensions.DependencyInjection; |
| 7 | +using EverythingServer.Prompts; |
| 8 | +using EverythingServer.Tools; |
9 | 9 |
|
10 | 10 | var builder = Host.CreateEmptyApplicationBuilder(settings: null); |
11 | 11 |
|
|
14 | 14 | builder.Services |
15 | 15 | .AddMcpServer() |
16 | 16 | .WithStdioServerTransport() |
17 | | - .WithToolsFromAssembly() |
18 | | - .WithListPromptsHandler((ctx, ct) => |
19 | | - { |
20 | | - return Task.FromResult(new ListPromptsResult |
21 | | - { |
22 | | - Prompts = |
23 | | - [ |
24 | | - new Prompt { Name= "simple_prompt", Description = "A prompt without arguments" }, |
25 | | - new Prompt { Name= "complex_prompt", Description = "A prompt with arguments", Arguments = [ |
26 | | - new PromptArgument { Name = "temperature", Description = "Temperature setting", Required = true }, |
27 | | - new PromptArgument { Name = "style", Description = "Output style", Required = false } |
28 | | - ] |
29 | | - } |
30 | | - ] |
31 | | - }); |
32 | | - }) |
33 | | - .WithGetPromptHandler((args, ct) => |
34 | | - { |
35 | | - List<PromptMessage> messages = args.Params?.Name switch |
36 | | - { |
37 | | - "simple_prompt" => [new PromptMessage { Role = Role.User, Content = new Content { Type = "text", Text = "This is a simple prompt without arguments" } }], |
38 | | - "complex_prompt" => [ |
39 | | - new PromptMessage { Role = Role.User, Content = new Content { Type = "text", Text = $"This is a complex prompt with arguments: temperature={args.Params?.Arguments?["temperature"]}, style={(args.Params?.Arguments?.ContainsKey("style") == true ? args.Params?.Arguments?["style"] : "")}" } }, |
40 | | - new PromptMessage { Role = Role.Assistant, Content = new Content { Type = "text", Text = "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" } }, |
41 | | - new PromptMessage { Role = Role.User, Content = new Content { Type = "image", Data = TinyImageTool.MCP_TINY_IMAGE.Split(",").Last(), MimeType = "image/png" } } |
42 | | - ] |
43 | | - , |
44 | | - _ => throw new NotSupportedException($"Unknown prompt name: {args.Params?.Name}") |
45 | | - }; |
46 | | - |
47 | | - return Task.FromResult(new GetPromptResult |
48 | | - { |
49 | | - Messages = messages |
50 | | - }); |
51 | | - }) |
| 17 | + .WithTools<AddTool>() |
| 18 | + .WithTools<AnnotatedMessageTool>() |
| 19 | + .WithTools<EchoTool>() |
| 20 | + .WithTools<LongRunningTool>() |
| 21 | + .WithTools<PrintEnvTool>() |
| 22 | + .WithTools<SampleLlmTool>() |
| 23 | + .WithTools<TinyImageTool>() |
| 24 | + .WithPrompts<ComplexPromptType>() |
| 25 | + .WithPrompts<SimplePromptType>() |
52 | 26 | .WithListResourceTemplatesHandler((ctx, ct) => |
53 | 27 | { |
54 | 28 | return Task.FromResult(new ListResourceTemplatesResult |
|
0 commit comments