Skip to content

Add MCP server for Fluent UI Blazor documentation#4425

Merged
vnbaaij merged 4 commits intomicrosoft:dev-v5from
AClerbois:users/aclerbois/dev-v5/mcp-2-create-mcp
Dec 31, 2025
Merged

Add MCP server for Fluent UI Blazor documentation#4425
vnbaaij merged 4 commits intomicrosoft:dev-v5from
AClerbois:users/aclerbois/dev-v5/mcp-2-create-mcp

Conversation

@AClerbois
Copy link
Collaborator

Introduces a new MCP (Model Context Protocol) server project that exposes comprehensive Fluent UI Blazor component documentation (names, summaries, parameters, events, methods, enums) via the MCP protocol for AI assistants and tools. The server uses pre-generated JSON documentation for fast, dependency-free access, with robust error handling and support for both development and packaged scenarios.

Includes:

  • New server project with stdio transport, tools, and resources for component and enum queries.
  • Service and model layer for querying documentation data.
  • Pre-build generation and embedding of JSON documentation.
  • Comprehensive unit and integration tests.
  • Documentation, packaging, and solution updates.

No changes to the main Fluent UI Blazor component library; all changes are isolated to the new MCP server and its infrastructure.

Pull Request

📖 Description

This pull request introduces a new MCP (Model Context Protocol) server for Fluent UI Blazor component documentation, along with supporting infrastructure and utilities. The main focus is on enabling AI assistants and tools to access structured metadata about Fluent UI Blazor components, including their parameters, events, methods, and enums. The changes include new project files, models, helpers, and build logic to generate and serve component documentation in a machine-readable format.

Key changes:

MCP Server Infrastructure

  • Added a new project Microsoft.FluentUI.AspNetCore.Components.McpServer with configuration for building, packaging, and serving as a .NET tool MCP server, including NuGet packaging metadata, build targets for generating documentation JSON, and embedding resources.
  • Included an MCP server manifest .mcp/server.json describing the server, its metadata, and how it is discovered and used by MCP clients.
  • Added .gitignore entries for generated documentation and VS Code settings in the MCP server directory.

Component Documentation Model

  • Introduced models representing components and their metadata, including ComponentInfo, ComponentDetails, EnumInfo, and related types for properties, events, and methods. These models provide a structured representation of component APIs for use by the MCP server. [1] [2] [3]

Utilities and Service Extensions

  • Added helpers for locating the pre-generated JSON documentation (JsonDocumentationFinder), formatting MCP tool output (ToolOutputHelper), and extension methods for configuring the MCP server and related services (ServiceCollectionExtensions). [1] [2] [3]

Solution and Dependency Management

  • Updated the solution file to include the new MCP server project and its test project under appropriate folders.
  • Added required package references for MCP server functionality and hosting, including ModelContextProtocol and Microsoft.Extensions.Hosting. [1] [2]

Minor Example/Test Updates

  • Marked properties with the [Parameter] attribute in ApiClassPerformanceTests.cs to align with Blazor component conventions.
  • Added a missing using directive in the same test file.

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

⏭ Next Steps

  • Improve the documentation to include the MCP configuration
  • Include the guide in the MCP
  • Include categories in the MCP
  • Include prompts

Copilot AI review requested due to automatic review settings December 23, 2025 17:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a comprehensive MCP (Model Context Protocol) server for Fluent UI Blazor component documentation, enabling AI assistants to access structured component metadata including parameters, events, methods, and enums. The implementation uses pre-generated JSON documentation for fast, dependency-free access with robust error handling.

Key changes:

  • New MCP server project with stdio transport, tools, resources, and comprehensive test coverage
  • Service and model layers for querying pre-generated JSON documentation
  • Build infrastructure for generating and embedding documentation
  • Extensive unit and integration tests covering all major functionality

Reviewed changes

