Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Tools/McpServer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ Tools are invoked automatically by the LLM for dynamic queries.
| Tool | Description | Parameters |
|------|-------------|------------|
| `ListComponents` | Lists all available components | `category` (optional) |
| `ListCategories` | Lists all available component categories | - |
| `GetComponentDetails` | Gets detailed documentation for a component | `componentName` |
| `SearchComponents` | Searches components by name or description | `searchTerm` |
| `GetEnumValues` | Gets enum type values | `enumName`, `filter` (optional) |
| `GetComponentEnums` | Lists enums used by a component | `componentName` |
| `ListDocumentationTopics` | Lists all documentation topics | - |
| `ListEnums` | Lists all available enum types | - |
| `ListDocumentation` | Lists all documentation topics | - |
| `GetDocumentationTopic` | Gets detailed documentation for a documentation topic | `topicName` |
| `SearchDocumentation` | Searches documentation by keyword | `searchTerm` |
| `GetMigrationGuide` | Gets migration guide for upgrading to v5 | - |
Expand Down
37 changes: 37 additions & 0 deletions src/Tools/McpServer/Tools/ComponentListTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,41 @@
// Sort the combined results by name for stable output
return [.. components.Concat(additionalComponents).OrderBy(c => c.Name, StringComparer.OrdinalIgnoreCase)];
}

/// <summary>
/// Lists all available component categories in the Fluent UI Blazor library.
/// Use this to discover valid category names for filtering <see cref="ListComponents"/>.
/// </summary>
/// <returns>
/// A formatted string listing all component categories with the number of components in each.
/// </returns>
[McpServerTool]
[Description("Lists all available component categories in Fluent UI Blazor. Use this to find valid category names for filtering ListComponents(category: ...).")]
public string ListCategories()
{
var components = _documentationService.GetAllComponents();

var groups = components
.GroupBy(c => c.Category, StringComparer.OrdinalIgnoreCase)
.OrderBy(g => g.Key, StringComparer.OrdinalIgnoreCase)
.ToList();

Comment thread
AClerbois marked this conversation as resolved.
if (groups.Count == 0)
{
return "No component categories found.";
}

Check failure on line 184 in src/Tools/McpServer/Tools/ComponentListTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)

Check failure on line 184 in src/Tools/McpServer/Tools/ComponentListTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)

Check failure on line 184 in src/Tools/McpServer/Tools/ComponentListTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)

Check failure on line 184 in src/Tools/McpServer/Tools/ComponentListTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)
var sb = new StringBuilder();
sb.AppendLine(CultureInfo.InvariantCulture, $"# Fluent UI Blazor - Component Categories ({groups.Count} categories)");
sb.AppendLine();

foreach (var group in groups)
{
sb.AppendLine(CultureInfo.InvariantCulture, $"- **{group.Key}** ({group.Count()} components)");
}

sb.AppendLine();
sb.AppendLine("Use `ListComponents(category: \"<CategoryName>\")` to list components in a specific category.");

return sb.ToString();
}
}
33 changes: 33 additions & 0 deletions src/Tools/McpServer/Tools/EnumTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,37 @@

return sb.ToString();
}

/// <summary>
/// Lists all enum types available in the Fluent UI Blazor library.
/// Use this to discover valid enum names for <see cref="GetEnumValues"/>.
/// </summary>
/// <returns>
/// A formatted string listing all enum types with their descriptions.
/// </returns>
[McpServerTool]
[Description("Lists all enum types available in the Fluent UI Blazor library. Use this to discover valid enum names for GetEnumValues(enumName: ...).")]
public string ListEnums()
{
var enums = _documentationService.GetAllEnums();

Comment thread
AClerbois marked this conversation as resolved.
if (enums.Count == 0)
{
return "No enums found.";
}

Check failure on line 177 in src/Tools/McpServer/Tools/EnumTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)

Check failure on line 177 in src/Tools/McpServer/Tools/EnumTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)

Check failure on line 177 in src/Tools/McpServer/Tools/EnumTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)

Check failure on line 177 in src/Tools/McpServer/Tools/EnumTools.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Blank line required between block and subsequent statement (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide2003)
var sb = new StringBuilder();
sb.AppendLine(CultureInfo.InvariantCulture, $"# Fluent UI Blazor - Enum Types ({enums.Count} enums)");
sb.AppendLine();

foreach (var enumInfo in enums)
{
var description = string.IsNullOrEmpty(enumInfo.Description) ? string.Empty : $" — {enumInfo.Description}";
sb.AppendLine(CultureInfo.InvariantCulture, $"- **{enumInfo.Name}**{description}");
}

sb.AppendLine();
sb.AppendLine("Use `GetEnumValues(enumName: \"EnumName\")` to see all values for a specific enum.");

return sb.ToString();
}
}
65 changes: 65 additions & 0 deletions tests/Tools/McpServer.Tests/Tools/ComponentListToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,69 @@ public void Constructor_ShouldInitializeCorrectly()
}

#endregion

#region ListCategories Tests

[Fact]
public void ListCategories_ShouldReturnCategories()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListCategories();

// Assert
Assert.False(string.IsNullOrEmpty(result));
Assert.Contains("# Fluent UI Blazor - Component Categories", result, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ListCategories_ShouldIncludeComponentCounts()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListCategories();

// Assert
Assert.Contains("components)", result, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ListCategories_ShouldIncludeUsageHint()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListCategories();

// Assert
Assert.Contains("ListComponents", result, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ListCategories_ShouldContainKnownCategory()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListCategories();

// Assert
Assert.Contains("Button", result, StringComparison.OrdinalIgnoreCase);
}

#endregion
}
65 changes: 65 additions & 0 deletions tests/Tools/McpServer.Tests/Tools/EnumToolsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,4 +332,69 @@ public void Constructor_ShouldInitializeCorrectly()
}

#endregion

#region ListEnums Tests

[Fact]
public void ListEnums_ShouldReturnEnumNames()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListEnums();

// Assert
Assert.False(string.IsNullOrEmpty(result));
Assert.Contains("Appearance", result, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ListEnums_ShouldReturnHeader()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListEnums();

// Assert
Assert.Contains("# Fluent UI Blazor - Enum Types", result, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ListEnums_ShouldIncludeUsageHint()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListEnums();

// Assert
Assert.Contains("GetEnumValues", result, StringComparison.OrdinalIgnoreCase);
}

[Fact]
public void ListEnums_ShouldIncludeCount()
{
Skip.IfNot(_jsonFileExists, "JSON documentation file not found");

// Arrange
var tools = CreateTools();

// Act
var result = tools.ListEnums();

// Assert
Assert.Contains("enums)", result, StringComparison.OrdinalIgnoreCase);
}

#endregion
}
Loading