22using Microsoft . Extensions . Hosting ;
33using ModelContextProtocol . Protocol . Types ;
44using EverythingServer . Tools ;
5+ using EverythingServer ;
56
67var builder = Host . CreateEmptyApplicationBuilder ( settings : null ) ;
78
1819 new Prompt { Name = "simple_prompt" , Description = "A prompt without arguments" } ,
1920 new Prompt { Name = "complex_prompt" , Description = "A prompt with arguments" , Arguments = [
2021 new PromptArgument { Name = "temperature" , Description = "Temperature setting" , Required = true } ,
21- new PromptArgument { Name = "style" , Description = "Output style" , Required = false }
22+ new PromptArgument { Name = "style" , Description = "Output style" , Required = false }
2223 ]
2324 }
2425 ]
4243 {
4344 Messages = messages
4445 } ) ;
45- } ) ;
46+ } )
47+ . WithListResourceTemplatesHandler ( ( ctx , ct ) =>
48+ {
49+ return Task . FromResult ( new ListResourceTemplatesResult
50+ {
51+ ResourceTemplates =
52+ [
53+ new ResourceTemplate { Name = "Static Resource" , Description = "A static resource with a numeric ID" , UriTemplate = "test://static/resource/{id}" }
54+ ]
55+ } ) ;
56+ } )
57+ . WithReadResourceHandler ( ( ctx , ct ) =>
58+ {
59+ var uri = ctx . Params ? . Uri ;
60+
61+ if ( uri is null || ! uri . StartsWith ( "test://static/resource/" ) )
62+ {
63+ throw new NotSupportedException ( $ "Unknown resource: { uri } ") ;
64+ }
65+
66+ int index = int . Parse ( uri [ "test://static/resource/" . Length ..] ) - 1 ;
67+
68+ if ( index < 0 || index >= ResourceGenerator . Resources . Count )
69+ {
70+ throw new NotSupportedException ( $ "Unknown resource: { uri } ") ;
71+ }
72+
73+ var resource = ResourceGenerator . Resources [ index ] ;
74+
75+ return Task . FromResult ( new ReadResourceResult
76+ {
77+ Contents = [ new ResourceContents
78+ {
79+ Uri = resource . Uri ,
80+ MimeType = resource . MimeType ,
81+ Blob = resource . Description ,
82+ Name = resource . Description
83+ }
84+ ]
85+ } ) ;
86+ } )
87+ ;
4688
4789await builder . Build ( ) . RunAsync ( ) ;
0 commit comments