Skip to content

Commit b5cb4a6

Browse files
committed
working on MCP server
1 parent c86514c commit b5cb4a6

File tree

90 files changed

+2034
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2034
-2
lines changed

.github/workflows/build-deploy-beta.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
Solution_Name: ./src/MauiReactor.Build.sln
1717
Test_Project: ./samples/UnitTests/UnitTests.csproj
1818
TemplatePack_Name: ./src/MauiReactor.TemplatePack/MauiReactor.TemplatePack.csproj
19-
Version: 4.0.3-beta
19+
Version: 4.0.4-beta
2020

2121
steps:
2222
- name: Checkout

src/MauiReactor.Build.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 18
4-
VisualStudioVersion = 18.3.11206.111 d18.3
4+
VisualStudioVersion = 18.3.11206.111
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiReactor", "MauiReactor\MauiReactor.csproj", "{96ED0DF8-9B7B-42A3-A410-BFCD921EDC54}"
77
EndProject
@@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiReactor.ScaffoldGenerat
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiReactor.Maps", "MauiReactor.Maps\MauiReactor.Maps.csproj", "{E3B3F8A0-947A-4945-B7E8-67B31B5D9EC2}"
1919
EndProject
20+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiReactor.MCP", "MauiReactor.MCP\MauiReactor.MCP.csproj", "{E96EE067-E033-C938-9419-B0997419CA93}"
21+
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2224
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
5153
{E3B3F8A0-947A-4945-B7E8-67B31B5D9EC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
5254
{E3B3F8A0-947A-4945-B7E8-67B31B5D9EC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
5355
{E3B3F8A0-947A-4945-B7E8-67B31B5D9EC2}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{E96EE067-E033-C938-9419-B0997419CA93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57+
{E96EE067-E033-C938-9419-B0997419CA93}.Debug|Any CPU.Build.0 = Debug|Any CPU
58+
{E96EE067-E033-C938-9419-B0997419CA93}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{E96EE067-E033-C938-9419-B0997419CA93}.Release|Any CPU.Build.0 = Release|Any CPU
5460
EndGlobalSection
5561
GlobalSection(SolutionProperties) = preSolution
5662
HideSolutionNode = FALSE
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-10-17/server.schema.json",
3+
"description": "MauiReactor is a MVU UI framework built on top of .NET MAUI",
4+
"name": "io.github.adospace/reactorui-maui",
5+
"version": "0.1.0-beta",
6+
"packages": [
7+
{
8+
"registryType": "nuget",
9+
"identifier": "Reactor.Maui.MCP",
10+
"version": "0.1.0-beta",
11+
"transport": {
12+
"type": "stdio"
13+
},
14+
"packageArguments": [],
15+
"environmentVariables": []
16+
}
17+
],
18+
"repository": {
19+
"url": "https://github.com/adospace/reactorui-maui",
20+
"source": "github"
21+
}
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"servers": {
3+
"MauiReactor.MCP": {
4+
"type": "stdio",
5+
"command": "dotnet",
6+
"args": [
7+
"run",
8+
"--project",
9+
"MauiReactor.MCP.csproj"
10+
]
11+
}
12+
}
13+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net10.0</TargetFramework>
5+
<RuntimeIdentifiers>win-x64;win-arm64;osx-arm64;linux-x64;linux-arm64;linux-musl-x64</RuntimeIdentifiers>
6+
<OutputType>Exe</OutputType>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
11+
12+
<!-- Set up the NuGet package to be an MCP server -->
13+
<PackAsTool>true</PackAsTool>
14+
<PackageType>McpServer</PackageType>
15+
16+
<!-- Set up the MCP server to be a self-contained application that does not rely on a shared framework -->
17+
<SelfContained>true</SelfContained>
18+
<PublishSelfContained>true</PublishSelfContained>
19+
20+
<!-- Set up the MCP server to be a single file executable -->
21+
<PublishSingleFile>true</PublishSingleFile>
22+
23+
<!-- Set recommended package metadata -->
24+
<PackageVersion>0.1.0-beta</PackageVersion>
25+
<PackageReadmeFile>README.md</PackageReadmeFile>
26+
<PackageId>MauiReactor.MCP</PackageId>
27+
<PackageTags>MauiReactor; MCP; server; stdio</PackageTags>
28+
<Description>MCP (Model Context Protocol) server for MauiReactor. Provides stdio endpoints exposing tools for .NET MAUI projects: component scaffolding, workspace inspection and file operations, plus basic build/test tasks. Designed for use with MCP-compatible clients.</Description>
29+
</PropertyGroup>
30+
31+
<!-- Include additional files for browsing the MCP server. -->
32+
<ItemGroup>
33+
<None Include=".mcp\server.json" Pack="true" PackagePath="/.mcp/" />
34+
<None Include="README.md" Pack="true" PackagePath="/" />
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
39+
<PackageReference Include="ModelContextProtocol" Version="0.5.0-preview.1" />
40+
</ItemGroup>
41+
42+
<ItemGroup>
43+
<Folder Include="Tools\Resources\Components\" />
44+
</ItemGroup>
45+
46+
<ItemGroup>
47+
<EmbeddedResource Include="Tools\Resources\Components\**\*.json" />
48+
</ItemGroup>
49+
50+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MauiReactor.MCP", "MauiReactor.MCP.csproj", "{D0B72383-61A6-5DEA-54D0-536827EC142C}"
6+
EndProject
7+
Global
8+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9+
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
11+
EndGlobalSection
12+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13+
{D0B72383-61A6-5DEA-54D0-536827EC142C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14+
{D0B72383-61A6-5DEA-54D0-536827EC142C}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{D0B72383-61A6-5DEA-54D0-536827EC142C}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{D0B72383-61A6-5DEA-54D0-536827EC142C}.Release|Any CPU.Build.0 = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(SolutionProperties) = preSolution
19+
HideSolutionNode = FALSE
20+
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {EA312B57-9D9B-4C79-9422-D8AA2975E765}
23+
EndGlobalSection
24+
EndGlobal

src/MauiReactor.MCP/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Microsoft.Extensions.Hosting;
3+
using Microsoft.Extensions.Logging;
4+
5+
var builder = Host.CreateApplicationBuilder(args);
6+
7+
// Configure all logs to go to stderr (stdout is used for the MCP protocol messages).
8+
builder.Logging.AddConsole(o => o.LogToStandardErrorThreshold = LogLevel.Trace);
9+
10+
// Add the MCP services: the transport to use (stdio) and the tools to register.
11+
builder.Services
12+
.AddMcpServer()
13+
.WithStdioServerTransport()
14+
.WithTools<global::ProjectTools>()
15+
.WithTools<global::ComponentTools>();
16+
17+
// Register the shell service for running external processes
18+
builder.Services.AddSingleton<MauiReactor.MCP.Services.IShell, MauiReactor.MCP.Services.ShellService>();
19+
20+
await builder.Build().RunAsync();

src/MauiReactor.MCP/README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# MauiReactor MCP Server
2+
3+
This package exposes a Model Context Protocol (MCP) server for working with MauiReactor and .NET MAUI projects. It provides tools for component scaffolding, workspace inspection, and basic build/test actions via stdio.
4+
5+
## Install (NuGet, `dnx`)
6+
7+
Once the package is published to NuGet, configure your IDE to install and run the server via `dnx`:
8+
9+
VS Code: create `.vscode/mcp.json` in your workspace
10+
11+
```json
12+
{
13+
"servers": {
14+
"MauiReactor.MCP": {
15+
"type": "stdio",
16+
"command": "dnx",
17+
"args": [
18+
"MauiReactor.MCP",
19+
"--version",
20+
"0.1.0-preview",
21+
"--yes"
22+
]
23+
}
24+
}
25+
}
26+
```
27+
28+
Visual Studio: create `.mcp.json` in the solution directory with the same content as above.
29+
30+
Notes:
31+
- Replace the version with the latest published package version.
32+
- `dnx` downloads and caches the self-contained binary per RID.
33+
34+
## Run from source (development)
35+
36+
To test locally without packaging:
37+
38+
```json
39+
{
40+
"servers": {
41+
"MauiReactor.MCP": {
42+
"type": "stdio",
43+
"command": "dotnet",
44+
"args": [
45+
"run",
46+
"--project",
47+
"<absolute path to src/MauiReactor.MCP>"
48+
]
49+
}
50+
}
51+
}
52+
```
53+
54+
## Server capabilities
55+
56+
- Tools: scaffolding MAUI components, reading/writing workspace files, basic build/test tasks.
57+
- Resources: embedded templates under `Tools/Resources/Components`.
58+
- Prompts: MCP-compliant prompt definitions for guided workflows.
59+
60+
## Client configuration (`.mcp/server.json`)
61+
62+
This package includes `.mcp/server.json` for IDE browsing. You can declare required inputs (e.g., workspace paths or feature flags) following MCP guidance. See [aka.ms/nuget/mcp/guide/configuring-inputs](https://aka.ms/nuget/mcp/guide/configuring-inputs).
63+
64+
## Pack and publish
65+
66+
```bash
67+
dotnet pack -c Release
68+
dotnet nuget push bin/Release/*.nupkg --source https://api.nuget.org/v3/index.json
69+
```
70+
71+
Ensure `PackageId`, `RepositoryUrl`, and metadata are set in `MauiReactor.MCP.csproj`.
72+
73+
## Troubleshooting
74+
75+
- `dnx` not found: update to the latest Copilot/IDE preview that supports MCP.
76+
- Startup errors: run with `dotnet run` to view detailed logs.
77+
- RID mismatch: confirm your platform is listed in `<RuntimeIdentifiers>`.
78+
79+
## References
80+
81+
- Model Context Protocol: https://modelcontextprotocol.io/
82+
- Specification: https://spec.modelcontextprotocol.io/
83+
- .NET MCP SDK (NuGet): https://www.nuget.org/packages/ModelContextProtocol
84+
- VS Code MCP servers: https://code.visualstudio.com/docs/copilot/chat/mcp-servers
85+
- Visual Studio MCP servers: https://learn.microsoft.com/visualstudio/ide/mcp-servers
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System.Diagnostics;
2+
using System.IO;
3+
4+
namespace MauiReactor.MCP.Services
5+
{
6+
public interface IShell
7+
{
8+
(int exitCode, string stdout, string stderr) Run(string fileName, string arguments, string workingDirectory);
9+
}
10+
11+
public class ShellService : IShell
12+
{
13+
public (int exitCode, string stdout, string stderr) Run(string fileName, string arguments, string workingDirectory)
14+
{
15+
var psi = new ProcessStartInfo
16+
{
17+
FileName = fileName,
18+
Arguments = arguments,
19+
WorkingDirectory = workingDirectory,
20+
RedirectStandardOutput = true,
21+
RedirectStandardError = true,
22+
UseShellExecute = false,
23+
CreateNoWindow = true,
24+
};
25+
26+
using var proc = new Process { StartInfo = psi };
27+
var stdoutBuilder = new StringWriter();
28+
var stderrBuilder = new StringWriter();
29+
30+
proc.OutputDataReceived += (s, e) => { if (e.Data != null) stdoutBuilder.WriteLine(e.Data); };
31+
proc.ErrorDataReceived += (s, e) => { if (e.Data != null) stderrBuilder.WriteLine(e.Data); };
32+
33+
proc.Start();
34+
proc.BeginOutputReadLine();
35+
proc.BeginErrorReadLine();
36+
proc.WaitForExit();
37+
38+
return (proc.ExitCode, stdoutBuilder.ToString(), stderrBuilder.ToString());
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)