中文 README | English README
A Model Context Protocol (MCP) server that provides AI assistants (like GitHub Copilot, Claude) with access to BootstrapBlazor component documentation and source code.
BootstrapBlazor.Copilot.MCPServer is an MCP server specifically designed for the BootstrapBlazor framework that can:
- 📚 Provide complete documentation for BootstrapBlazor components
- 🔍 Allow AI assistants to search and browse component source code
- 📖 Offer component usage examples and best practices
- 🔄 Automatically sync the latest BootstrapBlazor source code
- 🛠️ Support integration with AI assistants via HTTP transport
The project is built with .NET 9.0 and ASP.NET Core, including the following main components:
BootstrapBlazor.Copilot.MCPServer/
├── BootstrapBlazor.Copilot.MCPServer/ # Main service project
│ ├── Services/ # Core services
│ │ ├── GitRepositoryManager.cs # Git repository management
│ │ └── ComponentDocumentationService.cs # Component documentation service
│ ├── Tools/ # MCP tool definitions
│ │ └── ComponentsTool.cs # Component query tools
│ ├── Models/ # Data models
│ │ └── Component.cs # Component-related models
│ └── Program.cs # Application entry point
├── BootstrapBlazor.Copilot.MCPServer.AppHost/ # Aspire application host
└── BootstrapBlazor.Copilot.MCPServer.ServiceDefaults/ # Shared service configuration
-
Git Repository Management (
GitRepositoryManager
)- Automatically clone and update BootstrapBlazor official repository
- Check if local repository is up to date
- Background service for periodic code synchronization
-
Component Documentation Service (
ComponentDocumentationService
)- Scan and index all BootstrapBlazor components
- Provide access to component source code and example files
- Intelligent path resolution supporting multiple file organization structures
-
MCP Tools (
ComponentsTool
)ListComponents
: List all available componentsGetComponentFiles
: Get component file listGetFileContent
: Get specific file contentEcho
: Test tool
- .NET 9.0: Latest .NET framework
- ASP.NET Core: Web application framework
- Model Context Protocol: AI assistant integration protocol
- LibGit2Sharp: Git operations library
- .NET Aspire: Cloud-native application development platform
- OpenTelemetry: Observability and monitoring
- .NET 9.0 SDK
- Git
- Visual Studio 2022 or VS Code
-
Clone the project
git clone https://github.com/your-repo/BootstrapBlazor.Copilot.MCPServer.git cd BootstrapBlazor.Copilot.MCPServer
-
Restore dependencies
dotnet restore
-
Run the service
# Using Aspire (recommended) dotnet run --project BootstrapBlazor.Copilot.MCPServer.AppHost # Or run the main project directly dotnet run --project BootstrapBlazor.Copilot.MCPServer
-
Verify the service The service runs on
http://localhost:3001
by default and supports the following endpoints:/health
- Health check/alive
- Liveness check- MCP protocol endpoints
Configure the following options in appsettings.json
:
{
"McpToolConfig": {
"ServerUrl": "http://localhost:3001"
},
"GitRepository": {
"LocalPath": "C:\\temp\\BootstrapBlazorRepo" // Optional: custom local repository path
}
}
# MCP call example
ListComponents()
Returns names and descriptions of all BootstrapBlazor components.
GetComponentFiles("Button")
Returns a list of source code files and example files for the specified component.
GetFileContent({
"ComponentName": "Button",
"FileName": "Button.razor.cs",
"Category": "Source" // Source or Example
})
Returns the complete content of the specified file.
This service is designed to integrate with AI assistants that support the MCP protocol:
- Add MCP server in GitHub Copilot settings
- Configure server address:
https://localhost:3001
- Restart GitHub Copilot to apply configuration
Add to Claude Desktop configuration file:
{
"mcpServers": {
"bootstrapblazor": {
"command": "dotnet",
"args": ["run", "--project", "path/to/BootstrapBlazor.Copilot.MCPServer"],
"env": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
}
}
- Create a new tool class in the
Tools
directory - Mark the class with
[McpServerToolType]
- Mark tool methods with
[McpServerTool]
- Register the service in
Program.cs
Example:
[McpServerToolType]
public class NewTool
{
[McpServerTool, Description("New tool description")]
public string NewMethod(string parameter)
{
return "Result";
}
}
You can add new component analysis logic in ComponentDocumentationService
:
- Parse component properties
- Extract usage examples
- Generate component relationship diagrams
/health
- Complete health check/alive
- Basic liveness check
The project uses the .NET standard logging framework, supporting:
- Console output
- File logging (requires configuration)
- Structured logging
- OpenTelemetry integration
Provided through .NET Aspire and OpenTelemetry:
- Request tracing
- Performance metrics
- Distributed tracing
- Error monitoring
-
Git repository clone failure
- Check network connectivity
- Verify Git is properly installed
- Check firewall settings
-
MCP connection failure
- Verify server address configuration
- Check if port is in use
- Confirm MCP client configuration is correct
-
Component files not found
- Confirm BootstrapBlazor repository is properly cloned
- Check local repository path configuration
- Verify component name spelling
Enable detailed logging in development environment:
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"BootstrapBlazor.Copilot.MCPServer": "Trace"
}
}
}
- Fork this project
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Create a Pull Request
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
- BootstrapBlazor Official Website
- BootstrapBlazor GitHub Repository
- Model Context Protocol Specification
- .NET Aspire Documentation
- Update the component model, add example file and documentation file attributes
- Correct the file search logic to look for example code only in the Samples directory
- Update the MCP server version number and the way to access configuration items
- Adjust the ServerUrl configuration in the development environment to use HTTP protocol
- Initial release
- Basic MCP tool implementation
- Git repository auto-sync
- Component documentation service
Note: This project is currently in development, and APIs may change. Thorough testing is recommended before production use.