Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

simtest-funnel-mcp

A local MCP server that lets AI agents (Claude Code, Claude Desktop, any MCP client) compare signals stored in local CSV files with the funnel (tolerance-tube) algorithm of simtest-funnel, a port of LBNL Funnel.

The server reads the files itself, so raw samples never enter the model's context. It is stateless: every call names the files it reads, and no network connection is opened. describe_signals and compare_signals are read-only; plot_signals writes exactly the plot file it is given (and nothing at all without output_path), and only inside a workspace root declared by the client or an output directory configured at start-up (see Where plot files may be written). Transport: stdio.

Platform note: simtest-funnel is currently published to PyPI only as a Linux x86-64 / CPython 3.12 wheel, so uvx simtest-funnel-mcp works only there until cross-platform wheels are published. From a checkout of this repository it works wherever the Rust extension builds.

Tools

describe_signals(path, columns=None, max_columns=100, header_line=1)

Header line used, time column (how it was chosen and its kind: numeric or datetime, with or without time zone), row count, time start/end/span (on a date-time axis also as ISO 8601 strings and durations), sampling (uniform or not; min/median/max step), per-column min/max/range and data problems (non-numeric or empty cells, time not non-decreasing, time column without time zone, a preamble hint with the header_line to pass). Use it to choose columns and tolerances. At most max_columns columns and as many problems are listed; columns_total, columns_selected, columns_omitted and problems_omitted state the rest. columns filters by exact name or glob pattern (*, ?, [...]), e.g. ["*.port.signal"].

compare_signals(reference_path, test_path=None, ...)

