Skip to content

Commit 66e48e8

Browse files
committed
Initialize .NET project structure and configuration files
1 parent f8209a6 commit 66e48e8

11 files changed

Lines changed: 149 additions & 1 deletion

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// }
2121

2222
// Use 'postCreateCommand' to run commands after the container is created.
23-
// "postCreateCommand": "dotnet restore",
23+
//"postCreateCommand": "",
2424

2525
// Configure tool-specific properties.
2626
"customizations": {

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dotnet.defaultSolution": "AbeckDev.DbTimetable.sln"
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.5" />
11+
<PackageReference Include="ModelContextProtocol" Version="0.4.0-preview.3" />
12+
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.4.0-preview.3" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@AbeckDev.DbTimetable.Mcp_HostAddress = http://localhost:5252
2+
3+
GET {{AbeckDev.DbTimetable.Mcp_HostAddress}}/weatherforecast/
4+
Accept: application/json
5+
6+
###
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//Minimal API approach
2+
using ModelContextProtocol.Protocol;
3+
4+
var builder = WebApplication.CreateBuilder(args);
5+
6+
// Add services to the container.
7+
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
8+
builder.Services.AddMcpServer(options =>
9+
{
10+
options.ServerInfo = new Implementation { Name = "Deutsche Bahn - Timetable API", Version = "" };
11+
})
12+
.WithHttpTransport()
13+
.WithToolsFromAssembly()
14+
.WithPromptsFromAssembly();
15+
16+
17+
var app = builder.Build();
18+
app.MapMcp("/mcp");
19+
20+
app.Run("http://localhost:3001");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.ComponentModel;
3+
using Microsoft.Extensions.AI;
4+
using ModelContextProtocol.Server;
5+
6+
namespace AbeckDev.DbTimetable.Mcp;
7+
8+
[McpServerPromptType]
9+
public static class Prompts
10+
{
11+
[McpServerPrompt, Description("Creates a prompt to summarize the provided message.")]
12+
public static ChatMessage Summarize([Description("The content to summarize")] string content) =>
13+
new(ChatRole.User, $"Please summarize this content into a single sentence: {content}");
14+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"profiles": {
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
7+
"launchBrowser": false,
8+
"applicationUrl": "http://localhost:5252",
9+
"environmentVariables": {
10+
"ASPNETCORE_ENVIRONMENT": "Development"
11+
}
12+
},
13+
"https": {
14+
"commandName": "Project",
15+
"dotnetRunMessages": true,
16+
"launchBrowser": false,
17+
"applicationUrl": "https://localhost:7041;http://localhost:5252",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
}
22+
}
23+
}

AbeckDev.DbTimetable.Mcp/Tools.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.ComponentModel;
3+
using ModelContextProtocol.Server;
4+
5+
6+
namespace AbeckDev.DbTimetable.Mcp;
7+
8+
[McpServerToolType]
9+
public static class Tools
10+
{
11+
[McpServerTool, Description("Echoes the message back.")]
12+
public static string Echo(string message)
13+
{
14+
return $"Echo: {message}";
15+
}
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
},
8+
"AllowedHosts": "*"
9+
}

0 commit comments

Comments
 (0)