Skip to main content
Glama
ossenna-hq

ltspice-mcp

by ossenna-hq

thd

Read-onlyIdempotent

Compute total harmonic distortion (THD and THD+N) from any transient simulation via FFT, using coherent sampling for exact harmonic measurements without requiring a .four directive.

Instructions

Total harmonic distortion (THD and THD+N) of a periodic transient signal via FFT — works on any .tran result without a .four directive in the deck, and on any simulator. Defaults to COHERENT sampling (record trimmed to whole fundamental cycles, rectangular window) so harmonics land exactly on bins and THD is exact; window='hann' is the approximate fallback. Surfaces every condition the number depends on: the fundamental (given vs auto-detected), window kind, cycles analyzed, FFT length, sample rate, and per-harmonic levels. For LTspice's own .four result instead, see simulation_summary's Fourier section.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stepNoStep index for .step sweeps
t_endNoWindow end in SPICE notation.
formatNo'json' or 'text'
job_idNoAnalyze a run of a completed sweep/MC (or single) job instead of a raw_file path; pair with ``run_index``.
signalYesSignal to analyze (e.g. 'V(out)').
windowNo'coherent' trims to whole fundamental cycles + rectangular window (exact, no leakage); 'hann' analyzes the full window with a Hann taper (approximate — use when cycles can't be made integer).coherent
t_startNoWindow start (SPICE notation) — skip the startup transient before measuring.
raw_fileNoPath to .raw transient result. Pass this OR ``job_id`` (a job run), not both.
run_indexNo0-based run to analyze when ``job_id`` is given (default 0).
fundamentalNoFundamental frequency in SPICE notation (e.g. '1k'). Omit to auto-detect (largest FFT bin); pass it for an exact coherent result.
n_harmonicsNoHarmonics 2..n folded into THD (1..50, default 7).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
fs_hzYes
n_fftYes
signalNo
thd_dbYes
windowYes
thd_pctYes
coherentYes
n_cyclesYes
warningsYes
harmonicsYes
thd_n_pctYes
thd_ratioYes
thd_n_ratioYes
fundamental_hzYes
n_harmonics_usedYes
fundamental_sourceYes
Behavior5/5

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

Annotations declare read-only/idempotent behavior, which the description matches. It goes beyond annotations by disclosing the coherent sampling default, exactness implications, auto-detection of fundamental, and all conditions affecting the result—excellent transparency for a signal-analysis tool.

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

Conciseness5/5

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

Three dense sentences, each adding critical information: purpose, methodology accuracy trade-offs, and pointers to alternatives. Front-loaded with the main action, no fluff.

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 an 11-parameter tool with an output schema, the description covers purpose, usage conditions, algorithmic nuances, and alternative tools. The existence of an output schema handles return values, so no gaps remain.

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 parameters are already documented. The description adds meaningful context for key parameters (e.g., fundamental auto-detection vs explicit, window choice affecting accuracy, t_start for skipping transient), enriching the schema without redundant repetition.

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

Purpose5/5

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

Description clearly states it computes THD/THD+N from a transient signal via FFT, and explicitly distinguishes from LTspice's .four via simulation_summary. The verb and resource are specific, and the 'works on any .tran result' scope clarifies its niche.

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

Usage Guidelines5/5

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

Explicitly says when to use (any .tran result without .four, any simulator) and directs to simulation_summary for .four results. Also provides guidance on coherent vs. hann window selection, which helps the agent choose the right approach.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ossenna-hq/MCP_LTSpice'

If you have feedback or need assistance with the MCP directory API, please join our Discord server