Skip to content

Commit 830d85a

Browse files
sbroenneStefan Broenner
andauthored
feat: add batch mode CLI command for bulk operations (#464)
* feat: add batch mode CLI command for bulk operations (#463) Add 'excelcli batch' command that executes multiple CLI commands in a single process launch, eliminating per-process startup overhead and terminal buffer saturation for agents performing bulk operations. Key features: - Session auto-capture from session.open/create results - NDJSON output (one JSON result per line) - --stop-on-error flag to halt on first failure - --input <file> for JSON array or NDJSON input - --session <id> to pre-set default session Includes 13 integration tests covering: - Single/multiple command execution - Continue-on-error and stop-on-error behavior - Input validation (empty array, missing command, file not found) - NDJSON output format verification - NDJSON input format support - Exit code semantics Bug fixes included: - Fix 'unknown' category fallback in source generators - Add HasMcpToolAttribute filter for MCP tool generation - Escape Spectre.Console markup chars in CLI descriptions - Fix wrong param names in conditionalformat.md and slicer.md - Fix bash to PowerShell syntax in skills docs - Strip skills/README.md to minimal content * docs: update CHANGELOG for batch mode and bug fixes --------- Co-authored-by: Stefan Broenner <[email protected]>
1 parent c579aa0 commit 830d85a

17 files changed

Lines changed: 755 additions & 223 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ This changelog covers all components:
1313
### Added
1414

1515
- **CLI `--output` flag** for all commands: Save command output directly to a file. Screenshot commands automatically save decoded PNG images instead of base64 JSON
16+
- **CLI Batch Mode** (#463): New `excelcli batch` command executes multiple CLI commands from a JSON file in a single process launch
17+
- Session auto-capture from `session.open`/`session.create`, auto-clear on `session.close`
18+
- NDJSON output for machine-readable results
19+
- `--stop-on-error` flag to halt on first failure (default: continue all)
1620

1721
### Fixed
1822

1923
- **Screenshot reliability**: Screenshots now work reliably regardless of whether Excel is visible or hidden. Added automatic retry for transient capture failures
24+
- **CLI `--help` crash** (#463): Fixed Spectre.Console markup crash when parameter descriptions contain `[`/`]` characters (e.g., `[A1 notation]`)
25+
- **Source generator tool filtering**: Fixed `mcpTool ?? "unknown"` fallback; added `HasMcpToolAttribute` to correctly filter MCP-only tools
26+
- **Skills docs parameter names**: Fixed wrong CLI parameter names in `conditionalformat.md` and `slicer.md` reference files
2027

2128
## [1.7.2] - 2026-02-15
2229

skills/README.md

Lines changed: 18 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,37 @@
11
# Excel MCP Server - Agent Skills
22

3-
Cross-platform AI assistant guidance for Excel MCP Server, following the emerging Agent Skills specification.
4-
5-
## Two Skills for Different Use Cases
3+
Two skill packages for AI coding assistants:
64

75
| Skill | Target | Best For |
86
|-------|--------|----------|
9-
| **[excel-cli](excel-cli/SKILL.md)** | CLI Tool | **Coding agents** (Copilot, Cursor, Windsurf) - token-efficient, `--help` discoverable |
10-
| **[excel-mcp](excel-mcp/SKILL.md)** | MCP Server | **Conversational AI** (Claude Desktop, VS Code Chat) - rich tool schemas, exploratory workflows |
11-
12-
### When to use CLI (Recommended for Coding Agents)
13-
14-
Modern coding agents increasingly favor CLI-based workflows over MCP because:
15-
- **Token-efficient**: No large tool schemas loaded into context
16-
- **Discoverable**: Agents can run `excelcli --help` to learn commands
17-
- **Scriptable**: Works in PowerShell pipelines, CI/CD, batch processing
18-
- **Quiet mode**: `-q` flag outputs clean JSON only
19-
20-
```powershell
21-
# Coding agent workflow
22-
excelcli -q session open C:\Data\Report.xlsx
23-
excelcli -q range set-values --session 1 --sheet Sheet1 --range A1 --values-json '[["Hello"]]'
24-
excelcli -q session close --session 1 --save
25-
```
26-
27-
### When to use MCP Server
28-
29-
MCP remains relevant for:
30-
- Exploratory automation with iterative reasoning
31-
- Self-healing workflows needing rich introspection
32-
- Long-running autonomous tasks with continuous context
33-
- Conversational interfaces (Claude Desktop, VS Code Chat)
7+
| **[excel-cli](excel-cli/SKILL.md)** | CLI Tool | Coding agents - token-efficient, `--help` discoverable |
8+
| **[excel-mcp](excel-mcp/SKILL.md)** | MCP Server | Conversational AI - rich tool schemas |
349

35-
## What Are Agent Skills?
36-
37-
Agent Skills are reusable instruction sets that extend AI coding assistants with domain-specific knowledge. They enable consistent, reliable behavior when working with specific tools like Excel MCP Server.
38-
39-
## Supported Platforms
40-
41-
| Platform | Install Location | Auto-Install |
42-
|----------|------------------|--------------|
43-
| **GitHub Copilot** | `~/.copilot/skills/excel-mcp/` | Via VS Code extension |
44-
| **Claude Code** | `.claude/skills/excel-mcp/` | Manual or npx |
45-
| **Cursor** | `.cursor/skills/excel-mcp/` | Manual or npx |
46-
| **Windsurf** | `.windsurf/skills/excel-mcp/` | Manual or npx |
47-
| **Gemini CLI** | `.gemini/skills/excel-mcp/` | Manual or npx |
48-
| **Goose** | `.goose/skills/excel-mcp/` | Manual or npx |
49-
50-
## Installation Methods
51-
52-
### Method 1: VS Code Extension (Copilot)
53-
54-
Install the [Excel MCP Server extension](https://marketplace.visualstudio.com/items?itemName=sbroenne.excel-mcp) - skills are installed automatically to `~/.copilot/skills/`.
55-
56-
Enable skills in VS Code settings:
57-
```json
58-
{
59-
"chat.useAgentSkills": true
60-
}
61-
```
62-
63-
### Method 2: npx skills add (Cross-Platform)
64-
65-
The repository contains TWO skills. The CLI will prompt you to select which one(s) to install:
10+
## Installation
6611

6712
```bash
68-
# Interactive install - prompts to select excel-cli, excel-mcp, or both
69-
npx skills add sbroenne/mcp-server-excel
70-
71-
# Install specific skill directly
13+
# Via VS Code extension (auto-installs excel-mcp)
14+
# Or via npx:
7215
npx skills add sbroenne/mcp-server-excel --skill excel-cli # Coding agents
7316
npx skills add sbroenne/mcp-server-excel --skill excel-mcp # Conversational AI
74-
75-
# Install both skills
76-
npx skills add sbroenne/mcp-server-excel --skill '*'
77-
78-
# Install for specific agent
79-
npx skills add sbroenne/mcp-server-excel --skill excel-cli -a cursor
80-
npx skills add sbroenne/mcp-server-excel --skill excel-mcp -a claude-code
81-
82-
# Install globally (user-wide)
83-
npx skills add sbroenne/mcp-server-excel --skill excel-cli --global
8417
```
8518

86-
### Method 3: GitHub Release Download
87-
88-
Download `excel-skills-vX.X.X.zip` from [GitHub Releases](https://github.com/sbroenne/mcp-server-excel/releases/latest).
89-
90-
The package contains both skills:
91-
- `skills/excel-cli/` - for coding agents (Copilot, Cursor, Windsurf)
92-
- `skills/excel-mcp/` - for conversational AI (Claude Desktop, VS Code Chat)
93-
94-
Extract the skill(s) you need to your AI assistant's skills directory:
95-
- Copilot: `~/.copilot/skills/excel-cli/` or `~/.copilot/skills/excel-mcp/`
96-
- Claude Code: `.claude/skills/excel-cli/` or `.claude/skills/excel-mcp/`
97-
- Cursor: `.cursor/skills/excel-mcp/` or `.cursor/skills/excel-cli/`
98-
- Windsurf: `.windsurf/skills/excel-mcp/` or `.windsurf/skills/excel-cli/`
99-
100-
### Method 4: Git Clone (Development)
101-
102-
```bash
103-
# Clone and copy
104-
git clone https://github.com/sbroenne/mcp-server-excel.git
105-
cp -r mcp-server-excel/skills/excel-mcp ~/.copilot/skills/
106-
```
107-
108-
## Directory Structure
109-
110-
```
111-
skills/
112-
├── README.md # This file
113-
├── shared/ # Shared behavioral guidance (source of truth)
114-
│ ├── behavioral-rules.md # Core execution rules
115-
│ ├── anti-patterns.md # Common mistakes to avoid
116-
│ ├── workflows.md # Production workflow patterns
117-
│ ├── powerquery.md # Power Query specifics
118-
│ ├── datamodel.md # Data Model/DAX specifics
119-
│ ├── table.md # Table operations
120-
│ ├── range.md # Range operations
121-
│ ├── worksheet.md # Worksheet operations
122-
│ ├── chart.md # Chart operations
123-
│ ├── slicer.md # Slicer operations
124-
│ └── conditionalformat.md # Conditional formatting
125-
├── excel-mcp/ # MCP Server skill package
126-
│ ├── SKILL.md # Primary skill definition (MCP tools)
127-
│ ├── README.md # MCP skill installation guide
128-
│ ├── VERSION # Version tracking
129-
│ └── references/ # MCP-specific + shared (copied during build)
130-
│ ├── claude-desktop.md # Claude Desktop setup (MCP-specific)
131-
│ └── (shared files) # Copied from shared/ by build script
132-
├── excel-cli/ # CLI skill package
133-
│ ├── SKILL.md # CLI commands documentation
134-
│ ├── README.md # CLI skill installation guide
135-
│ └── references/ # CLI-specific + shared (copied during build)
136-
│ ├── README.md # Explains build process
137-
│ └── (shared files) # Copied from shared/ by build script
138-
├── CLAUDE.md # Claude Code project instructions
139-
└── .cursorrules # Cursor-specific rules
140-
```
141-
142-
**Note:** Shared behavioral guidance lives in `shared/` and is copied to each skill's `references/` folder during the build. Run `dotnet build -c Release` to generate SKILL.md and copy references.
143-
144-
## Platform-Specific Files
145-
146-
### For Claude Code Users
147-
148-
Copy `CLAUDE.md` to your project root:
149-
```bash
150-
cp skills/CLAUDE.md /path/to/your/project/CLAUDE.md
151-
```
152-
153-
Or reference from `.claude/skills/`:
154-
```bash
155-
mkdir -p .claude/skills
156-
cp -r skills/excel-mcp .claude/skills/
157-
```
158-
159-
### For Cursor Users
160-
161-
Copy `.cursorrules` to your project root:
162-
```bash
163-
cp skills/.cursorrules /path/to/your/project/.cursorrules
164-
```
165-
166-
## Building the Skills Package
167-
168-
Skill files are generated automatically during Release builds:
19+
## Building
16920

17021
```powershell
171-
# Build solution - generates SKILL.md and copies references
17222
dotnet build -c Release
173-
174-
# Output (in skills/ folder):
175-
# excel-mcp/SKILL.md - Generated MCP skill documentation
176-
# excel-mcp/references/ - Copied shared reference files
177-
# excel-cli/SKILL.md - Generated CLI skill documentation
178-
# excel-cli/references/ - Copied shared reference files
17923
```
18024

181-
For release artifacts (ZIP package), the GitHub Actions workflow handles packaging.
25+
Generates `SKILL.md` and copies `shared/` references into each skill's `references/` folder.
18226

183-
## Version Compatibility
27+
## Structure
18428

185-
| Skills Version | MCP Server Version | Minimum Excel |
186-
|----------------|-------------------|---------------|
187-
| 1.2.0+ | 1.2.0+ | Excel 2016+ |
188-
| 1.1.x | 1.1.x | Excel 2016+ |
189-
190-
## Contributing
191-
192-
See [CONTRIBUTING.md](../docs/CONTRIBUTING.md) for guidelines on improving the skills.
193-
194-
## Related Resources
195-
196-
- [Excel MCP Server Documentation](https://excelmcpserver.dev/)
197-
- [MCP Registry](https://mcp.run/registry)
198-
- [agentskills.io Specification](https://agentskills.io)
29+
```
30+
skills/
31+
├── shared/ # Shared behavioral guidance (source of truth)
32+
├── excel-mcp/ # MCP Server skill (SKILL.md + references/)
33+
├── excel-cli/ # CLI skill (SKILL.md + references/)
34+
├── templates/ # Scriban templates for SKILL.md generation
35+
├── CLAUDE.md # Claude Code project instructions
36+
└── .cursorrules # Cursor-specific rules
37+
```

skills/excel-cli/SKILL.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ documentation: https://excelmcpserver.dev/
2525
| 3. Write data | See below | If writing values |
2626
| 4. Save & close | `session close --save` | Always last |
2727

28+
> **10+ commands?** Use `excelcli -q batch --input commands.json` — sends all commands in one process with automatic session management. See Rule 8.
29+
2830
**Writing Data (Step 3):**
2931
- `--values` takes a JSON 2D array string: `--values '[["Header1","Header2"],[1,2]]'`
3032
- Write **one row at a time** for reliability: `--range-address A1:B1 --values '[["Name","Age"]]'`
@@ -33,6 +35,8 @@ documentation: https://excelmcpserver.dev/
3335

3436
## CRITICAL RULES (MUST FOLLOW)
3537

38+
> **⚡ Building dashboards or bulk operations?** Skip to **Rule 8: Batch Mode** — it eliminates per-command process overhead and auto-manages session IDs.
39+
3640
### Rule 1: NEVER Ask Clarifying Questions
3741

3842
Execute commands to discover the answer instead:
@@ -120,6 +124,35 @@ excelcli -q calculationmode calculate --session 1 --scope workbook
120124
excelcli -q calculationmode set-mode --session 1 --mode automatic
121125
```
122126

127+
### Rule 8: Use Batch Mode for Bulk Operations (10+ commands)
128+
129+
When executing 10+ commands on the same file, use `excelcli batch` to send all commands in a single process launch. This avoids per-process startup overhead and terminal buffer saturation.
130+
131+
```powershell
132+
# Create a JSON file with all commands
133+
@'
134+
[
135+
{"command": "session.open", "args": {"filePath": "C:\\path\\file.xlsx"}},
136+
{"command": "range.set-values", "args": {"sheetName": "Sheet1", "rangeAddress": "A1", "values": [["Hello"]]}},
137+
{"command": "range.set-values", "args": {"sheetName": "Sheet1", "rangeAddress": "A2", "values": [["World"]]}},
138+
{"command": "session.close", "args": {"save": true}}
139+
]
140+
'@ | Set-Content commands.json
141+
142+
# Execute all commands at once
143+
excelcli -q batch --input commands.json
144+
```
145+
146+
**Key features:**
147+
- **Session auto-capture**: `session.open`/`create` result sessionId auto-injected into subsequent commands — no need to parse and pass session IDs
148+
- **NDJSON output**: One JSON result per line: `{"index": 0, "command": "...", "success": true, "result": {...}}`
149+
- **`--stop-on-error`**: Exit on first failure (default: continue all)
150+
- **`--session <id>`**: Pre-set session ID for all commands (skip session.open)
151+
152+
**Input formats:**
153+
- JSON array from file: `excelcli -q batch --input commands.json`
154+
- NDJSON from stdin: `Get-Content commands.ndjson | excelcli -q batch`
155+
123156
## CLI Command Reference
124157

125158
> Auto-generated from `excelcli --help`. Use these exact parameter names.
@@ -299,7 +332,7 @@ Data Model relationships - link tables for cross-table DAX calculations. CRITICA
299332

300333

301334

302-
### unknown
335+
### diag
303336

304337
Diagnostic commands for testing CLI/MCP infrastructure without Excel. These commands validate parameter parsing, routing, JSON serialization, and error handling — no Excel COM session needed.
305338

@@ -520,7 +553,7 @@ Hyperlink and cell protection operations for Excel ranges. Use range for values/
520553

521554

522555

523-
### unknown
556+
### screenshot
524557

525558
Capture Excel worksheet content as images for visual verification. Uses Excel's built-in rendering (CopyPicture) to capture ranges as PNG images. Captures formatting, conditional formatting, charts, and all visual elements. ACTIONS: - capture: Capture a specific range as an image - capture-sheet: Capture the entire used area of a worksheet RETURNS: Base64-encoded PNG image data with dimensions metadata. For MCP: returned as inline ImageContent. For CLI: saved to file.
526559

skills/excel-cli/references/conditionalformat.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@
8484

8585
**CLI Usage**:
8686

87-
```bash
87+
```powershell
8888
# Add rule: highlight values > 100 in yellow
89-
excelcli conditionalformat add-rule --session <id> --sheet "Data" --range "B2:B100" \
90-
--rule-type "cell-value" --operator "greater" --formula1 "100" --interior-color "#FFFF00"
89+
excelcli conditionalformat add-rule --session <id> --sheet-name "Data" --range-address "B2:B100" `
90+
--rule-type "cell-value" --operator-type "greater" --formula1 "100" --interior-color "#FFFF00"
9191
9292
# Add expression rule: highlight entire row if column A is "Error"
93-
excelcli conditionalformat add-rule --session <id> --sheet "Data" --range "A2:E100" \
94-
--rule-type "expression" --formula "=\$A2=\"Error\"" --interior-color "#FF0000" --font-color "#FFFFFF"
93+
excelcli conditionalformat add-rule --session <id> --sheet-name "Data" --range-address "A2:E100" `
94+
--rule-type "expression" --formula1 "=`$A2=`"Error`"" --interior-color "#FF0000" --font-color "#FFFFFF"
9595
9696
# Clear all rules from range
97-
excelcli conditionalformat clear-rules --session <id> --sheet "Data" --range "A1:E100"
97+
excelcli conditionalformat clear-rules --session <id> --sheet-name "Data" --range-address "A1:E100"
9898
```
9999

100100
**Common Mistakes**:

skills/excel-cli/references/slicer.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ Two distinct slicer types exist:
3939

4040
The `--selected-items` parameter requires a JSON array. Use proper shell escaping:
4141

42-
```bash
42+
```powershell
4343
# PowerShell: use single quotes around the JSON, double quotes inside
4444
--selected-items '["West","East"]'
4545
46-
# Or escape inner quotes with backslash
47-
--selected-items "[\"West\",\"East\"]"
46+
# Or escape inner quotes with backtick
47+
--selected-items "[`"West`",`"East`"]"
4848
4949
# Clear filter (show all items)
5050
--selected-items '[]'
@@ -72,12 +72,12 @@ The `--selected-items` parameter requires a JSON array. Use proper shell escapin
7272

7373
**CLI Usage**:
7474

75-
```bash
75+
```powershell
7676
# Create PivotTable slicer
77-
excelcli slicer create-slicer --session <id> --pivottable-name "SalesPivot" --field-name "Region" --destination-sheet "Dashboard"
77+
excelcli slicer create-slicer --session <id> --pivot-table-name "SalesPivot" --field-name "Region" --destination-sheet "Dashboard"
7878
7979
# Set slicer filter
80-
excelcli slicer set-slicer-selection --session <id> --slicer-name "RegionSlicer" --selected-items "[\"West\",\"East\"]"
80+
excelcli slicer set-slicer-selection --session <id> --slicer-name "RegionSlicer" --selected-items "[`"West`",`"East`"]"
8181
8282
# Clear slicer filter (show all)
8383
excelcli slicer set-slicer-selection --session <id> --slicer-name "RegionSlicer" --selected-items "[]"

skills/excel-mcp/references/conditionalformat.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@
8484

8585
**CLI Usage**:
8686

87-
```bash
87+
```powershell
8888
# Add rule: highlight values > 100 in yellow
89-
excelcli conditionalformat add-rule --session <id> --sheet "Data" --range "B2:B100" \
90-
--rule-type "cell-value" --operator "greater" --formula1 "100" --interior-color "#FFFF00"
89+
excelcli conditionalformat add-rule --session <id> --sheet-name "Data" --range-address "B2:B100" `
90+
--rule-type "cell-value" --operator-type "greater" --formula1 "100" --interior-color "#FFFF00"
9191
9292
# Add expression rule: highlight entire row if column A is "Error"
93-
excelcli conditionalformat add-rule --session <id> --sheet "Data" --range "A2:E100" \
94-
--rule-type "expression" --formula "=\$A2=\"Error\"" --interior-color "#FF0000" --font-color "#FFFFFF"
93+
excelcli conditionalformat add-rule --session <id> --sheet-name "Data" --range-address "A2:E100" `
94+
--rule-type "expression" --formula1 "=`$A2=`"Error`"" --interior-color "#FF0000" --font-color "#FFFFFF"
9595
9696
# Clear all rules from range
97-
excelcli conditionalformat clear-rules --session <id> --sheet "Data" --range "A1:E100"
97+
excelcli conditionalformat clear-rules --session <id> --sheet-name "Data" --range-address "A1:E100"
9898
```
9999

100100
**Common Mistakes**:

0 commit comments

Comments
 (0)