letin
OfficialClick on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@letin lint all queries in my Power BI project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
letin
An MCP server that gives an AI assistant (GitHub Copilot in VS Code, Claude, …) real tools for managing Power Query (M) queries, in Excel workbooks and in Power BI projects.
Copilot in Excel / Power BI can suggest M. It cannot see how your queries depend on each other, rename one without breaking the rest, repoint forty queries at a new server, tell you which step killed query folding, put your queries in git, run a query to see what a step really returns, or check the M it just wrote against the real function library. This server does those things.
What it does
Area | Tools |
Inspect |
|
Guided actions |
|
Bulk edit / refactor |
|
Lint / performance |
|
Version control |
|
Run M |
|
M language |
|
Excel live |
|
Every write snapshots first, returns a unified diff, accepts dry_run=true, and is refused if it would turn valid M into a syntax error.
All edits are token-aware: a query called Sales is never confused with a column [Sales],
the string "Sales", or a comment.
Related MCP server: Microsoft Fabric MCP Server
Sources
Every tool takes a source:
| Backed by | Read | Write |
| Closed: the file's | ✅ | ✅ via COM. Already open → edited live, left unsaved for you to review. Closed → opened hidden with macros disabled, saved, closed. |
| The workbook in front in Excel | ✅ | ✅ |
| TMDL files ( | ✅ | ✅ M of any query; add/rename/delete for shared expressions only (renaming a table must be done in Desktop) |
| TMSL JSON: legacy PBIP, Tabular Editor, SSAS/AAS projects | ✅ | ✅ same rules as TMDL; string-vs-line-array form of each expression is kept |
| The model of a running Power BI Desktop (works for | ✅ | ❌ read-only by design: inspect, lint, diff, export, |
| One query per file, named after the file | ✅ | ✅ |
|
| ✅ | ✅ member-level edits; |
a folder of |
| ✅ | ✅ |
A .pbix file is refused with instructions (save as .pbip, or open it and use pbi:desktop). Desktop must be
closed/reopened to pick up PBIP edits (that is how Desktop works, not a limitation of this server).
How evaluation works
evaluate_* never runs anything in your session. A private, hidden, macro-disabled Excel opens a throwaway copy of the
workbook (unsaved edits included), or for non-Excel sources a blank workbook seeded with the source's queries. Your expression
is wrapped in try, the outcome is serialised to JSON by M itself, landed on a scratch sheet and read back. The refresh runs
in the background under a watchdog; on timeout that Excel is killed, so a credential or privacy prompt cannot hang the server.
Typical cost: 7-10 s per call. Non-Excel sources are evaluated by Excel's engine: Power BI-only connectors are unavailable
and credentials come from Excel's data source settings for your Windows user. ignore_privacy_levels=true turns the privacy
firewall off for that one throwaway evaluation.
Install
Windows, Python 3.10+, Excel installed for workbook editing. letin is on PyPI
and in the MCP Registry as io.github.S-CurveLabs/letin.
The simplest way to run it is with uv, which needs no separate install step:
uvx letinOr install it with pip install letin and run letin.
GitHub Copilot in VS Code
Run MCP: Open User Configuration from the command palette and add:
{
"servers": {
"letin": {
"type": "stdio",
"command": "uvx",
"args": ["letin"]
}
}
}Then in Copilot Chat switch to Agent mode and check that the letin tools are enabled.
Claude Code
claude mcp add letin -- uvx letinFrom source
git clone https://github.com/S-CurveLabs/letin.git
cd letin
python -m venv .venv
.\.venv\Scripts\pip install -e .Opening the clone in VS Code picks up .vscode/mcp.json, which runs that checkout with .venv\Scripts\python.exe -m letin.
Things to ask
"List the queries in
C:\Reports\Sales.xlsxand draw the dependency graph as Mermaid.""Lint it. Which steps are breaking query folding?"
"Every query points at
\\oldserver\finance. Move that into a parameter calledSourceFolder.""Rename
Query1tostg_Orderseverywhere.""In
Budget, unpivot everything except Department and Account, then group by Department summing Value.""Export the queries to
./queriesso I can commit them." / "What changed in the workbook since that export?""Undo that last change."
"What columns does
Saleshave after the Merged Queries step? Show me 5 rows." / "Walk me through what every step ofSalesdoes." / "At which step does the error first appear?""Write a query that pivots months into columns, validate it, run it, then save it as
Sales by Month.""What's the signature of
Table.NestedJoin? Which functions split text?""Format every query in this workbook." / "What queries are in the report I have open in Power BI Desktop?"
Safety model
Snapshots live in
%LOCALAPPDATA%\letin\snapshots\<workbook>-<hash>\(last 50 per source); override the root withLETIN_HOME.Formulas with unbalanced brackets or unterminated strings are rejected before they reach the host.
Hidden Excel instances are started with
AutomationSecurity = ForceDisable: workbook macros never run.refresh_queryonly works on a workbook you have open, because a hidden refresh can block forever on a credentials or privacy-level prompt.The server itself makes no network calls. Only
evaluate_*andrefresh_queryrun M, always in Excel's engine, which then contacts whatever data sources that M reads, exactly as a refresh in Excel would. Every other tool is static analysis.Evaluation happens on a throwaway copy in a separate hidden Excel, under a timeout; nothing open on your screen is modified.
Limits (v0.2)
Evaluation needs Excel on the machine, and uses Excel's engine even for Power BI sources (see above).
Live Power BI Desktop is read-only, and needs Windows PowerShell 5.1 (built into Windows) to drive Desktop's ADOMD client.
Reference analysis is lexical. Names built at runtime (
Expression.Evaluate,#shared) are reported, not rewritten.The validator knows the library of this machine's Excel; connectors that exist only in Power BI are reported as
info, never as errors. Regenerate the catalog after an Office update withpython scripts/build_m_library.py.Lint rules about folding are heuristics; confirm with View Native Query.
model.bimis re-serialised as 2-space JSON, so the first diff can be noisy if your tool formats it differently.
Development
.\.venv\Scripts\pip install -e ".[dev]"
.\.venv\Scripts\pytest -m "not excel" # pure tests
.\.venv\Scripts\pytest # also drives a real hidden ExcelLayout: m/ (lexer, structural parser, full syntax parser, validator, formatter) → graph.py lint.py refactor.py
transforms.py (pure, host-agnostic) → hosts/ (Excel COM + file, PBIP/TMDL, model.bim, live Desktop, M files, folder)
→ evaluate.py (hidden-Excel evaluation) → server.py (MCP tools). data/m_library.json is generated by
scripts/build_m_library.py.
License
MIT. See LICENSE.
Available Tools
31 toolsapply_transformB
Add a standard Power Query step without hand-writing M. action and params come from list_transforms, e.g.
action='unpivot_other_columns', params={'keep_columns': ['Region']}; or action='group_by',
params={'group_columns': ['Region'], 'aggregations': [{'name': 'Total', 'operation': 'sum', 'column': 'Amount'}]}.
The step is appended to the end unless after_step names an earlier step (the next step is rewired, as the editor does).
Inputs: query (required), action (required), params (required), source (required), +3 more.
copy_queriesB
Copy queries between workbooks / projects / folders, bringing the queries they depend on along.
Inputs: names (required), to_source (required), from_source (required), dry_run, +2 more.
delete_queryBDestructive
Delete a query. Refuses when other queries reference it unless force=true.
Inputs: name (required), source (required), force, dry_run.
dependency_graphARead-only
Query-to-query lineage. With query, only its upstream and downstream. format: 'json' or 'mermaid'.
Also reports roots (read external data), leaves (final outputs), orphans and cyclic references.
Inputs: source (required), query, format.
diff_queriesARead-only
Compare the queries of two sources (workbook vs workbook, workbook vs exported folder, PBIP vs PBIP ...).
Line endings are ignored. To compare against a snapshot pass its path from list_snapshots.
Inputs: source_a (required), source_b (required).
evaluate_mARead-only
Run any M expression and get the result as data. Tables come back with column names, types and the first rows
rows (cell errors shown as #ERROR); lists, records, scalars and functions (with signature) are described too; an M error
comes back as reason + message. With source, the expression can reference that source's queries by name
(e.g. Table.RowCount(Sales)), including unsaved edits of an open workbook. count_rows and profile (Table.Profile:
min/max/nulls/distinct per column) scan the whole result, so they can be slow. ignore_privacy_levels=true disables the
privacy firewall for this throwaway evaluation only.
Inputs: expression (required), rows, source, profile, +3 more.
evaluate_queryARead-only
Freshly evaluate a query, or the query only up to step, and return columns, types and sample rows. Use it to get real
column names before apply_transform, to see what a step does to the data, or to find the step where an error first
appears (evaluate step by step).
Inputs: query (required), source (required), rows, step, +4 more.
evaluate_stepsARead-only
Evaluate EVERY step of a query in one engine call and describe each one (columns, types, first rows rows, or the
error). The fastest way to see how a query transforms its data and to find the step where an error first appears:
one call instead of evaluate_query once per step.
Inputs: query (required), source (required), rows, timeout_seconds, +1 more.
export_queriesB
Write every query to folder as one .pq file each plus pq-manifest.json: ready to commit to git and diff in a PR.
Existing .pq files in the folder are replaced.
Inputs: folder (required), source (required).
extract_parameterB
Turn a hard-coded text value (path, server, URL) into a Power Query parameter and reference it everywhere. With match_prefix, "C:\Data" also rewrites "C:\Data\sales.csv" to SourceFolder & "\sales.csv".
Inputs: value (required), source (required), parameter_name (required), dry_run, +2 more.
find_in_queriesBRead-only
Search the M of every query. scope: all | code | strings | comments. Returns query, step and line for each hit.
Inputs: source (required), pattern (required), regex, scope.
format_mARead-only
Pretty-print M (an expression or a section document): one step per line, long calls broken at their arguments, comments kept. The output is verified token-for-token against the input, so meaning can never change.
Inputs: formula (required).
format_queriesA
Format one query, or every query, in place (same guarantees as format_m).
Inputs: source (required), query, dry_run.
get_queryBRead-only
Full M code of one query plus its parsed steps, data sources, dependencies and dependents.
Inputs: name (required), source (required).
import_queriesA
Load .pq files from folder back into source. mode='update' changes/adds queries; mode='sync' also deletes
queries that are not in the folder.
Inputs: folder (required), source (required), mode, dry_run.
lint_queriesARead-only
Audit queries for folding breakers, hard-coded paths/servers, dead steps, brittle column lists, untyped columns, duplicated logic, orphans and cycles. Each finding carries a concrete suggestion. min_severity: info | warning | error.
Inputs: source (required), query, min_severity.
list_data_sourcesBRead-only
Inventory of every external source (files, folders, servers, URLs) each query reads, and whether it is hard-coded or parameterised.
Inputs: source (required).
list_queriesCRead-only
Every query with its kind (query/function/parameter), step count, load destination, and what it depends on / is used by.
Inputs: source (required).
list_snapshotsBRead-only
Snapshots taken automatically before each write to this source, newest first.
Inputs: source (required).
list_sourcesARead-only
List workbooks open in Excel and models open in Power BI Desktop (both usable as source), and explain the other source forms.
Inputs: no named parameters.
list_transformsARead-only
Catalog of guided actions for apply_transform (unpivot, pivot, group_by, merge, filter, types, ...) with their params.
Inputs: no named parameters.
m_function_helpARead-only
Look up the M standard library (generated from the real engine: 850+ members). Give an exact name ('Table.Group') for its signature and description, a namespace ('Table.' or 'List') to list its members, or words to search names and descriptions ('unpivot', 'split text delimiter'). Use it instead of guessing signatures.
Inputs: name_or_search (required), limit.
preview_queryBRead-only
Column names and first rows of a query that is loaded to a worksheet table (open Excel workbook only). Use it to get real column names before apply_transform.
Inputs: name (required), source (required), rows.
refresh_queryA
Refresh one query in an open Excel workbook and wait for it; returns the mashup engine's error text if it fails.
Inputs: name (required), source (required).
remove_stepA
Delete a step and rewire the steps that used it to the step it read from.
Inputs: step (required), query (required), source (required), dry_run.
rename_queryA
Rename a query and rewrite every reference to it in all other queries (token-aware: strings, comments and same-named columns are left alone).
Inputs: source (required), new_name (required), old_name (required), dry_run.
rename_stepB
Rename a step inside a query and every reference to it.
Inputs: query (required), source (required), new_name (required), old_name (required), +1 more.
replace_in_queriesA
Find and replace across all (or the listed) queries in one go, e.g. repoint a server or folder. scope: 'strings' (only inside text literals; safest, the default), 'code' (outside strings and comments), 'all'.
Inputs: find (required), source (required), replace (required), regex, +4 more.
restore_snapshotA
Roll back to a snapshot. With queries, only those are restored; otherwise the whole query set is put back
(queries created since are deleted). 'latest' undoes the most recent write.
Inputs: source (required), dry_run, queries, snapshot_id.
set_queryA
Replace a query's M (or create it with create_if_missing). Rejects unbalanced brackets/strings before writing. For standard actions prefer apply_transform; for renames prefer rename_query / rename_step.
Inputs: name (required), source (required), formula (required), dry_run, +2 more.
validate_mARead-only
Check M before using it: syntax errors with line/column and a plain-English cause (missing comma between steps,
unquoted step name, if without else ...), unknown steps/queries/functions with did-you-mean, and wrong argument counts
for library functions. Pass formula (an expression or a whole section document); add source so its query names are
known. Or pass source (+ optional query) alone to validate what is already there.
Inputs: query, source, formula.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 31 tools
Most tools are clearly distinct (apply_transform vs evaluate_m vs format_m serve different purposes), but a few could be confused: evaluate_query and evaluate_steps overlap in intent, and list_data_sources vs list_sources are similar in name and both deal with sources. Overall, descriptions help clarify, but a couple of pairs require careful reading.
All tool names follow a consistent verb_noun pattern, using snake_case throughout. Verbs like list, get, create, delete, update, rename, remove, validate, format, evaluate, import, export, copy, diff, refresh, preview, replace are all used in a predictable way, making the naming highly consistent and easy to learn.
With 27 tools, the server exceeds the typical well-scoped range of 3-15 tools. The breadth of functionality is impressive, but the high count may overwhelm agents, especially when several tools overlap in purpose (e.g., evaluate_query vs evaluate_steps). The count feels heavy for a single cohesive toolset, though each tool does serve a niche.
The toolset covers the full lifecycle of Power Query management: creating, reading, updating, deleting, renaming, formatting, validating, importing/exporting, diffing, snapshotting, searching, linting, and evaluating queries. It also includes comprehensive dependency analysis and source inventory, with no obvious dead ends for common workflows.
Related MCP Connectors
The Excel engine for AI agents: read, check and edit Excel models over MCP.
AI access to Quadratic spreadsheets: open files, run Python/SQL, query connected databases.
Forge designed Power BI projects (.pbip) from your agent, bound to your own semantic model.
AI code governance and code review for Claude Code, Copilot and Cursor. Checks rules and security.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceControl Excel with Natural Language through AI assistants like GitHub Copilot, Claude, and ChatGPT. This MCP server enables AI-powered Excel automation for Power Query, DAX measures, VBA macros, PivotTables, and more.935MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to interact with Microsoft Fabric and Power BI services through the Model Context Protocol. Users can manage workspaces, execute DAX queries, refresh datasets, and create Fabric notebooks using natural language.69 npm2MIT
- AlicenseAqualityDmaintenanceEnables exploring Microsoft Fabric / Power BI workspaces and semantic models, and executing ad-hoc DAX queries.57MIT
- AlicenseNot gradedqualityDmaintenanceEnables natural language interaction with Power BI Desktop via MCP, allowing DAX authoring, measure optimization, and model inspection.MIT