Argument Default Meaning
test_path the reference file (with pairs only) Test CSV file; required unless pairs are given
columns all common columns Signal columns to compare: exact names or glob patterns (*, ?, [...], matched against the columns of both files)
pairs none [{"reference": .., "test": .., "label": ..}]: compare a reference column with a differently named test column (exact names; not together with columns)
header_line 1 Header line of the reference file (see CSV dialect)
test_header_line header_line Header line of the test file
tolerances one set, library default List of sets: optional unique label plus any of the six coefficients
column_tolerances none {row key: coefficients} overrides, applied per axis (the key is the column name, or a pair's label, else its test column)
x_range unbounded {"lo": .., "hi": ..} time window; finite bounds (on a date-time axis numbers are epoch seconds, or ISO 8601 strings), omit one for unbounded
max_intervals 5 Violation intervals listed per failing row (largest deviation first)
max_rows 100 Rows returned (errors, then failures, then passes); totals always cover all rows
include_snippet false Add a pytest file reproducing the returned rows (for CI), in the structured field snippet
time_limit 60 Deadline in seconds for the whole call, counted from its start, reading the files included (positive); see Time limit and cancellation

The result has one row per (column, tolerance set) with verdict (pass / fail / error), the library status code, points outside the tube, fractions of points and span outside, the worst deviation and, for failures only, the violation intervals. Missing columns, bad data and other per-column problems are reported in their rows instead of failing the call. Both structured content and a short text rendering are returned. Time values are never rounded in the structured content; the text prints them with enough digits to tell adjacent samples apart.

Column pairs. Without columns or pairs, every signal column present in both files is compared with the column of the same name. pairs compares differently named columns, from two files or from one (omit test_path; the file is then read once). One reference column may appear in several pairs. Names are exact and case-sensitive, units in names such as (°C) are part of the name; a name that is not found gives a row error suggesting close names (e.g. temperature_2m -> temperature_2m (°C)). A pair's row is keyed (column) by its label, else its test column; keys must be unique, and pair rows also carry reference_column and test_column. Without pairs a test_path is required (a file compared with itself would pass trivially).

A column passes when every test point inside the compared time range (x_range intersected with the reference time span) lies inside the tube and, within x_range, both files cover the same time span. If one file covers more time than the other within x_range, the row has verdict error with status MISSING_REFERENCE (test extends beyond the reference) or MISSING_TEST (the reverse), still reports points_compared / points_outside, and its problem text names both time spans and the exact x_range that compares the overlap.

plot_signals(reference_path, column, test_path=None, test_column=None, ...)

Draws ONE comparison - one signal column (or one reference column against a differently named test column), one tolerance set - and returns a PNG preview (800 x 450 px) inline as MCP image content, so the model can look at it. SVG is never returned inline (it would reach the model as text).

Argument Default Meaning
column required The one signal column to plot (exact name, no glob patterns); the reference column
test_path the reference file Test CSV file
test_column column Test column plotted against column, like one compare_signals pair (legend and title then name both)
header_line, test_header_line 1, header_line As in compare_signals
tolerance library default One tolerance set: optional label plus any of the six coefficients (one entry of compare_signals tolerances)
x_range unbounded As in compare_signals; also the time window shown (zoom)
output_path none Write the plot here: .svg (document) or .png (1600 x 900 px), inside a workspace root or a configured output directory. Omit for the preview only
overwrite false Replace output_path if it exists (refused otherwise)
max_intervals 5 Violation intervals listed in the result row (all are drawn)
time_limit 60 Deadline in seconds for the whole call (reading, comparison, rendering); when reached the call fails and nothing is written

The plot shows the reference (dark grey, dashed), the test (blue, solid), the tolerance tube (grey band between thin lower and upper bound lines) and every region where the test leaves the tube (red shading, with x markers on the violating test points). The title states the column, the verdict, the points outside and the non-zero resolved tolerances; the axes are labelled with the time column and the signal column; a legend sits below the axes. The background is white, so plots stay readable on light and dark pages (on a dark page they appear as a light card).

The comparison runs on the full data with exactly the semantics of compare_signals; the result carries the same summary row (plus the file written, the preview size and how many points were drawn), never sample values. For drawing, reference, test and both tube bounds are reduced to the min/max of 1000 time buckets (the test keeping the worst point of every violation interval), so the SVG stays fully vector and small (a few hundred kB at most for 200 000 samples). Where needed, the exact bound value at a drawn test point is added to the drawn bound, so a plot never contradicts the verdict: every drawn test point lies inside or outside the drawn tube exactly as the comparison judged it (violating points at least as far outside as their deviation), every violation interval is shaded (at least ~3 px wide, even for a single sample) and contains a marked test point, and in a passing plot no drawn test point lies outside the drawn tube. A column that cannot be compared (missing, bad data, differing time spans, non-monotonic time) is an error and nothing is written.

Output files: the file must lie inside a workspace root or a configured output directory (below); a relative output_path is taken relative to the first workspace root, else the first output directory; the directory must already exist (none is created); a symbolic link must point to a file with the same extension; an existing file is refused unless overwrite=true. These checks run before any CSV file is read. The file is written only after rendering succeeded, under a temporary name in the target directory, and moved into place (atomically replacing an existing file with overwrite=true; never replacing one without it) only if the call is still live, so a failed, cancelled or timed-out call writes nothing and no partial file ever appears. Because the checks run up to a minute before the write, the write itself does not trust the checked path: on Linux and macOS it works on a handle of the target directory, opened without following a symbolic link and verified to lie inside a workspace root or output directory immediately before the file is moved into place, and a symbolic link at the file name is replaced, never followed. (On Windows the directory is resolved and checked again immediately before the write, which narrows but cannot close that window.) The reported file.path is where the file was written. Output is deterministic: the same input gives byte-identical SVG and PNG files (with the same matplotlib version), so plots can be kept in a repository and diffed. SVG text is embedded as paths (bundled DejaVu Sans), so files look the same everywhere.

On a date-time time axis the x data stay epoch seconds (so the drawing agrees with the comparison exactly), the ticks are UTC-aligned dates and times (MM-DD hh:mm, the year on the first tick and at year changes), the x label ends in (UTC) or (no time zone), the subtitle shows the time tolerance as a duration (x ±PT3H) and the result's view carries lo_iso / hi_iso.

Plots are rendered with matplotlib (headless, imported only on the first plot_signals call, so server start-up is not slowed). It adds about 24 MB of wheels (~77 MB installed). matplotlib keeps a font cache in its cache directory (~/.cache/matplotlib, or $MPLCONFIGDIR), created on first use in an environment; that is the only other file touched.

Time limit and cancellation

Comparisons run in a worker thread without holding the Python interpreter lock, so the server keeps answering other requests while one runs. Comparisons usually take well under a second even for a million samples; a nearly noise-free signal with a large time tolerance (rtolx/atolx) can take much longer.

  • time_limit (seconds, default 60) is a deadline for the whole call, counted from its start: reading the CSV files counts against it (and, for plot_signals, rendering). Comparisons start only while time remains, and a running one stops when the limit is reached. Reading and rendering are not interrupted, so a call can overrun the limit by the time they take.
  • compare_signals then still succeeds: rows hold the comparisons that finished (server-detected problems such as missing columns included), not_completed lists the {column, tolerance_set} pairs that did not (capped at max_rows, the rest counted in not_completed_omitted), totals.not_completed counts them, time_limit_reached is true and a note suggests a larger time_limit, fewer columns or a narrower x_range. The text shows them on a NOT COMPLETED (time limit) line; a requested snippet covers the finished rows only. When everything finishes, none of these fields appear.
  • plot_signals is one comparison: when the limit is reached the call fails with an error naming the limit and nothing is written. The limit and cancellation are checked before rendering and again immediately before the file is moved into place.
  • When the client cancels a call (MCP notifications/cancelled, e.g. the user interrupts the agent), the running comparison stops within milliseconds and no further comparison of that call is started. A cancelled plot_signals call never writes its file, also when the cancellation arrives after the comparison, while rendering.

Pytest snippet

With include_snippet=true the result carries a self-contained pytest module (structured field snippet, sent once; the text rendering only points to it) that asserts the observed status of every returned row; rows omitted by max_rows are listed as a comment, and the snippet is capped at 64 kB. It embeds the server's CSV reader verbatim. Data paths under the first workspace root (else the server's working directory) are written relative to it and resolved at run time against $SIMTEST_FUNNEL_DATA_ROOT, defaulting to the current directory, so run pytest from the same place in a CI checkout. Files outside that base keep their absolute path, with a comment that they will not resolve elsewhere. The snippet reads each file with the header line the server used (REFERENCE_HEADER_LINE / TEST_HEADER_LINE, TEST = REFERENCE for one file), converts date-time time columns exactly as the server does, and each case (key, reference column, test column, tolerance set, tolerances, expected status) compares its own reference and test column; ISO x-range bounds are written as epoch seconds with the ISO form in a comment.

