Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 9, 2025

Summary

excel_pivottable tool was invisible to LLMs despite complete implementation. Missing [McpServerToolType] class attribute and explicit tool name prevented MCP SDK's WithToolsFromAssembly() discovery.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Maintenance (dependency updates, code cleanup, etc.)

Related Issues

Closes #[issue number per problem statement]

Changes Made

ExcelPivotTableTool.cs (2 lines):

  • Added [McpServerToolType] to class - required for SDK assembly scanning
  • Added explicit Name = "excel_pivottable" to [McpServerTool] attribute

ToolDiscoveryTests.cs (new file, 24 tests):

  • Verifies all 11 tools have [McpServerToolType] class attribute
  • Verifies all 11 tools have [McpServerTool(Name = "...")] with correct naming convention
  • Prevents regression

Pattern comparison:

// ❌ Before (not discoverable)
public static partial class ExcelPivotTableTool
{
    [McpServerTool]
    public static async Task<string> ExcelPivotTable(...)

// ✅ After (discoverable, matches all other tools)
[McpServerToolType]
public static partial class ExcelPivotTableTool
{
    [McpServerTool(Name = "excel_pivottable")]
    public static async Task<string> ExcelPivotTable(...)

Testing Performed

  • Build produces zero warnings
  • All 24 unit tests pass (ToolDiscoveryTests)
  • Smoke test compiles and references tool correctly
  • Verified pattern matches all 10 other working MCP tools

Test Commands

# Unit tests (no Excel required)
dotnet test --filter "Category=Unit&Feature=ToolDiscovery"

# Smoke test (requires Excel)
dotnet test --filter "FullyQualifiedName~McpServerSmokeTests.SmokeTest_AllTools_LlmWorkflow"

Screenshots (if applicable)

N/A - attribute-only fix with no UI changes

Core Commands Coverage Checklist ⚠️

Does this PR add or modify Core Commands methods? [x] No

Core implementation already existed and was complete. Only MCP SDK discovery attributes were missing.

Checklist

  • Code follows project style guidelines
  • Self-review of code completed
  • Code builds with zero warnings
  • Appropriate error handling added
  • Updated help text (if adding new commands)
  • Updated README.md (if needed)
  • Follows Excel COM best practices from copilot-instructions.md
  • Uses ExcelHelper.WithExcel() for Excel operations
  • Properly handles 1-based Excel indexing
  • Escapes user input with .EscapeMarkup()
  • Returns consistent exit codes (0 = success, 1+ = error)

Additional Notes

Documentation already listed excel_pivottable as tool #6 of 11 - only discovery mechanism was broken. Zero functional changes to PivotTable implementation itself.

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG] LLMs cannot find the PivotTable functionality in the MCP Server</issue_title>
<issue_description>They only see:

excel_batch
excel_connection
excel_datamodel
excel_file
excel_namedrange
excel_powerquery
excel_querytable
excel_range
excel_table
excel_vba
excel_worksheet</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 9, 2025 14:03
- Added [McpServerToolType] attribute to ExcelPivotTableTool class
- Added explicit Name = "excel_pivottable" to [McpServerTool] attribute
- Matches pattern used by all other working MCP tools
- Enables MCP SDK's WithToolsFromAssembly() to discover the tool

The tool implementation was complete but missing the required attributes
for auto-discovery. LLMs can now find and use excel_pivottable.

Co-authored-by: sbroenne <3026464+sbroenne@users.noreply.github.com>
- Created ToolDiscoveryTests to verify all 11 MCP tools have required attributes
- Tests verify [McpServerToolType] on class and [McpServerTool(Name)] on method
- All 24 tests pass, confirming PivotTable tool is properly configured
- Prevents regression of tool discovery issues

Co-authored-by: sbroenne <3026464+sbroenne@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix LLMs inability to find PivotTable functionality Fix: Add missing MCP SDK discovery attributes to PivotTable tool Nov 9, 2025
Copilot AI requested a review from sbroenne November 9, 2025 14:08
Copilot finished work on behalf of sbroenne November 9, 2025 14:08
@sbroenne sbroenne marked this pull request as ready for review November 9, 2025 14:43
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

1 similar comment
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sbroenne sbroenne merged commit a66561b into main Nov 9, 2025
6 checks passed
@sbroenne sbroenne deleted the copilot/fix-pivottable-functionality branch November 9, 2025 14:43
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.

[BUG] LLMs cannot find the PivotTable functionality in the MCP Server

2 participants