Skip to content

Commit 14e50ac

Browse files
committed
Add advanced topics documentation covering performance optimization, logging, security, and best practices
1 parent b596fa0 commit 14e50ac

File tree

2 files changed

+201
-160
lines changed

2 files changed

+201
-160
lines changed

README.md

Lines changed: 40 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -186,125 +186,9 @@ Use the install badges at the top of this page to automatically configure the MC
186186

187187
### Option 2: Manual Configuration
188188

189-
### Template & Framework Information
189+
Follow the instructions below for your specific development environment:
190190

191-
- **dotnet_template_list** - List all installed .NET templates with metadata
192-
- **dotnet_template_search** - Search for templates by name or description
193-
- **dotnet_template_info** - Get detailed template information and parameters
194-
- **dotnet_framework_info** - Get .NET framework version information and LTS status
195-
196-
### Project Management
197-
198-
- **dotnet_project_new** - Create new .NET projects from templates
199-
- **dotnet_project_restore** - Restore project dependencies
200-
- **dotnet_project_build** - Build .NET projects
201-
- **dotnet_project_run** - Build and run .NET projects
202-
- **dotnet_project_test** - Run unit tests
203-
- **dotnet_project_publish** - Publish projects for deployment
204-
- **dotnet_project_clean** - Clean build outputs
205-
- **dotnet_pack_create** - Create NuGet packages from projects
206-
- **dotnet_watch_run** - Run with file watching and hot reload
207-
- **dotnet_watch_test** - Run tests with auto-restart on file changes
208-
- **dotnet_watch_build** - Build with auto-rebuild on file changes
209-
210-
### Package Management
211-
212-
- **dotnet_package_add** - Add NuGet package references
213-
- **dotnet_package_remove** - Remove NuGet package references
214-
- **dotnet_package_search** - Search for NuGet packages on nuget.org
215-
- **dotnet_package_update** - Update NuGet packages to newer versions
216-
- **dotnet_package_list** - List package references (including outdated/deprecated)
217-
- **dotnet_reference_add** - Add project-to-project references
218-
- **dotnet_reference_remove** - Remove project-to-project references
219-
- **dotnet_reference_list** - List project references
220-
221-
### Solution Management
222-
223-
- **dotnet_solution_create** - Create new solution files (.sln or .slnx format)
224-
- **dotnet_solution_add** - Add projects to a solution
225-
- **dotnet_solution_list** - List projects in a solution
226-
- **dotnet_solution_remove** - Remove projects from a solution
227-
228-
### Code Quality
229-
230-
- **dotnet_format** - Format code according to .editorconfig and style rules
231-
232-
### Utilities
233-
234-
- **dotnet_nuget_locals** - Manage NuGet local caches (list, clear)
235-
236-
### SDK Information
237-
238-
- **dotnet_sdk_version** - Get .NET SDK version
239-
- **dotnet_sdk_info** - Get detailed SDK and runtime information
240-
- **dotnet_sdk_list** - List installed SDKs
241-
- **dotnet_runtime_list** - List installed runtimes
242-
243-
### Help
244-
245-
- **dotnet_help** - Get help for any dotnet command
246-
247-
## How It Works Under the Hood
248-
249-
```mermaid
250-
graph TD
251-
A[MCP Tool Request] --> B{Request Type}
252-
B -->|Metadata Query| C[Template Engine<br/>NuGet Packages]
253-
B -->|Operation| D[.NET CLI<br/>Execution]
254-
C --> E[Cached Response]
255-
D --> F[Command Output]
256-
E --> G[Structured Result]
257-
F --> G
258-
G --> H[AI Assistant]
259-
260-
style C fill:#e8f5e9
261-
style D fill:#e1f5ff
262-
style E fill:#fff9c4
263-
style F fill:#fff9c4
264-
```
265-
266-
The .NET MCP Server uses a **hybrid architecture** for optimal performance and reliability:
267-
268-
### SDK Integration (Fast, Cached)
269-
270-
Uses official Microsoft NuGet packages for metadata operations:
271-
272-
- **Template Engine** - Queries installed templates, parameters, and metadata
273-
- **MSBuild APIs** - Validates frameworks, reads project files
274-
- **Caching** - Template data cached for 5 minutes to improve performance
275-
276-
### CLI Execution (Reliable, Proven)
277-
278-
Executes actual `dotnet` commands for operations:
279-
280-
- **Project creation** - `dotnet new`
281-
- **Package management** - `dotnet add package`
282-
- **Build operations** - `dotnet build`, `dotnet test`, `dotnet run`
283-
- **Solution management** - `dotnet sln add`
284-
285-
This hybrid approach ensures both **speed** (for queries) and **reliability** (for operations).
286-
287-
📖 [Full SDK integration details](doc/sdk-integration.md)
288-
289-
## Building from Source
290-
291-
For development or contributing:
292-
293-
```bash
294-
git clone https://github.com/jongalloway/dotnet-mcp.git
295-
cd dotnet-mcp/DotNetMcp
296-
dotnet build
297-
```
298-
299-
**Run the server**:
300-
301-
```bash
302-
dotnet run
303-
```
304-
305-
The server communicates via stdio transport and is designed to be invoked by MCP clients.
306-
307-
#### Visual Studio Code
191+
### Visual Studio Code
308192

