Skip to content

Commit c8c2ace

Browse files
committed
update sample
1 parent cc4cace commit c8c2ace

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageVersion Condition="'$(TargetFramework)'=='net9.0'" Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNet9PackageVersion)" />
1717
<PackageVersion Condition="'$(TargetFramework)'=='net10.0'" Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNet10PackageVersion)" />
1818
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="$(AspNet10PackageVersion)" />
19-
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.1.0-preview.10" />
19+
<PackageVersion Include="ModelContextProtocol.AspNetCore" Version="0.1.0-preview.11" />
2020
<PackageVersion Include="Scalar.AspNetCore" Version="2.1.17" />
2121
<PackageVersion Include="WeihanLi.Common" Version="1.0.77" />
2222
</ItemGroup>

samples/WeihanLi.Web.Extensions.Samples/Program.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
)
102102
);
103103

104+
builder.Services.AddMcpServer()
105+
.WithToolsFromAssembly()
106+
.WithHttpTransport()
107+
;
108+
104109
var app = builder.Build();
105110

106111
app.MapRuntimeInfo().ShortCircuit();
@@ -185,13 +190,25 @@
185190
// });
186191

187192
app.MapConfigInspector()
193+
.AsMcpTool(tool =>
194+
{
195+
tool.Description = "Get configurations";
196+
})
188197
// .RequireAuthorization(x => x
189198
// .AddAuthenticationSchemes("ApiKey")
190199
// .RequireAuthenticatedUser()
191200
// )
192201
;
193202
app.MapControllers();
194203

204+
app.MapGet("/mcp-tools", (EndpointDataSource endpointDataSource) =>
205+
{
206+
var tools = endpointDataSource.Endpoints.Where(x => x.Metadata.Any(m => m is McpToolEndpointMetadata))
207+
.Select(x=>x.Metadata.OfType<McpToolEndpointMetadata>().First())
208+
.ToArray();
209+
return tools;
210+
});
211+
195212
await app.RunAsync();
196213

197214

0 commit comments

Comments
 (0)