@@ -58,22 +58,7 @@ public static partial class McpServerBuilderExtensions
5858 /// <summary>Adds <see cref="McpServerTool"/> instances to the service collection backing <paramref name="builder"/>.</summary>
5959 /// <param name="builder">The builder instance.</param>
6060 /// <param name="toolTypes">Types with marked methods to add as tools 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="toolTypes"/> is <see langword="null"/>.</exception>
64- /// <remarks>
65- /// This method discovers all instance and static methods (public and non-public) on the specified <paramref name="toolTypes"/>
66- /// types, where the methods are attributed as <see cref="McpServerToolAttribute"/>, and adds an <see cref="McpServerTool"/>
67- /// instance for each. For instance methods, an instance will be constructed for each invocation of the tool.
68- /// </remarks>
69- [ RequiresUnreferencedCode ( WithToolsRequiresUnreferencedCodeMessage ) ]
70- public static IMcpServerBuilder WithTools ( this IMcpServerBuilder builder , params IEnumerable < Type > toolTypes ) =>
71- WithTools ( builder , serializerOptions : null , toolTypes ) ;
72-
73- /// <summary>Adds <see cref="McpServerTool"/> instances to the service collection backing <paramref name="builder"/>.</summary>
74- /// <param name="builder">The builder instance.</param>
7561 /// <param name="serializerOptions">The serializer options governing tool parameter marshalling.</param>
76- /// <param name="toolTypes">Types with marked methods to add as tools to the server.</param>
7762 /// <returns>The builder provided in <paramref name="builder"/>.</returns>
7863 /// <exception cref="ArgumentNullException"><paramref name="builder"/> is <see langword="null"/>.</exception>
7964 /// <exception cref="ArgumentNullException"><paramref name="toolTypes"/> is <see langword="null"/>.</exception>
@@ -83,7 +68,7 @@ public static IMcpServerBuilder WithTools(this IMcpServerBuilder builder, params
8368 /// instance for each. For instance methods, an instance will be constructed for each invocation of the tool.
8469 /// </remarks>
8570 [ RequiresUnreferencedCode ( WithToolsRequiresUnreferencedCodeMessage ) ]
86- public static IMcpServerBuilder WithTools ( this IMcpServerBuilder builder , JsonSerializerOptions ? serializerOptions , params IEnumerable < Type > toolTypes )
71+ public static IMcpServerBuilder WithTools ( this IMcpServerBuilder builder , IEnumerable < Type > toolTypes , JsonSerializerOptions ? serializerOptions = null )
8772 {
8873 Throw . IfNull ( builder ) ;
8974 Throw . IfNull ( toolTypes ) ;
@@ -142,10 +127,11 @@ public static IMcpServerBuilder WithToolsFromAssembly(this IMcpServerBuilder bui
142127
143128 toolAssembly ??= Assembly . GetCallingAssembly ( ) ;
144129
145- return builder . WithTools ( serializerOptions : serializerOptions ,
130+ return builder . WithTools (
146131 from t in toolAssembly . GetTypes ( )
147132 where t . GetCustomAttribute < McpServerToolTypeAttribute > ( ) is not null
148- select t ) ;
133+ select t ,
134+ serializerOptions ) ;
149135 }
150136 #endregion
151137
0 commit comments