Skip to content

Commit a2ffda9

Browse files
committed
Added WithTools back in to easily init capabilities
1 parent 33fbfab commit a2ffda9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

samples/AspNetCoreMcpPerSessionTools/Program.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
{
1919
// Configure per-session options to filter tools based on route category
2020
options.ConfigureSessionOptions = async (httpContext, mcpOptions, cancellationToken) =>
21-
{
21+
{
2222
// Determine tool category from route parameters
2323
var toolCategory = GetToolCategoryFromRoute(httpContext);
2424

@@ -29,6 +29,9 @@
2929
return;
3030
}
3131

32+
// Clear tools (we add them to make sure the capability is initialized)
33+
toolCollection.Clear();
34+
3235
// Get pre-populated tools for the requested category
3336
if (toolDictionary.TryGetValue(toolCategory.ToLower(), out var tools))
3437
{
@@ -38,7 +41,10 @@
3841
}
3942
}
4043
};
41-
});
44+
})
45+
.WithTools<ClockTool>()
46+
.WithTools<CalculatorTool>()
47+
.WithTools<UserInfoTool>();
4248

4349
// Add OpenTelemetry for observability
4450
builder.Services.AddOpenTelemetry()

0 commit comments

Comments
 (0)