Skip to content

Conversation

@AClerbois
Copy link
Collaborator

@AClerbois AClerbois commented Dec 5, 2025

Pull Request

📖 Description

Following the issue #4386, I create the MCP Server.

The MCP is documented in the demo doc examples via reflexion.

You can find all MCP ressources via the documentation.

If you run it via VS Code, you can get the follow behavior.

Prompts :
image

Tools :
image

Ressources :
image

🎫 Issues

👩‍💻 Reviewer Notes

You should follow the Examples/Mcp/Readme.md file to isntall locally the MCP and test it.

📑 Test Plan

✅ 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

After that, you should publish the new NuGet generated package to NuGet.org

  • 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

- Implemented EnumInfoFactory for creating enum information from types.
- Developed FluentUIDocumentationService to extract documentation from Fluent UI components.
- Created TypeHelper for type-related operations, including friendly type names and enum value retrieval.
- Added XmlDocumentationReader for reading XML documentation comments.
- Introduced ComponentDetailTools for detailed component documentation retrieval.
- Created ComponentListTools for listing and searching Fluent UI components.
- Developed EnumTools for accessing enum documentation and values.
- Implemented GuideTools for accessing documentation guides.
- Added ToolOutputHelper for formatting tool output.
- Created XmlDocumentationFinder to locate XML documentation files.
- Added FluentUI.Mcp.Shared project to the solution.
- Integrated MCP capabilities into the FluentUI.Demo.Client project.
- Updated solution and project files to include new references.
- Removed McpReflectionService.cs from the server project and moved it to the shared project.
- Created McpCapabilitiesData class to provide static data for MCP tools, prompts, and resources.
- Implemented MCP server documentation in McpServer.md.
- Added a new example page (McpCapabilities.razor) to demonstrate MCP capabilities.
- Removed obsolete McpReflectionService.cs file from the server project.
- Removed the C# MCP Server Expert agent documentation.
- Added NSubstitute package for mocking in tests.
- Updated solution file to include new MCP project and test projects.
- Created new test projects for FluentUI MCP Server and its services.
- Implemented unit tests for DocumentationGuideService, FluentUIDocumentationService, and MCP capabilities.
- Added tests for component detail and list tools, including search and filtering functionalities.
- Introduced tests for enum tools and guide tools, ensuring coverage for known and unknown cases.
- Configured xUnit runner settings for test execution.
!type.Name.Contains('<') &&
!type.Name.Contains('>') &&
!type.Name.EndsWith("_g") &&
typeof(ComponentBase).IsAssignableFrom(type);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this check use typeof(IComponent).IsAssignableFrom(type) instead?
Just wondering because components can implement IComponent directly without inheriting from ComponentBase, so I wanted to confirm whether the intent here is to include only ComponentBase-derived components or all valid component types.

Choose a reason for hiding this comment

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

After a discussion with @dvoituron, we found you're right about the ComponentBase, but the IComponent is not the best choice.

