Skip to main content

MCP server exposing NetSuite saved search exports as a structured query interface for Claude

Project description

netsuite-saved-search-mcp

NetSuite saved search exports look like Excel files but are actually XML SpreadsheetML with a .xls extension — Excel opens them, pandas trips on them, and most teams writing Claude integrations against NetSuite end up rebuilding the same parser by hand. This MCP server exposes those exports as a structured query interface for Claude: discover files, inspect columns, filter and aggregate rows, categorize by memo keywords, surface anomalies. Seven tools wrap a parser that handles the format's real quirks — entity-encoded text, empty cells flagged with ss:Index, drifting column layouts between saved searches, DateTime cells that won't parse. The parser runs in lxml's recovery mode and reports broken cells as structured warnings rather than crashing on them.

Quick start

uvx netsuite-saved-search-mcp           # or: pip install netsuite-saved-search-mcp
export NSMCP_ROOT=/path/to/your/exports

Add to Claude Desktop's config (full version in examples/claude_desktop_config.json):

{
  "mcpServers": {
    "netsuite-saved-search": {
      "command": "uvx",
      "args": ["netsuite-saved-search-mcp"],
      "env": {"NSMCP_ROOT": "/path/to/your/exports"}
    }
  }
}

Then any tool call lands directly:

{
  "tool": "query_export",
  "arguments": {
    "file_path": "Q3_GL.xls",
    "filters": [{"op": "eq", "column": "Account", "value": "4000"}]
  }
}

Why this exists

NetSuite saved search exports use XML SpreadsheetML, not Excel binary, despite the .xls extension. Column layouts drift between saved searches, so code that hardcodes column letters breaks on the next export. Empty cells are silently omitted from each row with ss:Index attributes marking where they were, which trips naive sequential parsers. Every finance team using Claude with NetSuite ends up rebuilding the same parser. This server solves it once.

Tools

Tool Description Key parameters
list_exports Scan a directory for .xls files; return one summary per file with row counts, header counts, warning counts, and detected date range. directory
get_headers Return column headers, their spreadsheet column letters, and the 0-indexed header row. file_path
query_export Filter rows by a list of predicates (AND-combined), optionally project to a subset of columns, cap results. file_path, filters, columns?, limit?
aggregate_export Group rows by one or more columns; compute sum/count/avg/min/max per group. file_path, group_by, measures
categorize_by_memo Tag every row with a _category derived from case-insensitive keyword rules across one or more memo columns. file_path, memo_columns, rules
detect_anomalies Three checks: zero-activity periods (HIGH), ratio anomalies (MEDIUM), document-count variance (MEDIUM). file_path, account_column, amount_column, period_column
get_parse_warnings Return parse warnings (phantom_column, bad_datetime, encoding_recovery, empty_row_skipped) captured during the most recent parse. file_path

Predicates are a discriminated union keyed on op. Example query with two predicates:

{
  "file_path": "deferred_commissions_2024.xls",
  "filters": [
    {"op": "eq", "column": "Account", "value": "1321"},
    {"op": "date_range", "column": "Date", "start": "2024-01-01", "end": "2024-12-31"}
  ],
  "columns": ["Date", "Document Number", "Amount", "Memo (line)"],
  "limit": 100
}

Measures for aggregate_export:

[{"column": "Amount", "op": "sum", "alias": "total"}, {"column": "Document Number", "op": "count"}]

Example walkthrough

See examples/walkthrough.md for an end-to-end example using the included sanitized fixtures.

Limitations

  • Only handles saved search exports, not raw transaction-level XML from SuiteScript or RESTlets.
  • All-string exports with no typed columns may misidentify the header row; an explicit header_row override is planned.
  • Memo categorization uses case-insensitive substring matching against US-English keywords. No stemming, no fuzzy matching.
  • Not optimized for exports larger than 100k rows. The cache holds parsed NetSuiteExport instances in memory keyed by (path, mtime).
  • v0.1. The MCP tool schemas and the parser's Predicate/Measure models may change before v1.0.

Contributing

Issues and PRs welcome. Run uv run pytest, uv run mypy src, and uv run ruff check src tests before submitting; all three should be clean. Commits follow Conventional Commits. New tools require a Pydantic response model, a happy-path test against the included GL fixture, a failure-path test (missing file or unknown column), and an entry in the table above.

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netsuite_saved_search_mcp-0.1.0.tar.gz (100.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netsuite_saved_search_mcp-0.1.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file netsuite_saved_search_mcp-0.1.0.tar.gz.

File metadata

File hashes

Hashes for netsuite_saved_search_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d2d36607607666e1af05d2fea1714a0476d59a9d3e5854dc4e7d30e59ca88e02
MD5 c52adc93f446331da8266d4c75c65d55
BLAKE2b-256 d47b2eb426e84cd2adafe7bb495348661b1de8ca682a94adda9ff36fc37045f2

See more details on using hashes here.

File details

Details for the file netsuite_saved_search_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for netsuite_saved_search_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb751e4d6bf5d953aea69691ae2df34d78c58df09f794f631e33fce90e1cc7f
MD5 f15d38ec6ec67c042fad838b29ce10c3
BLAKE2b-256 f8f5f4e8b242959bfb35962425531da5fbd045dce7b1dec095b05b5c83a3abd3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page