Copilot reviewed 49 out of 49 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/Tools/McpServer.Tests/*.cs Comprehensive test suite with 30+ test classes covering models, services, tools, resources, and integration scenarios
tests/Tools/McpServer.Tests/TestHelpers.cs Custom test skip mechanism implementation
src/Tools/McpServer/Tools/*.cs MCP tool implementations for component listing, details, and enum queries
src/Tools/McpServer/Services/*.cs Documentation service and JSON reader with caching and error handling
src/Tools/McpServer/Resources/*.cs MCP resource implementations for static documentation access
src/Tools/McpServer/Models/*.cs Domain models representing components, enums, properties, events, and methods
src/Tools/McpServer/Helpers/*.cs Utility helpers for formatting tool output
src/Tools/McpServer/Extensions/*.cs Service collection extensions for DI configuration
src/Tools/McpServer/*.csproj Project configuration with NuGet packaging, tool setup, and pre-build documentation generation
src/Tools/McpServer/README.md Comprehensive documentation covering installation, architecture, usage, and debugging
Directory.Packages.props Added ModelContextProtocol and Microsoft.Extensions.Hosting package references
Microsoft.FluentUI-v5.slnx Updated solution to include MCP server and test projects

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vnbaaij
Copy link
Collaborator

vnbaaij commented Dec 24, 2025

Love this!. But the code should not be in the Microsoft.FluentUI.AspNetCore.Components namespace and the project should not be called Microsoft.FluentUI.AspNetCore.Components.McpServer

Please rename the project and namspace used to Microsoft.FluentUI.AspNetCore.McpServer. It then follows the same pattern as used for the Templates project.

@AClerbois
Copy link
Collaborator Author

@vnbaaij That's a very good point. I just pushed up the renamed version.
Happy Christmas to you and your loved family

Introduces a new MCP (Model Context Protocol) server project that exposes comprehensive Fluent UI Blazor component documentation (names, summaries, parameters, events, methods, enums) via the MCP protocol for AI assistants and tools. The server uses pre-generated JSON documentation for fast, dependency-free access, with robust error handling and support for both development and packaged scenarios.

Includes:
- New server project with stdio transport, tools, and resources for component and enum queries.
- Service and model layer for querying documentation data.
- Pre-build generation and embedding of JSON documentation.
- Comprehensive unit and integration tests.
- Documentation, packaging, and solution updates.

No changes to the main Fluent UI Blazor component library; all changes are isolated to the new MCP server and its infrastructure.

Downgrade server and package versions; update icon source

Downgraded server and NuGet package versions from 5.0.0-preview.4 to 5.0.0-preview.1. Changed the icon from a PNG on GitHub to an SVG on fluentui-blazor.net, updating the MIME type accordingly. Also updated the NuGet package identifier to Microsoft.FluentUI.AspNetCore.Components.McpServer.

Refactor LINQ usage in finder, cache init, and tests

Refactored JsonDocumentationFinder to use LINQ for file path selection, simplifying the code. Updated FluentUIDocumentationService cache initialization to use LINQ's Select for conversion. Adjusted integration tests to discard unused list tool results, clarifying test intent.

Refactor test loop to use LINQ Select for details

Refactored the foreach loop in SearchAndDetails_ShouldBeConsistent to use LINQ's Select for projecting components to their details before iteration. This simplifies the code by removing the inner call to GetComponentDetails and makes the loop more concise and readable.

Rename MCP server project to Microsoft.FluentUI.AspNetCore.McpServer

Renamed the MCP server and test projects from Microsoft.FluentUI.AspNetCore.Components.McpServer to Microsoft.FluentUI.AspNetCore.McpServer. Updated all namespaces, using directives, project references, and InternalsVisibleTo attributes accordingly. Adjusted solution, server manifest, launch settings, and documentation to use the new project and package name. No functional changes; this is a pure rename for clarity and consistency.
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/mcp-2-create-mcp branch from 517b5c6 to 29691e7 Compare December 28, 2025 09:18
- Move all MCP JSON model classes to dedicated files under Models.McpDocumentation for better organization
- Centralize log prefix with McpServerConstants.LogPrefix for consistent logging
- Use case-insensitive sorting/grouping for components, enums, and categories throughout
- Remove unused ExtractEventType method and related tests
- Refactor markdown generation in ComponentResources for clarity
- Add Meziantou.Analyzer to project for code analysis
- Use case-insensitive equality in MethodInfo
- Change GetEnumsForComponent to return IDictionary for abstraction
- Update tests and usages to new model namespace
- Overall, improves code structure, maintainability, and consistency

Refactor: case-insensitive ops, JSON models, logging

- Use case-insensitive ordering and comparisons for all component, enum, and category listings, as well as in tests.
- Move JSON documentation models to dedicated files and a new namespace for better organization.
- Remove obsolete ExtractEventType method and legacy test helpers; introduce dedicated skip/test attribute files.
- Standardize console logging with a new log prefix constant.
- Refactor component markdown generation into focused helper methods.
- Add Meziantou.Analyzer to main and test projects.
- Improve path handling and use consistent dictionary types.
- Clean up project files and test code for clarity and maintainability.
@AClerbois
Copy link
Collaborator Author

@dvoituron your comments have been fixed.

@AClerbois AClerbois requested a review from dvoituron December 30, 2025 10:26
Copy link
Collaborator

@dvoituron dvoituron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are a few errors in the Readme.md file (for example, the MCP json content).
But I suggest merging this tool and creating another PR with complete documentation only, including a tutorial for VSCode and Visual Studio (where to write the configuration files, how to start the tool—where to click, etc.).

@vnbaaij vnbaaij merged commit 302f503 into microsoft:dev-v5 Dec 31, 2025
3 checks passed
@AClerbois AClerbois deleted the users/aclerbois/dev-v5/mcp-2-create-mcp branch December 31, 2025 12:53
@vnbaaij vnbaaij linked an issue Dec 31, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MCP (Model Context Protocol) Server for Component Documentation

3 participants