CSV dialect

Comma-separated, one header row (UTF-8, optional BOM). Lines whose first non-blank character is # and blank lines are ignored; a # anywhere else is data (e.g. a column a#1). A data row with more fields than the header is an error naming the row and line; a trailing delimiter on every line, header included, is accepted (the empty last column is dropped). Short rows count as empty cells. The time column is the first column named time (case-insensitive), otherwise the first column; the choice is echoed back. Other columns whose name differs from time only by case are ordinary signal columns.

Header line. header_line (1-based physical file line, default 1) skips the lines before it unread; the header is the first non-blank, non-comment line at or after it, so the default is the first non-comment line, as always. Data row line numbers in errors stay physical file lines. The header line is never detected automatically. When a read fails, or succeeds but looks wrong (the header has a different field count than a later header-like line, or the time column has bad cells), and the top of the file looks like a preamble (a blank line followed by a line without numbers whose next line looks like data with the same field count), the error or a problem says so and suggests that line, e.g. pass header_line=4. The hint never changes what is read.

Date-time time column. A time column whose non-empty cells are all ISO 8601 date-times (YYYY-MM-DD, optionally T or a space and hh:mm, optional seconds and fraction, optional Z or an offset +hh:mm, +hhmm or +hh) is read as seconds since 1970-01-01 UTC, so a file and its copy with epoch-second times give identical results. Date-only cells are midnight. Hours run 00-23, invalid dates are not date-times, and only upper case T and Z are accepted. Other formats (01/02/2026, Excel serial dates) are not recognised; such a column is non-numeric. A cell without offset is read as UTC and describe_signals reports that the column has no time zone; offsets are converted to UTC. Reference and test time columns must be of the same kind: both numeric, both without time zone, or both with offsets (otherwise the call fails explaining how to fix it); a column mixing cells with and without offset is a time-column problem. Only the time column is converted; date-times in signal columns are non-numeric.

