File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
samples/WeihanLi.Web.Extensions.Samples Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 16
16
<PackageVersion Condition =" '$(TargetFramework)'=='net9.0'" Include =" Microsoft.AspNetCore.Authentication.JwtBearer" Version =" $(AspNet9PackageVersion)" />
17
17
<PackageVersion Condition =" '$(TargetFramework)'=='net10.0'" Include =" Microsoft.AspNetCore.Authentication.JwtBearer" Version =" $(AspNet10PackageVersion)" />
18
18
<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 " />
20
20
<PackageVersion Include =" Scalar.AspNetCore" Version =" 2.1.17" />
21
21
<PackageVersion Include =" WeihanLi.Common" Version =" 1.0.77" />
22
22
</ItemGroup >
Original file line number Diff line number Diff line change 101
101
)
102
102
) ;
103
103
104
+ builder . Services . AddMcpServer ( )
105
+ . WithToolsFromAssembly ( )
106
+ . WithHttpTransport ( )
107
+ ;
108
+
104
109
var app = builder . Build ( ) ;
105
110
106
111
app . MapRuntimeInfo ( ) . ShortCircuit ( ) ;
185
190
// });
186
191
187
192
app . MapConfigInspector ( )
193
+ . AsMcpTool ( tool =>
194
+ {
195
+ tool . Description = "Get configurations" ;
196
+ } )
188
197
// .RequireAuthorization(x => x
189
198
// .AddAuthenticationSchemes("ApiKey")
190
199
// .RequireAuthenticatedUser()
191
200
// )
192
201
;
193
202
app . MapControllers ( ) ;
194
203
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
+
195
212
await app . RunAsync ( ) ;
196
213
197
214
You can’t perform that action at this time.
0 commit comments