Fixing WithPromptsFromAssembly (#174)

* Fixing WithPromptsFromAssembly

Was looking for tools

* Fixing test
This commit is contained in:
Aaron Powell 2025-04-01 11:59:31 +11:00 • committed by GitHub
commit b9bb871787
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -176,7 +176,7 @@ public static partial class McpServerBuilderExtensions
} }
/// <summary> /// <summary>
/// Adds types marked with the <see cref="McpServerToolTypeAttribute"/> attribute from the given assembly as prompts to the server. /// Adds types marked with the <see cref="McpServerPromptTypeAttribute"/> attribute from the given assembly as prompts to the server.
/// </summary> /// </summary>
/// <param name="builder">The builder instance.</param> /// <param name="builder">The builder instance.</param>
/// <param name="promptAssembly">The assembly to load the types from. Null to get the current assembly</param> /// <param name="promptAssembly">The assembly to load the types from. Null to get the current assembly</param>
@ -190,7 +190,7 @@ public static partial class McpServerBuilderExtensions
return builder.WithPrompts( return builder.WithPrompts(
from t in promptAssembly.GetTypes() from t in promptAssembly.GetTypes()
where t.GetCustomAttribute<McpServerToolTypeAttribute>() is not null where t.GetCustomAttribute<McpServerPromptTypeAttribute>() is not null
select t); select t);
} }
#endregion #endregion

View file

@ -218,7 +218,7 @@ public class McpServerBuilderExtensionsPromptsTests : LoggedTest, IAsyncDisposab
Assert.Contains(services.GetServices<McpServerPrompt>(), t => t.ProtocolPrompt.Name == nameof(MorePrompts.AnotherPrompt)); Assert.Contains(services.GetServices<McpServerPrompt>(), t => t.ProtocolPrompt.Name == nameof(MorePrompts.AnotherPrompt));
} }
[McpServerToolType] [McpServerPromptType]
public sealed class SimplePrompts(ObjectWithId? id = null) public sealed class SimplePrompts(ObjectWithId? id = null)
{ {
[McpServerPrompt, Description("Returns chat messages")] [McpServerPrompt, Description("Returns chat messages")]