In the library each component must be inherit from FluentComponentBase and ````FluentInputBase, both as interfaced through IFluentComponentBase```.

This is the best choice to enforce the security then

.Select(c => c.Category)
.Where(c => !string.IsNullOrEmpty(c))
.Distinct()
.OrderBy(c => c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit / Question:
Noticed that Distinct and OrderBy don’t specify a comparer here.
Is the case-sensitivity or ordering intended to follow the default culture-aware behavior?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I will fix it in my next commit. Ty

vnbaaij and others added 2 commits December 10, 2025 15:41
- Implement tests for DocumentationGuideService to verify guide retrieval and content.
- Add tests for FluentUIDocumentationService to ensure component details and categories are correctly returned.
- Create tests for various prompts including CreateComponentPrompt, CreateFormPrompt, and ExplainComponentPrompt to validate prompt generation.
- Introduce tests for McpCapabilitiesData and McpReflectionService to check data integrity and resource availability.
- Develop tests for tools such as ComponentDetailTools, ComponentListTools, EnumTools, and GuideTools to ensure functionality and correctness.
- Establish a global usings file for test projects to streamline code.
- Set up project file for the test suite with necessary dependencies and configurations.

Update namespaces to new McpServer structure and Blazor APIs

Migrated all FluentUI.Mcp.Server.* and FluentUI.Mcp.Shared.* references to Microsoft.FluentUI.AspNetCore.Components.McpServer.* and related namespaces across the codebase. Updated Blazor components in McpCapabilities.razor to use new FluentTabs/FluentTab APIs (Label, ActiveTabIdChanged) and added type parameters to FluentDataGrid. Adjusted service initialization and test setup to use the correct assemblies. Added "peer": true to several dev dependencies in package-lock.json. These changes align with the new package structure and resolve naming conflicts.

Refine component type filtering and category sorting

Expanded IsValidComponentType docs to clarify FluentUI focus and rationale for IFluentComponentBase usage. Updated filtering to require IFluentComponentBase implementation. Improved GetCategories to use case-insensitive distinct and sorting. Added explicit System.Linq import.
@AClerbois AClerbois force-pushed the users/aclerbois/dev-v5/add-mcp branch from 21de7f6 to 103238c Compare December 11, 2025 17:04
AClerbois and others added 5 commits December 11, 2025 20:30
Major refactor: replace XML-based documentation with build-time generated JSON file for all component and enum info. Remove LoxSmoke.DocXml dependency and all runtime XML parsing. Embed JSON as resource for fast, reliable access. Update DI, services, tests, and README. Add new generator, models, and MSBuild targets for auto-generation and embedding.
Enhance SetupProjectPrompt to include explicit version info and NuGet guidance. Expose documented component and MCP Server versions in FluentUIDocumentationService. Add CheckVersionCompatibilityPrompt for semantic version checks and actionable recommendations. Introduce VersionTools for programmatic version info and compatibility checks. Register new prompt in service collection. Improves user guidance and reduces documentation mismatches.
Added new test classes for MCP Server prompts, resources, and tools, including coverage for prompt generation, resource access, and version/tooling features. Updated CreateFormPromptTests for v5 component naming. Enhanced McpCapabilitiesDataTests with cache and initialization checks. All new tests include MIT license headers and XML documentation. These changes greatly improve test coverage and reliability.

Add comprehensive unit tests for MCP Server and prompts

Expanded test coverage for MCP Server, Prompts, Resources, Tools, and Shared models. Added dedicated test classes for each prompt and resource, including edge case and error handling tests. Improved robustness of existing tests, especially for v5 component name changes. Ensured all new tests include MIT license headers and XML documentation. This enhances reliability and maintainability across the codebase.
Refactored codebase to use C# collection expressions (e.g., [.. collection], []) instead of .ToList(), new[], or Array.Empty<T>(). This modernizes and simplifies list and array creation throughout both implementation and test files, improving readability without changing behavior. Also includes minor formatting cleanups for consistency.
<packageSources>
<clear />
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
<add key="dotnet9" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Microsoft ADO refues to have multiple feeds. We can use only the dotnet-public

app.UseRequestLocalization(new RequestLocalizationOptions().AddSupportedUICultures(["en", "fr"]));

// API endpoint to expose MCP capabilities for WebAssembly clients
app.MapGet("/api/mcp/capabilities", () => McpCapabilitiesData.GetSummary())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you add this API? The Blazor Demo project can be published using Server but also WASM mode to be hosted on a static website.

- **Resources**: User-selected static content (component lists, guides)
- **Prompts**: Pre-defined templates for common tasks (create component, migrate code)

{{ McpCapabilities }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to display the source code of this component. You can add SourceCode="false" to hide the source tab.

</FluentTabs>
}

@code {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we don't display the source code in the .md file, can you move this code to a .cs file ?

else
{
// Fetch from API (for WebAssembly mode)
_summary = await Http.GetFromJsonAsync<McpSummary>("/api/mcp/capabilities");
Copy link
Collaborator

Choose a reason for hiding this comment

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

The final hosting will be on a static web site. So not API available :-(

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can have an API with SWA

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you change this file ?

@AClerbois
Copy link
Collaborator Author

@vnbaaij @Tyme-Bleyaert FYI :

After a code review today with @dvoituron,

We decided to stop this PR and split it into several smaller prs, following the plan :

  1. Prepare the docgenapi, to provide a text file to the future step containing a complete json file to be used for the next step.

  2. Create a smaller MCPs server with less MCP content and provide then into several smaller PR and add minimum markdown documentation.

  3. Improve agan the docgenapi to provide to the demo(doc) the reflexion of the tool provided by the MCP. Instead make reflection via API. More efficient than reflection.

  4. Add Prompts / Ressources / toosl in the MCP Server.

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.

5 participants