On a date-time axis x tolerances and numeric x_range bounds are seconds (atolx = 10800 is ±3 h), x_range bounds may also be ISO strings (with a time zone exactly when the time columns have one), a non-zero ltolx is refused (it would scale with ~1.8e9 s), every tolerance set with a non-zero time half-width echoes it as time_tolerance: {"seconds": 10800, "duration": "PT3H"} (also from rtolx), and every time in the results keeps its number and gains an ISO 8601 sibling (time_start_iso, lo_iso, x_iso, start_x_iso, ...; UTC with Z for offset axes, without suffix for zone-less ones). The text rendering prints ISO times and durations.

Example: an Open-Meteo Previous Runs CSV starts with a metadata line, a values line and a blank line, then the header time,temperature_2m (°C),temperature_2m_previous_day1 (°C),... with times such as 2026-11-20T00:00. "Was the forecast made 1, 3 and 5 days ahead within 2 °C and 3 hours?":

{
  "reference_path": "/data/stockholm.csv",
  "header_line": 4,
  "pairs": [
    {"reference": "temperature_2m (°C)", "test": "temperature_2m_previous_day1 (°C)", "label": "day1"},
    {"reference": "temperature_2m (°C)", "test": "temperature_2m_previous_day3 (°C)", "label": "day3"},
    {"reference": "temperature_2m (°C)", "test": "temperature_2m_previous_day5 (°C)", "label": "day5"}
  ],
  "tolerances": [{"label": "2C_3h", "atoly": 2, "atolx": 10800}],
  "x_range": {"lo": "2026-11-06T00:00"}
}

Tolerances

Six coefficients, x = time axis, y = signal value. At each reference sample the tube half-widths are

half_x = max(atolx, rtolx * time_span_ref, ltolx * |t|)
half_y = max(atoly, rtoly * value_range_ref, ltoly * |y_ref|)
  • atol*: absolute (time units / signal units; seconds on a date-time axis)
  • rtol*: fraction of the reference time span / value range
  • ltol*: fraction of the local |t| / |y_ref|

If a half-width comes out effectively zero (< 1e-10), e.g. rtoly alone on a constant reference (value range 0), it falls back to rtol * max|reference value| on that axis (when rtol > 0), and finally to 1e-10. For constant or near-constant signals give atoly explicitly.

Omitted coefficients are resolved by the library, per axis: an axis with no coefficient given gets its default — on the x axis all 0 (no time tolerance), on the y axis rtoly = 0.002; an axis with any coefficient given uses 0 for its others; an explicit 0 counts as given. The six resolved values are always echoed back.

Tolerance in x widens the tube along time, so a test signal shifted or delayed by up to half_x still passes; steep edges and small timing offsets then do not cause false failures. There is no tolerance in x unless you give one: with x tolerance 0 the x half-width is the 1e-10 floor, so each test point is checked only against the y band around the reference at the same time and a slightly delayed steep edge fails. Prefer atolx (time units): rtolx is a fraction of the whole time span and grows with the length of the record (rtolx = 0.002 allows 43 minutes on 15 days of data). When a row fails and no x coefficient was given for it, compare_signals and plot_signals add a note:

1 failing row(s) had no x (time) tolerance: none was given and the default is 0.
If the test may be shifted or delayed in time against the reference (e.g. at
steep edges), consider an x tolerance such as atolx (time units)

"1 % in y, 0.5 s in x" is {"rtoly": 0.01, "atolx": 0.5} (or ltoly for 1 % of the local value).

Registering the server

Claude Code

Once published to PyPI:

claude mcp add simtest-funnel -- uvx simtest-funnel-mcp

From a checkout of this repository (use --scope user to make it available in every project):

claude mcp add simtest-funnel -- uv run --directory /path/to/simtest-funnel --quiet simtest-funnel-mcp

Inside this repository nothing needs to be registered: the checked-in .mcp.json starts the server with uv run from the workspace (Claude Code asks for approval the first time).

Claude Desktop

Add to claude_desktop_config.json (Settings → Developer → Edit Config):

{
  "mcpServers": {
    "simtest-funnel": {
      "command": "uvx",
      "args": ["simtest-funnel-mcp"]
    }
  }
}

or, from a checkout:

