@@ -57,7 +57,29 @@ public static partial class McpServerBuilderExtensions
5757
5858 /// <summary>Adds <see cref="McpServerTool"/> instances to the service collection backing <paramref name="builder"/>.</summary>
5959 /// <param name="builder">The builder instance.</param>
60- /// <param name="toolTypes">Types with marked methods to add as tools to the server.</param>
60+ /// <param name="tools">The <see cref="McpServerTool"/> instances to add to the server.</param>
61+ /// <returns>The builder provided in <paramref name="builder"/>.</returns>
62+ /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
63+ /// <exception cref="ArgumentNullException"><paramref name="tools"/> is <see langword="null"/>.</exception>
64+ public static IMcpServerBuilder WithTools ( this IMcpServerBuilder builder , IEnumerable < McpServerTool > tools )
65+ {
66+ Throw . IfNull ( builder ) ;
67+ Throw . IfNull ( tools ) ;
68+
69+ foreach ( var tool in tools )
70+ {
71+ if ( tool is not null )
72+ {
73+ builder . Services . AddSingleton ( tool ) ;
74+ }
75+ }
76+
77+ return builder ;
78+ }
79+
80+ /// <summary>Adds <see cref="McpServerTool"/> instances to the service collection backing <paramref name="builder"/>.</summary>
81+ /// <param name="builder">The builder instance.</param>
82+ /// <param name="toolTypes">Types with <see cref="McpServerToolAttribute"/>-attributed methods to add as tools to the server.</param>
6183 /// <param name="serializerOptions">The serializer options governing tool parameter marshalling.</param>
6284 /// <returns>The builder provided in <paramref name="builder"/>.</returns>
6385 /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
@@ -173,6 +195,28 @@ where t.GetCustomAttribute<McpServerToolTypeAttribute>() is not null
173195 return builder ;
174196 }
175197
198+ /// <summary>Adds <see cref="McpServerPrompt"/> instances to the service collection backing <paramref name="builder"/>.</summary>
199+ /// <param name="builder">The builder instance.</param>
200+ /// <param name="prompts">The <see cref="McpServerPrompt"/> instances to add to the server.</param>
201+ /// <returns>The builder provided in <paramref name="builder"/>.</returns>
202+ /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
203+ /// <exception cref="ArgumentNullException"><paramref name="prompts"/> is <see langword="null"/>.</exception>
204+ public static IMcpServerBuilder WithPrompts ( this IMcpServerBuilder builder , IEnumerable < McpServerPrompt > prompts )
205+ {
206+ Throw . IfNull ( builder ) ;
207+ Throw . IfNull ( prompts ) ;
208+
209+ foreach ( var prompt in prompts )
210+ {
211+ if ( prompt is not null )
212+ {
213+ builder . Services . AddSingleton ( prompt ) ;
214+ }
215+ }
216+
217+ return builder ;
218+ }
219+
176220 /// <summary>Adds <see cref="McpServerPrompt"/> instances to the service collection backing <paramref name="builder"/>.</summary>
177221 /// <param name="builder">The builder instance.</param>
178222 /// <param name="promptTypes">Types with marked methods to add as prompts to the server.</param>
0 commit comments