From e35a0f3be7bc6fcb253791774fb1e34723e4fef2 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 20 Jul 2025 22:17:58 +0000
Subject: [PATCH 1/3] Initial plan
From 152f08b022f67a4ce62420aa5734f85212bad7b9 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 20 Jul 2025 22:42:39 +0000
Subject: [PATCH 2/3] Create MCP Server with Weather and Time tools
Co-authored-by: codebytes <47988+codebytes@users.noreply.github.com>
---
BuildWithAspire.slnx | 1 +
.../BuildWithAspire.AppHost.csproj | 1 +
src/BuildWithAspire.AppHost/Program.cs | 8 +-
.../BuildWithAspire.McpServer.csproj | 19 +++
src/BuildWithAspire.McpServer/McpServer.cs | 59 ++++++++++
src/BuildWithAspire.McpServer/Program.cs | 52 +++++++++
.../Tools/TimeTool.cs | 110 ++++++++++++++++++
.../Tools/WeatherTool.cs | 94 +++++++++++++++
8 files changed, 343 insertions(+), 1 deletion(-)
create mode 100644 src/BuildWithAspire.McpServer/BuildWithAspire.McpServer.csproj
create mode 100644 src/BuildWithAspire.McpServer/McpServer.cs
create mode 100644 src/BuildWithAspire.McpServer/Program.cs
create mode 100644 src/BuildWithAspire.McpServer/Tools/TimeTool.cs
create mode 100644 src/BuildWithAspire.McpServer/Tools/WeatherTool.cs
diff --git a/BuildWithAspire.slnx b/BuildWithAspire.slnx
index 7fd00f5..ef4ee82 100644
--- a/BuildWithAspire.slnx
+++ b/BuildWithAspire.slnx
@@ -5,6 +5,7 @@
+
diff --git a/src/BuildWithAspire.AppHost/BuildWithAspire.AppHost.csproj b/src/BuildWithAspire.AppHost/BuildWithAspire.AppHost.csproj
index 0ec973d..cfe27d4 100644
--- a/src/BuildWithAspire.AppHost/BuildWithAspire.AppHost.csproj
+++ b/src/BuildWithAspire.AppHost/BuildWithAspire.AppHost.csproj
@@ -24,6 +24,7 @@
+
diff --git a/src/BuildWithAspire.AppHost/Program.cs b/src/BuildWithAspire.AppHost/Program.cs
index db9d17b..0ef689e 100644
--- a/src/BuildWithAspire.AppHost/Program.cs
+++ b/src/BuildWithAspire.AppHost/Program.cs
@@ -38,10 +38,16 @@
.WithReference(chatDb)
.WaitFor(chatDb);
+// Add MCP Server service
+var mcpServer = builder.AddProject("mcpserver")
+ .WithExternalHttpEndpoints();
+
// Add Web service
var _ = builder.AddProject("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService)
- .WaitFor(apiService);
+ .WithReference(mcpServer)
+ .WaitFor(apiService)
+ .WaitFor(mcpServer);
builder.Build().Run();
diff --git a/src/BuildWithAspire.McpServer/BuildWithAspire.McpServer.csproj b/src/BuildWithAspire.McpServer/BuildWithAspire.McpServer.csproj
new file mode 100644
index 0000000..b65a777
--- /dev/null
+++ b/src/BuildWithAspire.McpServer/BuildWithAspire.McpServer.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/BuildWithAspire.McpServer/McpServer.cs b/src/BuildWithAspire.McpServer/McpServer.cs
new file mode 100644
index 0000000..0b10a95
--- /dev/null
+++ b/src/BuildWithAspire.McpServer/McpServer.cs
@@ -0,0 +1,59 @@
+using BuildWithAspire.McpServer.Tools;
+
+namespace BuildWithAspire.McpServer;
+
+///
+/// MCP tool call request structure.
+///
+public class McpToolCallRequest
+{
+ public string Name { get; set; } = string.Empty;
+ public Dictionary Arguments { get; set; } = new();
+}
+
+///
+/// MCP Server that manages tool calls.
+///
+public class McpServer
+{
+ private readonly Dictionary, CancellationToken, Task