@@ -57,7 +57,29 @@ public static partial class McpServerBuilderExtensions
57
57
58
58
/// <summary>Adds <see cref="McpServerTool"/> instances to the service collection backing <paramref name="builder"/>.</summary>
59
59
/// <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>
61
83
/// <param name="serializerOptions">The serializer options governing tool parameter marshalling.</param>
62
84
/// <returns>The builder provided in <paramref name="builder"/>.</returns>
63
85
/// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
@@ -173,6 +195,28 @@ where t.GetCustomAttribute<McpServerToolTypeAttribute>() is not null
173
195
return builder ;
174
196
}
175
197
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
+
176
220
/// <summary>Adds <see cref="McpServerPrompt"/> instances to the service collection backing <paramref name="builder"/>.</summary>
177
221
/// <param name="builder">The builder instance.</param>
178
222
/// <param name="promptTypes">Types with marked methods to add as prompts to the server.</param>
0 commit comments