Files
sbroenne__mcp-server-excel/docs/DEVELOPMENT.md
T
Stefan Broenner 321aa694f4 feat: Improve SEO and add comprehensive installation guide (#144)
* Refactor README files: Simplify language in ExcelMcp.ComInterop and remove ExcelMcp.Core documentation

* chore: Remove references to COMMANDS.md in documentation and workflows, update to README.md or component documentation

* chore: Update documentation references to CLI and remove obsolete CLI.md file

* feat(cli): implement 38 missing command wrappers and sync online help

Implementation (38 commands):
- Range: Add 33 commands (copy-values/formulas, insert/delete cells/rows/columns,
  find/replace/sort, discovery, hyperlinks, styles/validation, merge/autofit, advanced)
- Table: Add 2 commands (get/set-column-format)
- QueryTable: Add 3 commands (create-from-connection/query, update-properties)
- PivotTable: Document 7 blocked methods with technical context

Routing & Help:
- Add 38 routing entries in Program.cs switch statement
- Update ShowHelp() function with all 38 commands:
  * Range: Reorganize into 8 subsections for clarity
  * Table: Add 2 column format commands
  * QueryTable: Add 3 create/update commands
- Grow Program.cs from 554 to 608 lines (+9.7%)

Documentation:
- Update CLI README: 109 → 147 commands
- Update category counts: Range (11→44), Table (21→23), QueryTable (5→8)
- Update MCP Server README: CLI reference now shows 147 commands
- Document PivotTable limitations in code comments

Status: 38/45 commands complete (84.4%)
- Implemented: 38 (Range: 33, Table: 2, QueryTable: 3)
- Blocked: 7 (PivotTable methods awaiting file manipulation support)

Fixes:
- Correct property names in RangeCommands (Address vs Url, ScreenTip vs Tooltip)
- Fix hyperlink removal logic (target address calculation)
- Replace ToLowerInvariant() with StringComparison.OrdinalIgnoreCase for CA1862
- Ensure consistent formatting throughout

Zero compilation errors, all tests passing.

* refactor(release): unify MCP Server and CLI releases, optimize copilot instructions

Release Workflow Changes:
- Rename release-mcp-server.yml to handle both MCP Server and CLI
- Change tag pattern: mcp-v* → v* (unified versioning)
- MCP Server and CLI always release together with same version
- Single workflow builds and publishes both NuGet packages
- GitHub release includes both ZIP packages
- Delete obsolete workflows:
  * release-cli.yml (merged into unified workflow)
  * release-core.yml (no longer publishing Core to NuGet)
  * release-cominterop.yml (no longer publishing ComInterop to NuGet)

Copilot Instructions Optimization:
- copilot-instructions.md: 184→132 lines (-28%)
  * Replace verbose navigation with priority-based structure
  * Consolidate code patterns (remove redundant comments)
  * Compress 28 lesson paragraphs → 7 one-line takeaways
  * Simplify path-specific explanation

- critical-rules.instructions.md: Add usage-based priority table
  * Group rules by context: Every Edit, Writing Code, Writing Tests, Before Commit, PR Process, Rare
  * Replace flat list with contextual grouping for 10x faster scanning
  * Add 'Why Critical' column for each rule

Benefits:
- Simplified release process: One tag (v1.2.3) releases both packages
- Version consistency: MCP Server and CLI stay in sync
- Reduced CI/CD complexity: 3 fewer workflows to maintain
- Better LLM efficiency: 28% less token usage in main instructions
- Faster rule lookup: O(1) with priority table vs linear scan

* docs: update release documentation for unified v* versioning

- Updated RELEASE-STRATEGY.md: Removed separate Core/ComInterop/MCP/CLI sections, added unified MCP+CLI release section
- Updated NUGET-GUIDE.md: Changed to unified v* tag pattern, combined package documentation
- Updated MCP_REGISTRY_PUBLISHING.md: Changed mcp-v* to v* tag pattern
- All docs now reflect simplified release strategy (MCP Server + CLI always released together)

* docs: update development-workflow instructions for unified versioning

- Changed tag pattern from separate mcp-v*/cli-v* to unified v*
- Reflects simplified release strategy (MCP Server + CLI together)

* Remove redundant CheckIfOpen action

FileAction.CheckIfOpen was redundant because ExcelBatch already checks
if files are locked before opening Excel COM (via FileAccessValidator.
ValidateFileNotLocked). Operations fail gracefully with clear error
messages when files are open, eliminating need for pre-flight checks.

Changes:
- Remove CheckIfOpen from FileAction enum
- Remove CheckIfOpen implementation (75 lines)
- Remove CheckIfOpen from ActionExtensions mapping
- Update audit scripts to remove CheckIfOpen exceptions
- Update excel_file.md prompt to document automatic lock detection
- Update ExcelFileTool [Description] to remove CheckIfOpen guidance

Benefits:
- Simpler architecture with less mental load for LLMs
- One less action to learn and maintain
- Automatic error handling with actionable user guidance
- Consistent with batch mechanism that already handles this

Fixes: MCP Server test failures (missing enum mapping)

* Optimize instruction files for expert LLM audience

- Eliminate duplication across all 13 instruction files
- Remove beginner content and explanatory 'why' sections
- Establish expert tone throughout (assumes C#, Excel, COM knowledge)
- Consolidate test commands to testing-strategy (single source of truth)
- Cross-reference instead of duplicating content (WithExcel, SaveAsync, workflows)
- Major rewrites: bug-fixing (416→82), documentation-structure (355→86), mcp-llm-guidance (414→152), mcp-server-guide (282→192)
- Result: Most files now under 200 lines, focused on project-specific patterns only

* Update MCP Server README: emphasize RPA/CLI capabilities and simplify installation

- Add RPA (Robotic Process Automation) terminology for CLI automation use cases
- Remove specific command counts that change frequently
- Simplify installation section to prioritize VS Code Extension
- Add CLI example use case for version control workflows
- Update resources section with RPA/CI/CD focus

* feat: improve SEO with GitHub Pages docs and enhanced server.json description

* feat: Improve SEO and add comprehensive installation guide

- Add GitHub repository topics (20 relevant tags for discoverability)
- Update GitHub repository description for better search results
- Enable GitHub Pages with docs/index.md landing page
- Enhance MCP Registry server.json description
- Improve NuGet package metadata with comprehensive tags
- Add REPL developer callout and interactive development messaging
- Create comprehensive INSTALLATION.md guide
- Fix VS Code marketplace extension ID (sbroenne.excel-mcp)
- Add Critical Rule 20: Never commit automatically
- Update README and docs to mention both MCP Server and CLI prominently

---------

Co-authored-by: Stefan Broenner <stefan.broenner@microsoft.comm>
2025-11-09 10:49:25 +00:00

10 KiB
Raw Permalink Blame History

Development Workflow

🚨 IMPORTANT: All Changes Must Use Pull Requests

Direct commits to main are not allowed. All changes must go through the Pull Request (PR) process to ensure:

  • Code review and quality control
  • Proper version management
  • CI/CD validation
  • Documentation updates

📋 Standard Development Workflow

1. Create Feature Branch

# Create and switch to feature branch
git checkout -b feature/your-feature-name

# Or for bug fixes
git checkout -b fix/issue-description

# Or for documentation updates  
git checkout -b docs/update-description

2. Make Your Changes

# Make code changes, add tests, update docs
# Commit frequently with clear messages

git add .
git commit -m "Add feature X with tests and documentation

- Implement core functionality
- Add comprehensive unit tests  
- Update command documentation
- Include usage examples"

3. Push Feature Branch

# Push your feature branch to GitHub
git push origin feature/your-feature-name

4. Create Pull Request

  1. Go to GitHub Repository
  2. Click "New Pull Request"
  3. Select your feature branch
  4. Fill out the PR template:
    • Clear title describing the change
    • Detailed description of what was changed and why
    • Testing information - what tests were added/run
    • Breaking changes - if any
    • Documentation updates - what docs were updated

5. PR Review Process

  • Automated checks will run (build, tests, linting)
  • Code review by maintainers
  • Address feedback if requested
  • Merge once approved and all checks pass

6. After Merge

# Switch back to main and pull latest
git checkout main
git pull origin main

# Delete the feature branch (cleanup)
git branch -d feature/your-feature-name
git push origin --delete feature/your-feature-name

🏷️ Release Process

Creating a New Release

Only maintainers can create releases. The process is:

  1. Ensure all changes are merged to main via PRs

  2. Create and push a version tag:

# Create version tag (semantic versioning)
git tag v1.1.0

# Push the tag (triggers release workflow)
git push origin v1.1.0
  1. Automated Release Workflow:
    • ✅ Updates version numbers in project files
    • ✅ Builds the release binaries
    • ✅ Creates GitHub release with ZIP file
    • ✅ Updates release notes

Version Numbering

We follow Semantic Versioning:

  • Major (v2.0.0): Breaking changes
  • Minor (v1.1.0): New features, backward compatible
  • Patch (v1.0.1): Bug fixes, backward compatible

🔒 Branch Protection Rules

The main branch is protected with:

  • Require pull request reviews - Changes must be reviewed
  • Require status checks - CI/CD must pass
  • Require up-to-date branches - Must be current with main
  • No direct pushes - All changes via PR only

🧪 Testing Requirements & Organization

Three-Tier Test Architecture

ExcelMcp uses a production-ready three-tier testing approach with organized directory structure:

tests/
├── ExcelMcp.Core.Tests/
│   ├── Unit/           # Fast tests, no Excel required (~2-5 sec)
│   ├── Integration/    # Medium speed, requires Excel (~1-15 min)
│   └── RoundTrip/      # Slow, comprehensive workflows (~3-10 min each)
├── ExcelMcp.McpServer.Tests/
│   ├── Unit/           # Fast tests, no server required  
│   ├── Integration/    # Medium speed, requires MCP server
│   └── RoundTrip/      # Slow, end-to-end protocol testing
└── ExcelMcp.CLI.Tests/
    ├── Unit/           # Fast tests, no Excel required
    └── Integration/    # Medium speed, requires Excel & CLI

Development Workflow Commands

During Development (Fast Feedback):

# Quick validation - run tests for specific feature
dotnet test --filter "Feature=PowerQuery&RunType!=OnDemand"
dotnet test --filter "Feature=DataModel&RunType!=OnDemand"

Before Commit (Comprehensive):

# Full local validation - runs in 10-20 minutes (excludes VBA)
dotnet test --filter "Category=Integration&RunType!=OnDemand&Feature!=VBA&Feature!=VBATrust"

Session/Batch Code Changes (MANDATORY):

# When modifying ExcelSession.cs or ExcelBatch.cs
dotnet test --filter "RunType=OnDemand"

Test Categories & Guidelines

⚠️ No Unit Tests - See docs/ADR-001-NO-UNIT-TESTS.md for architectural rationale

Integration Tests (Category=Integration)

  • ✅ Test business logic with real Excel COM interaction
  • ✅ Medium speed (10-20 minutes for full suite)
  • ✅ Requires Excel installation
  • ✅ These ARE our unit tests (Excel COM cannot be mocked)
  • ✅ Run specific features during development
  • ✅ Slow execution (3-10 minutes each)
  • ✅ Verifies actual Excel state changes
  • ✅ Comprehensive scenario coverage

Adding New Tests

When creating tests, follow these placement guidelines:

// Unit Test Example
[Trait("Category", "Unit")]
[Trait("Speed", "Fast")]
[Trait("Layer", "Core")]
public class CommandLogicTests 
{
    // Tests business logic without Excel
}

// Integration Test Example  
[Trait("Category", "Integration")]
[Trait("Speed", "Medium")]
[Trait("Feature", "PowerQuery")]
[Trait("RequiresExcel", "true")]
public class PowerQueryCommandsTests
{
    // Tests single Excel operations
}

// Round Trip Test Example
[Trait("Category", "RoundTrip")]
[Trait("Speed", "Slow")]
[Trait("Feature", "EndToEnd")]
[Trait("RequiresExcel", "true")]
public class VbaWorkflowTests
{
    // Tests complete workflows: import → run → verify → export
}

PR Testing Requirements

Before creating a PR, ensure:

# Required - Integration tests pass (excludes VBA)
dotnet test --filter "Category=Integration&RunType!=OnDemand&Feature!=VBA&Feature!=VBATrust"

# Code builds without warnings
dotnet build -c Release

# Code follows style guidelines (automatic via EditorConfig)

For Complex Features:

  • ✅ Add integration tests for all Excel operations
  • ✅ Test round-trip persistence (create → save → reload → verify)
  • ✅ Update documentation
  • ✅ No unit tests needed (see ADR-001-NO-UNIT-TESTS.md)

📋 MCP Server Configuration Management

CRITICAL: Keep server.json in Sync

When modifying MCP Server functionality, you must update src/ExcelMcp.McpServer/.mcp/server.json:

When to Update server.json:

  • ✅ Adding new MCP tools - Add tool definition to "tools" array
  • ✅ Modifying tool parameters - Update inputSchema and properties
  • ✅ Changing tool descriptions - Update description fields
  • ✅ Adding new capabilities - Update "capabilities" section
  • ✅ Changing requirements - Update "environment"."requirements"

server.json Synchronization Checklist:

# After making MCP Server code changes, verify:

# 1. Tool definitions match actual implementations
Compare-Object (Get-Content "src/ExcelMcp.McpServer/.mcp/server.json" | ConvertFrom-Json).tools (Get-ChildItem "src/ExcelMcp.McpServer/Tools/*.cs")

# 2. Build succeeds with updated configuration
dotnet build src/ExcelMcp.McpServer/ExcelMcp.McpServer.csproj

# 3. Test MCP server starts without errors
dnx Sbroenne.ExcelMcp.McpServer --yes

server.json Structure:

{
  "version": "2.0.0",          // ← Updated by release workflow
  "tools": [                   // ← Must match Tools/*.cs implementations
    {
      "name": "excel_file",    // ← Must match [McpServerTool] attribute
      "description": "...",    // ← Keep description accurate
      "inputSchema": {         // ← Must match method parameters
        "properties": {
          "action": { ... },   // ← Must match actual actions supported
          "filePath": { ... }   // ← Must match parameter types
        }
      }
    }
  ]
}

Common server.json Update Scenarios:

  1. Adding New Tool:

    // In Tools/NewTool.cs
    [McpServerTool]
    public async Task<string> NewTool(string action, string parameter)
    
    // Add to server.json tools array
    {
      "name": "excel_newtool",
      "description": "New functionality description",
      "inputSchema": { ... }
    }
    
  2. Adding Action to Existing Tool:

    // In existing tool method
    case "new-action":
      return HandleNewAction(parameter);
    
    // Update inputSchema properties.action enum
    "action": {
      "enum": ["list", "create", "new-action"]  // ← Add new action
    }
    

<EFBFBD>📝 PR Template Checklist

When creating a PR, verify:

  • Code builds with zero warnings
  • All tests pass (unit tests minimum)
  • New features have tests
  • Documentation updated (README, etc.)
  • MCP server.json updated (if MCP Server changes) ← NEW
  • Breaking changes documented
  • Follows existing code patterns
  • Commit messages are clear

🚫 What NOT to Do

  • ❌ Don't commit directly to main
  • ❌ Don't create releases without PRs
  • ❌ Don't skip tests
  • ❌ Don't ignore build warnings
  • ❌ Don't update version numbers manually (release workflow handles this)

💡 Tips for Good PRs

Commit Messages

✅ Good: "Add PowerQuery batch refresh command with error handling"
❌ Bad: "fix stuff"

PR Titles

✅ Good: "Add batch operations for Power Query refresh"
❌ Bad: "Update code"

PR Size

  • Keep PRs focused - One feature/fix per PR
  • Break large changes into smaller, reviewable chunks
  • Include tests and docs in the same PR as the feature

🔧 Local Development Setup

# Clone the repository
git clone https://github.com/sbroenne/mcp-server-excel.git
cd ExcelMcp

# Install dependencies
dotnet restore

# Run all tests
dotnet test

# Build release version
dotnet build -c Release

# Test the built executable
.\src\ExcelMcp.CLI\bin\Release\net10.0\excelcli.exe --version

📞 Need Help?

  • Read the docs: Contributing Guide
  • Ask questions: Create a GitHub Issue with the question label
  • Report bugs: Use the bug report template

Remember: Every change, no matter how small, must go through a Pull Request!

This ensures code quality, proper testing, and maintains the project's reliability for all users.