|
| 1 | +# GitHub Copilot Instructions for MCP .NET Samples |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +This repository contains Model Context Protocol (MCP) .NET sample implementations showcasing how to build MCP servers using .NET 9.0. The project includes three main samples: Awesome Copilot (GitHub integration), Markdown to HTML converter, and Todo List management. |
| 6 | + |
| 7 | +## Coding Standards and Practices |
| 8 | + |
| 9 | +### .NET Development Standards |
| 10 | +- **Target Framework**: Use .NET 9.0 as specified in Directory.Build.props |
| 11 | +- **Language Version**: Use latest C# language features |
| 12 | +- **Nullability**: Enable nullable reference types (`<Nullable>enable</Nullable>`) |
| 13 | +- **Implicit Usings**: Leverage implicit global usings (`<ImplicitUsings>enable</ImplicitUsings>`) |
| 14 | +- **Async/Await**: Prefer async/await patterns for I/O operations, especially for MCP server implementations |
| 15 | + |
| 16 | +### Project Structure Conventions |
| 17 | +- Each sample should be self-contained with its own solution file (`.sln`) |
| 18 | +- Use the naming pattern: `McpSamples.{SampleName}.{ComponentType}` |
| 19 | +- Organize projects with `src/` directories containing the main implementation |
| 20 | +- Include `infra/` directories for Azure deployment (Bicep files) |
| 21 | +- Provide Docker support with appropriate Dockerfiles |
| 22 | + |
| 23 | +### MCP Server Implementation Guidelines |
| 24 | +- Implement MCP servers using the shared `McpSamples.Shared` library |
| 25 | +- Use proper dependency injection patterns |
| 26 | +- Follow the MCP protocol specifications for tools, prompts, and resources |
| 27 | +- Implement proper error handling and logging |
| 28 | +- Use descriptive attributes for MCP server components: |
| 29 | + - `[McpServerPromptType]` for prompt classes |
| 30 | + - `[McpServerPrompt]` for prompt methods |
| 31 | + - `[Description]` attributes for parameters and methods |
| 32 | + |
| 33 | +### Code Style Guidelines |
| 34 | +- Follow Microsoft C# coding conventions |
| 35 | +- Use meaningful variable and method names |
| 36 | +- Implement comprehensive XML documentation comments |
| 37 | +- Use readonly fields where appropriate |
| 38 | +- Prefer record types for immutable data models |
| 39 | +- Use required properties for essential data |
| 40 | + |
| 41 | +### Azure Integration Standards |
| 42 | +- Use Bicep for Infrastructure as Code |
| 43 | +- Follow Azure naming conventions with abbreviations |
| 44 | +- Implement proper Azure identity and security practices |
| 45 | +- Use Azure Container Apps for deployment |
| 46 | +- Configure Application Insights for monitoring |
| 47 | + |
| 48 | +### Testing Requirements |
| 49 | +- Write unit tests for all business logic |
| 50 | +- Use descriptive test method names following Given_When_Then pattern |
| 51 | +- Mock external dependencies appropriately |
| 52 | +- Test MCP server functionality including tools and prompts |
| 53 | +- Ensure tests cover error scenarios |
| 54 | + |
| 55 | +## Code Review Guidelines |
| 56 | + |
| 57 | +### Security Checklist |
| 58 | +- [ ] Verify no hardcoded secrets or connection strings |
| 59 | +- [ ] Ensure proper input validation and sanitization |
| 60 | +- [ ] Check for proper authentication and authorization |
| 61 | +- [ ] Validate Azure resource security configurations |
| 62 | +- [ ] Review Docker image security practices |
| 63 | + |
| 64 | +### Performance Considerations |
| 65 | +- [ ] Check for efficient async/await usage |
| 66 | +- [ ] Verify proper disposal of resources (using statements) |
| 67 | +- [ ] Review memory allocation patterns |
| 68 | +- [ ] Ensure proper caching where appropriate |
| 69 | +- [ ] Validate container resource requirements |
| 70 | + |
| 71 | +### MCP Protocol Compliance |
| 72 | +- [ ] Verify correct MCP server registration and initialization |
| 73 | +- [ ] Check tool and prompt implementations follow MCP specifications |
| 74 | +- [ ] Ensure proper error handling and response formatting |
| 75 | +- [ ] Validate resource management and cleanup |
| 76 | + |
| 77 | +## Pull Request Guidelines |
| 78 | + |
| 79 | +### Commit Message Format |
| 80 | +Use conventional commit format: |
| 81 | +- `feat: add new MCP tool for file operations` |
| 82 | +- `fix: resolve connection timeout in MCP server` |
| 83 | +- `docs: update README with deployment instructions` |
| 84 | +- `refactor: optimize MCP message handling` |
| 85 | + |
| 86 | +### PR Description Template |
| 87 | +Include the following in your PR description: |
| 88 | +1. **Summary**: Brief description of changes |
| 89 | +2. **Changes**: List of specific modifications |
| 90 | +3. **Testing**: How the changes were tested |
| 91 | +4. **Azure**: Any infrastructure changes |
| 92 | +5. **Breaking Changes**: List any breaking changes |
| 93 | +6. **Screenshots**: For UI changes (if applicable) |
| 94 | + |
| 95 | +### Required Checks |
| 96 | +- [ ] Code builds successfully for .NET 9.0 |
| 97 | +- [ ] All existing tests pass |
| 98 | +- [ ] New features include appropriate tests |
| 99 | +- [ ] Documentation is updated |
| 100 | +- [ ] Azure deployment scripts are validated |
| 101 | +- [ ] Docker images build successfully |
| 102 | +- [ ] MCP server functionality is verified |
| 103 | + |
| 104 | +## Preferred Technologies and Libraries |
| 105 | + |
| 106 | +### Core Technologies |
| 107 | +- **.NET 9.0** - Primary target framework |
| 108 | +- **C# Latest** - Use latest language features |
| 109 | +- **ASP.NET Core** - For HTTP-based MCP servers |
| 110 | +- **System.Text.Json** - Preferred JSON serialization |
| 111 | +- **Microsoft.Extensions.*** - Use built-in dependency injection and configuration |
| 112 | + |
| 113 | +### Azure Services |
| 114 | +- **Azure Container Apps** - Primary deployment target |
| 115 | +- **Azure Container Registry** - For container images |
| 116 | +- **Application Insights** - For monitoring and telemetry |
| 117 | +- **Azure Identity** - For authentication |
| 118 | + |
| 119 | +### Development Tools |
| 120 | +- **Visual Studio Code** - Recommended IDE |
| 121 | +- **Docker Desktop** - For local container development |
| 122 | +- **Azure CLI** - For Azure operations |
| 123 | +- **Azure Developer CLI (azd)** - For deployment automation |
| 124 | + |
| 125 | +## Sample-Specific Guidelines |
| 126 | + |
| 127 | +### Awesome Copilot Sample |
| 128 | +- Focus on GitHub integration and file system operations |
| 129 | +- Implement proper metadata handling for Copilot instructions |
| 130 | +- Use structured search and filtering capabilities |
| 131 | + |
| 132 | +### Markdown to HTML Sample |
| 133 | +- Ensure proper HTML sanitization and security |
| 134 | +- Support various markdown extensions |
| 135 | +- Implement configurable HTML output options |
| 136 | + |
| 137 | +### Todo List Sample |
| 138 | +- Use proper data persistence patterns |
| 139 | +- Implement CRUD operations efficiently |
| 140 | +- Follow RESTful API principles for HTTP endpoints |
| 141 | + |
| 142 | +## Additional Notes |
| 143 | + |
| 144 | +- Always test MCP server functionality with VS Code MCP integration |
| 145 | +- Ensure compatibility with both local and containerized deployments |
| 146 | +- Follow Microsoft Open Source guidelines and code of conduct |
| 147 | +- Update documentation when adding new features or changing existing behavior |
| 148 | +- Consider backward compatibility when making changes to MCP interfaces |
0 commit comments