Arch Dotnet
Clean Architecture MCP Server with .NET 8.0
Ask AI about Arch Dotnet
Powered by Claude Β· Grounded in docs
I know everything about Arch Dotnet. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
MCP Architecture - Agentic AI Service
A clean, SOLID, object-oriented architecture for implementing Model Context Protocol (MCP) with an Agentic AI service built on .NET 8.0.
Architecture Overview
This solution follows Clean Architecture principles with clear separation of concerns:
- Domain Layer: Core models, interfaces, and business logic
- Application Layer: Use cases and application services
- Infrastructure Layer: External service implementations (HTTP clients, data access)
- API Layer: ASP.NET Core Web API with REST endpoints
Project Structure
McpArchitecture/
βββ McpArchitecture.Domain/ # Core domain models and interfaces
βββ McpArchitecture.Application/ # Application services and use cases
βββ McpArchitecture.Infrastructure/ # Infrastructure implementations
βββ McpArchitecture.Api/ # ASP.NET Core Web API
βββ scripts/ # PowerShell setup scripts
βββ README.md
Prerequisites
- .NET 8.0 SDK or later
- Visual Studio 2022 (or later)
- PowerShell 5.1 or later
Setup Instructions
Option 1: Using PowerShell Scripts (Recommended)
-
Open PowerShell in the project root directory
-
Run the setup script:
.\scripts\Setup-Project.ps1 -
Add NuGet packages:
.\scripts\Add-Packages.ps1
Option 2: Manual Setup
-
Create the solution:
dotnet new sln -n McpArchitecture -
Create projects:
dotnet new classlib -n McpArchitecture.Domain dotnet new classlib -n McpArchitecture.Application dotnet new classlib -n McpArchitecture.Infrastructure dotnet new webapi -n McpArchitecture.Api -
Add projects to solution:
dotnet sln add McpArchitecture.Domain/McpArchitecture.Domain.csproj dotnet sln add McpArchitecture.Application/McpArchitecture.Application.csproj dotnet sln add McpArchitecture.Infrastructure/McpArchitecture.Infrastructure.csproj dotnet sln add McpArchitecture.Api/McpArchitecture.Api.csproj -
Add project references (see Setup-Project.ps1 for reference structure)
Running the Application
Option 1: Using the Start Script (Recommended)
Windows (PowerShell):
.\start.ps1
Linux/Mac (Bash):
chmod +x start.sh
./start.sh
With custom options:
# Run in Production environment
.\start.ps1 -Environment Production
# Run on custom port
.\start.ps1 -Port 5002
# Show help
.\start.ps1 -Help
Option 2: Using Visual Studio 2022
- Open the solution in Visual Studio 2022
- Set
McpArchitecture.Apias the startup project - Press F5 to run
Option 3: Using .NET CLI
cd McpArchitecture.Api
dotnet run
Access the API
Once started, navigate to:
- Swagger UI:
https://localhost:5001/swagger - API Base:
https://localhost:5001
API Endpoints
Standard MCP Endpoints
POST /api/mcp/request- Process an MCP requestPOST /api/mcp/message- Process an MCP messageGET /api/mcp/resources- Get all available resourcesGET /api/mcp/resources/{id}- Get a specific resourcePOST /api/mcp/resources- Register a new resource
FileServer MCP (JSON-RPC 2.0)
POST /api/mcp/json- Process JSON-RPC 2.0 MCP requestsfilesystem/list_files- List files and directoriesfilesystem/read_file- Read file contentsfilesystem/write_file- Write file contentsfilesystem/get_file_info- Get file/directory informationfilesystem/create_directory- Create a directoryfilesystem/delete_file- Delete a file or directory
Testing with MCP Inspector
Use the MCP Inspector to interactively test the API:
.\test-mcp\start-inspector.ps1
This will launch a web-based inspector tool. See test-mcp/README.md for details.
Design Principles
This project follows SOLID principles:
- Single Responsibility: Each class has one reason to change
- Open/Closed: Open for extension, closed for modification
- Liskov Substitution: Interfaces can be swapped without breaking functionality
- Interface Segregation: Small, focused interfaces
- Dependency Inversion: Depend on abstractions, not concretions
Features
- β Clean Architecture with layered separation
- β Dependency Injection throughout
- β Structured logging with Serilog
- β Swagger/OpenAPI documentation
- β RESTful API design
- β Resource management system
- β MCP protocol implementation
- β Visual Studio 2022 compatible
Configuration
Edit appsettings.json to configure:
- MCP base URL
- Timeout settings
- Logging levels
Testing
To add tests, create a test project:
dotnet new xunit -n McpArchitecture.Tests
dotnet add reference ../McpArchitecture.Domain/McpArchitecture.Domain.csproj
Contributing
This is a clean architecture template. Extend it based on your specific requirements while maintaining the SOLID principles and clean architecture boundaries.
License
This project is provided as-is for educational and commercial use.