309193
**Using Quick Install** (recommended - .NET 10 required):
310194

@@ -336,7 +220,7 @@ Edit your VS Code settings (`Ctrl+,` or `Cmd+,`, search for "mcp"):
336220

337221
📖 [Full VS Code MCP documentation](https://code.visualstudio.com/docs/copilot/customization/mcp-servers#_add-an-mcp-server)
338222

339-
#### Visual Studio 2022
223+
### Visual Studio 2022
340224

341225
**Requirements**: Visual Studio 2022 version 17.13 or later
342226

@@ -364,7 +248,7 @@ Edit your VS Code settings (`Ctrl+,` or `Cmd+,`, search for "mcp"):
364248

365249
📖 [Full Visual Studio MCP documentation](https://learn.microsoft.com/en-us/visualstudio/ide/mcp-servers?view=vs-2022)
366250

367-
#### Claude Desktop
251+
### Claude Desktop
368252

369253
**Using DNX** (recommended - .NET 10 required):
370254

@@ -491,14 +375,14 @@ The server exposes read-only resources that provide efficient access to .NET env
491375

492376
Resources provide structured JSON data and are more efficient than tool calls for frequently accessed read-only information.
493377

494-
### Template & Framework Information
378+
### Tools - Templates & Frameworks
495379

496380
- **dotnet_template_list** - List all installed .NET templates with metadata
497381
- **dotnet_template_search** - Search for templates by name or description
498382
- **dotnet_template_info** - Get detailed template information and parameters
499383
- **dotnet_framework_info** - Get .NET framework version information and LTS status
500384

501-
### Project Management
385+
### Tools - Project Management
502386

503387
- **dotnet_project_new** - Create new .NET projects from templates
504388
- **dotnet_project_restore** - Restore project dependencies
@@ -512,7 +396,7 @@ Resources provide structured JSON data and are more efficient than tool calls fo
512396
- **dotnet_watch_test** - Run tests with auto-restart on file changes
513397
- **dotnet_watch_build** - Build with auto-rebuild on file changes
514398

515-
### Package Management
399+
### Tools - Package Management
516400

517401
- **dotnet_package_add** - Add NuGet package references
518402
- **dotnet_package_remove** - Remove NuGet package references
@@ -523,77 +407,72 @@ Resources provide structured JSON data and are more efficient than tool calls fo
523407
- **dotnet_reference_remove** - Remove project-to-project references
524408
- **dotnet_reference_list** - List project references
525409

526-
### Solution Management
410+
### Tools - Solution Management
527411

528412
- **dotnet_solution_create** - Create new solution files (.sln or .slnx format)
529413
- **dotnet_solution_add** - Add projects to a solution
530414
- **dotnet_solution_list** - List projects in a solution
531415
- **dotnet_solution_remove** - Remove projects from a solution
532416

533-
### Code Quality
417+
### Tools - Code Quality
534418

535419
- **dotnet_format** - Format code according to .editorconfig and style rules
536420

537-
### Utilities
421+
### Tools - Utilities
538422

539423
- **dotnet_nuget_locals** - Manage NuGet local caches (list, clear)
540424

541-
### SDK Information
425+
### Tools - SDK Information
542426

543427
- **dotnet_sdk_version** - Get .NET SDK version
544428
- **dotnet_sdk_info** - Get detailed SDK and runtime information
545429
- **dotnet_sdk_list** - List installed SDKs
546430
- **dotnet_runtime_list** - List installed runtimes
547431

548-
### Help
432+
### Tools - Help
549433

550434
- **dotnet_help** - Get help for any dotnet command
551435

552-
## Advanced Topics
553-
554-
### Performance Optimization
555-
556-
The server implements several performance optimizations:
557-
558-
- **Template caching** - Template Engine data cached for 5 minutes
559-
- **Output limiting** - Command output limited to 1 million characters to prevent memory issues
560-
- **Async operations** - All I/O operations use async/await patterns
561-
562-
### Logging
436+
## Building from Source
563437

564-
The server implements MCP-compliant logging:
438+
For development or contributing:
565439

566-
- Logs are sent to the MCP client via the logging protocol
567-
- Log levels: Debug, Information, Warning, Error
568-
- Configurable logging level set by the client
440+
```bash
441+
git clone https://github.com/jongalloway/dotnet-mcp.git
442+
cd dotnet-mcp/DotNetMcp
443+
dotnet build
444+
```
569445

570-
### Security
446+
**Run the server**:
571447

572-
The MCP server follows security best practices:
448+
```bash
449+
dotnet run
450+
```
573451

574-
- **Local execution only** - All operations run on your local machine
575-
- **No external communication** - No data sent to external servers
576-
- **Standard permissions** - Uses your .NET SDK permissions
577-
- **Input validation** - All parameters validated before execution
578-
- **Path sanitization** - File paths validated to prevent directory traversal
452+
The server communicates via stdio transport and is designed to be invoked by MCP clients.
579453

580454
## Project Structure
581455

582456
```text
583457
dotnet-mcp/
584-
├── DotNetMcp/
585-
│ ├── DotNetMcp.csproj # Project file
586-
│ ├── Program.cs # MCP server setup
587-
│ ├── DotNetCliTools.cs # MCP tool implementations
588-
│ ├── DotNetSdkConstants.cs # Strongly-typed SDK constants
589-
│ ├── TemplateEngineHelper.cs # Template Engine integration
590-
│ └── FrameworkHelper.cs # Framework validation helpers
458+
├── DotNetMcp/ # Main MCP server project
459+
│ ├── DotNetMcp.csproj # Project file with NuGet dependencies
460+
│ ├── Program.cs # MCP server setup and hosting
461+
│ ├── DotNetCliTools.cs # MCP tool implementations (40+ tools)
462+
│ ├── DotNetResources.cs # MCP resource implementations (SDK, runtime, templates, frameworks)
463+
│ ├── DotNetCommandExecutor.cs # Command execution helper with logging
464+
│ ├── DotNetSdkConstants.cs # Strongly-typed SDK constants (TFMs, configurations, runtimes)
465+
│ ├── TemplateEngineHelper.cs # Template Engine integration with caching
466+
│ └── FrameworkHelper.cs # Framework validation and metadata helpers
591467
├── doc/
592-
│ └── sdk-integration.md # SDK integration documentation
468+
│ └── sdk-integration.md # SDK integration architecture documentation
593469
├── .github/
594-
│ ├── copilot-instructions.md # Copilot development guidelines
470+
│ ├── copilot-instructions.md # Development guidelines for GitHub Copilot
471+
│ ├── dependabot.yml # Automated dependency updates
595472
│ └── workflows/
596-
│ └── build.yml # CI/CD workflow
473+
│ └── build.yml # CI/CD build and test workflow
474+
├── DotNetMcp.slnx # Solution file (XML-based .slnx format)
475+
├── LICENSE # MIT License
597476
└── README.md # This file
598477
```
599478

@@ -610,6 +489,7 @@ dotnet-mcp/
610489
## Documentation
611490

612491
- 📖 [SDK Integration Details](doc/sdk-integration.md) - Technical architecture and SDK usage
492+
- 📖 [Advanced Topics](doc/advanced-topics.md) - Performance, logging, and security details
613493
- 📖 [Model Context Protocol](https://modelcontextprotocol.io/) - Official MCP specification
614494
- 📖 [MCP C# SDK Docs](https://modelcontextprotocol.github.io/csharp-sdk/) - SDK documentation
615495

0 commit comments

Comments
 (0)