{
  "mcpServers": {
    "simtest-funnel": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/simtest-funnel", "--quiet", "simtest-funnel-mcp"]
    }
  }
}

Use absolute paths in tool calls. When the client declares workspace roots, the server refuses paths outside them and resolves relative paths against the first root. Only local file:// roots (empty host or localhost) are used; other roots are ignored with a note in the result.

Where plot files may be written

plot_signals writes a file only

  1. inside a workspace root declared by the client (Claude Code declares the project directory), or
  2. inside an output directory configured when the server is started: --output-dir DIR (repeatable) and/or the environment variable SIMTEST_FUNNEL_MCP_OUTPUT_DIR (several directories separated by :, ; on Windows).

When both exist, a path inside either is allowed. With neither (e.g. a client that declares no roots and no configured directory), every output_path is refused with an error saying how to enable writing; plot_signals without output_path still returns the inline preview. The server's working directory is never used as a fallback. Each configured directory must already exist (use an absolute path; ~ is expanded); the server refuses to start otherwise, with a message naming the entry.

Claude Code needs nothing for plots inside the project. To also allow a directory outside it, add the option to the command:

claude mcp add simtest-funnel -- uvx simtest-funnel-mcp --output-dir /home/me/plots

or, in a project's .mcp.json:

{
  "mcpServers": {
    "simtest-funnel": {
      "type": "stdio",
      "command": "uvx",
      "args": ["simtest-funnel-mcp", "--output-dir", "/home/me/plots"]
    }
  }
}

Clients that declare no workspace roots (Claude Desktop, at the time of writing) need an output directory to save plots (claude_desktop_config.json):

{
  "mcpServers": {
    "simtest-funnel": {
      "command": "uvx",
      "args": ["simtest-funnel-mcp", "--output-dir", "/Users/me/Documents/plots"]
    }
  }
}

or with the environment variable:

{
  "mcpServers": {
    "simtest-funnel": {
      "command": "uvx",
      "args": ["simtest-funnel-mcp"],
      "env": { "SIMTEST_FUNNEL_MCP_OUTPUT_DIR": "/Users/me/Documents/plots" }
    }
  }
}

From a checkout, append the option after the command in the same way: "args": ["run", "--directory", "/path/to/simtest-funnel", "--quiet", "simtest-funnel-mcp", "--output-dir", "/Users/me/Documents/plots"].

Development

make build          # builds the native simtest-funnel module
make test-python    # includes python/simtest-funnel-mcp/tests (incl. stdio end-to-end)
make lint-python    # mypy --strict
uv run simtest-funnel-mcp   # start the server on stdio (--help for options)

Metadata

Release files for simtest-funnel-mcp 1.0.0b17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simtest-funnel-mcp 1.0.0b17
File Size Uploaded Provenance Actions
simtest_funnel_mcp-1.0.0b17.tar.gz 101.6 kB Without provenance Details for simtest_funnel_mcp-1.0.0b17.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simtest-funnel-mcp 1.0.0b17
File Interpreter ABI Platform Actions
simtest_funnel_mcp-1.0.0b17-py3-none-any.whl Python 3 none any Details for simtest_funnel_mcp-1.0.0b17-py3-none-any.whl

Total release size: 170.3 kB

Release files / simtest_funnel_mcp-1.0.0b17.tar.gz

Download URL simtest_funnel_mcp-1.0.0b17.tar.gz
Size 101.6 kB
Tags Source
SHA-256 checksum
How to use checksums
7e14a5df97f1fd0b23c79a7012e65121cc67c0a998b891a61dc1c29fdd221596
BLAKE2b-256 checksum
How to use checksums
f3b6a256293346fafb4a361b0676e381ef2f3d8cdab1c4b6d4c72978e88f5a2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Release files / simtest_funnel_mcp-1.0.0b17-py3-none-any.whl

Download URL simtest_funnel_mcp-1.0.0b17-py3-none-any.whl
Size 68.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49782d3e9ef21612ff199e164bf8f69ac125a22ad4e0b233262adff5565a958d
BLAKE2b-256 checksum
How to use checksums
cc5bad026197569f9858c9578d6dc0dce3759a01161adac3f829ddedf137acea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.16

Security for simtest-funnel-mcp 1.0.0b17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page