Skip to main content
Glama

excel

Author and run VBA macros in a workbook via COM; check AccessVBOM trust first to prevent HRESULT 0x800a03ec failures.

Instructions

Purpose: Author and run VBA macros against Excel via COM late binding (ADR-015). Headline differentiator against Claude for Excel which writes formulas but cannot run VBA. Details: action='run_vba' authors a Sub in a fresh workbook, saves into the managed Trusted Location (%LOCALAPPDATA%\desktop-touch-mcp\trusted-vba), and Application.Run the macro. Requires HKCU AccessVBOM=1 + VBAWarnings=1 + a registered Trusted Location (all configured by node scripts/enable-access-vbom.mjs). Trust setup: Excel must restart after the CLI runs (values cached at process start). action='check_access_vbom' is a read-only preflight returning {trusted, lockedByPolicy, scope}. Prefer: Run check_access_vbom first when a workflow depends on macro execution; the remediation hint pre-empts an opaque HRESULT 0x800a03ec failure inside run_vba. Caveats: macroName MUST appear as Sub <name>(...) in code (else VbaMacroNotFound). VBA Editor UI is structurally bypassed — no UIA tree walk needed. Excel COM is STA: each call serialises through the bridge's worker thread, so long-running macros block subsequent excel() calls on the same MCP server. Examples: excel({action:'check_access_vbom'}) → {trusted:true, scope:'hkcu'} excel({action:'run_vba', code:'Sub DesktopTouchAdHoc()\n Range("A1").Value = "Hello"\nEnd Sub'}) → {ok:true, workbookPath:'...\trusted-vba\dt_vba_.xlsm'} excel({action:'run_vba', code:'Sub Demo()\n MsgBox "hi"\nEnd Sub', macroName:'Demo', visible:true}) → demo recording path

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeNoVBA source. MUST declare at least one Sub matching `macroName` (default `DesktopTouchAdHoc`). Example: "Sub DesktopTouchAdHoc()\r\n Range(\"A1\").Value = \"Hello\"\r\nEnd Sub"
actionYesAction selector — one of: run_vba, check_access_vbom. Per-action required fields are enforced at call time (see the tool description); this flat schema lists every action's fields as optional.
includeNoOptional response-shape opt-in. `['envelope']` returns the self-documenting envelope (`_version` / `data` / `as_of` / `confidence`). `['raw']` forces raw shape (overrides DESKTOP_TOUCH_ENVELOPE=1 server default). Default behaviour is raw shape (compat with existing clients).
visibleNoIf true, show the Excel window during execution. Default false (headless). Setting visible:true is useful for demo recording but may surface MsgBox/InputBox calls in the macro that block the COM thread.
macroNameNoSub name to invoke. MUST appear in `code` as `Sub <name>(...)`. Default `DesktopTouchAdHoc`.DesktopTouchAdHoc

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv2.3.1
    • addedInput schema / $schema
      Added value: +"http://json-schema.org/draft-07/schema#"
    • removedInput schema / additionalProperties
      Removed value: -true
    • addedInput schema / properties / action
      Added value: +{
      +  "description": "Action selector — one of: run_vba, check_access_vbom. Per-action required fields are enforced at call time (see the tool description); this flat schema lists every action's fields as optional.",
      +  "enum": [
      +    "run_vba",
      +    "check_access_vbom"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / code
      Added value: +{
      +  "description": "VBA source. MUST declare at least one Sub matching `macroName` (default `DesktopTouchAdHoc`). Example: \n\"Sub DesktopTouchAdHoc()\\r\\n    Range(\\\"A1\\\").Value = \\\"Hello\\\"\\r\\nEnd Sub\"",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / include
      Added value: +{
      +  "description": "Optional response-shape opt-in. `['envelope']` returns the self-documenting envelope (`_version` / `data` / `as_of` / `confidence`). `['raw']` forces raw shape (overrides DESKTOP_TOUCH_ENVELOPE=1 server default). Default behaviour is raw shape (compat with existing clients).",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • addedInput schema / properties / macroName
      Added value: +{
      +  "default": "DesktopTouchAdHoc",
      +  "description": "Sub name to invoke. MUST appear in `code` as `Sub <name>(...)`. Default `DesktopTouchAdHoc`.",
      +  "minLength": 1,
      +  "type": "string"
      +}
    • addedInput schema / properties / visible
      Added value: +{
      +  "default": false,
      +  "description": "If true, show the Excel window during execution. Default false (headless). Setting visible:true is useful for demo recording but may surface MsgBox/InputBox calls in the macro that block the COM thread.",
      +  "type": "boolean"
      +}
    • addedInput schema / required
      Added value: +[
      +  "action"
      +]
  2. Addedv1.12.0
  3. Removedv1.10.4
  4. Addedv1.9.2
  5. Removedv1.8.0
  6. Addedv1.6.0
  7. Removedv1.5.1
  8. Addedv1.5.0

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and delivers: prerequisites (HKCU AccessVBOM=1, VBAWarnings=1, registered Trusted Location, restart-after-CLI), the STA serialization caveat that long macros block subsequent excel() calls, the VbaMacroNotFound failure mode, and the UI-bypass behavior. This is unusually rich behavioral disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with 'Purpose:' followed by Details, Prefer, Caveats, and Examples — a predictable structure. It is dense and long, but nearly every line carries non-redundant information, so the length is justified rather than padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex COM/VBA tool with no output schema, the description supplies enough: return-shape examples (trusted/scope, ok/workbookPath), preconditions, and failure modes. Nothing an agent needs to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds real meaning: macroName must appear as `Sub <name>(...)` in code (else VbaMacroNotFound), and the three worked examples show how action/code/macroName/visible combine. The cross-parameter constraint between code and macroName is the key added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Author and run VBA macros against Excel via COM late binding') and clearly enumerates the two actions, run_vba and check_access_vbom. It differentiates against an external product ('Claude for Excel') but never distinguishes from the sibling tool run_macro, which an agent must otherwise infer is different.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit ordering rule — run check_access_vbom first when a workflow depends on macro execution — and explains the remediation motivation. It stops short of stating when NOT to use this tool versus siblings like run_macro, so exclusion guidance is missing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.