Skip to content

feat: bundled zero-dependency MCP server + README tagline - #24

Closed
adiled wants to merge 14 commits into
devfrom
feat/mcp-server
Closed

adiled wants to merge 14 commits into
devfrom
feat/mcp-server

Conversation

@adiled

@adiled adiled commented Aug 27, 2026

Copy link
Copy Markdown
Owner

What

Adds a bundled, zero-dependency MCP server to the package, plus a README tagline update.

MCP server (ohlc-resample-mcp bin)

  • New ohlc-resample-mcp binary ships inside this same package — install ohlc-resample and get the server for free, no second publish.
  • A thin adapter over the package's own CLI: each tool call builds an argv array and runs runCli in-process with injected streams. It has no resampling/parsing/formatting logic of its own, so every future CLI feature (formats, streaming, Parquet, --map) is inherited with zero maintenance.
  • No @modelcontextprotocol/sdk dependency — MCP is plain JSON-RPC 2.0 over stdio (initialize, tools/list, tools/call, ping), hand-rolled directly. Runtime deps stay just mri + hyparquet.
  • Single file-path tool resample_ohlcv_file: input_path (csv/json/jsonl/ndjson/parquet), base_timeframe, new_timeframe, format, shape, optional map (e.g. CCXT timestamp/amount), optional output_path. File-path-based, so the LLM pays tokens for intent, not payload.

Bug fix

  • Streaming CSV → CSV output previously failed with shaped.join is not a function: IncrementalWriter rendered object-shaped candles as CSV rows without converting to the 6-tuple shape. CSV rows are now always written in array shape regardless of the requested JSON shape.

Tests / docs

  • 11 new MCP tests (exercising dispatch directly) — 111 total passing.
  • README: tagline changed to "Transform, resample, and stream market data at any scale." and a new "MCP server (AI agents)" section.

Why

MCP is the interface for AI agents to drive market-data analysis. The server is agent-facing and file-path-based, and bundling it keeps a single package/release with zero extra maintenance.

Notes

This PR is based on dev and includes the CLI/streaming/parquet/map work the MCP server depends on.

github-actions Bot and others added 14 commits August 25, 2026 23:16
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Existing functions accept sync iterables/generators (+ Float64Array for OHLCV)
- Add async variants resampleOhlcvAsync / resampleTicksByTimeAsync / resampleTicksByCountAsync with out-of-order healing (outOfOrderMs)
- CLI: stream CSV/JSONL/NDJSON files line-by-line, incremental output, new jsonl format
- Changeset (minor), README docs. Closes #9.
- New src/map.ts: OhlcvMap/TickMap (Record form: canonical field -> source
  key; function form: (record) => IOHLCV/TradeTick) + mapToOhlcv/mapToTick +
  async-iterable wrappers. Exported from index.
- Library: resampleOhlcvAsync / resampleTicksByTimeAsync /
  resampleTicksByCountAsync gain options.map, applied to Parquet rows and
  object-shaped AsyncIterable items (tuples/Float64Array unaffected).
- Parquet reader now reads exact canonical columns only; any other layout
  requires map. Removes the OHLCV/TICK alias tables and resolveColumn
  guessing (per user: aliasing can go now that map exists).
- CLI: --map field=sourceKey flag (Record form) threads into CSV header
  resolution, JSON/JSONL object key remap, JSON array buffer path, and the
  Parquet branch. With --map a CSV first line is always the header.
- Tests: parquet custom-name Record/function map + partial-map error + alias
  fixture now requires map; library CCXT-style Record/function map on object
  streams + tuple pass-through; CLI --map on CSV/JSON/parquet/pipe + invalid
  field. Fixtures ohlcv_custom.parquet, ticks_custom.parquet added.
- README + changeset updated: map option (Record + function), CLI --map,
  aliasing removed.
Install footprint: 461 kB -> ~145 kB. The seven lodash helpers used
(isPlainObject, sum, max, min, groupBy, sortBy, chunk) were the entire
315 kB lodash package as a runtime dep; each is now a native inline
implementation (stable Array.sort, plain-object grouping, loop min/max/sum,
slice-based chunking). Runtime deps are now commander + hyparquet only —
we install only what we build.
… config-mutation bug; clean unknown-option errors
* feat: streaming and large-data support

- Existing functions accept sync iterables/generators (+ Float64Array for OHLCV)
- Add async variants resampleOhlcvAsync / resampleTicksByTimeAsync / resampleTicksByCountAsync with out-of-order healing (outOfOrderMs)
- CLI: stream CSV/JSONL/NDJSON files line-by-line, incremental output, new jsonl format
- Changeset (minor), README docs. Closes #9.

* feat: parquet file input (async only) and ESM-only package

* chore: keep require() working via CJS wrapper; downgrade to minor

* Add per-record map option; drop parquet alias guessing

- New src/map.ts: OhlcvMap/TickMap (Record form: canonical field -> source
  key; function form: (record) => IOHLCV/TradeTick) + mapToOhlcv/mapToTick +
  async-iterable wrappers. Exported from index.
- Library: resampleOhlcvAsync / resampleTicksByTimeAsync /
  resampleTicksByCountAsync gain options.map, applied to Parquet rows and
  object-shaped AsyncIterable items (tuples/Float64Array unaffected).
- Parquet reader now reads exact canonical columns only; any other layout
  requires map. Removes the OHLCV/TICK alias tables and resolveColumn
  guessing (per user: aliasing can go now that map exists).
- CLI: --map field=sourceKey flag (Record form) threads into CSV header
  resolution, JSON/JSONL object key remap, JSON array buffer path, and the
  Parquet branch. With --map a CSV first line is always the header.
- Tests: parquet custom-name Record/function map + partial-map error + alias
  fixture now requires map; library CCXT-style Record/function map on object
  streams + tuple pass-through; CLI --map on CSV/JSON/parquet/pipe + invalid
  field. Fixtures ohlcv_custom.parquet, ticks_custom.parquet added.
- README + changeset updated: map option (Record + function), CLI --map,
  aliasing removed.

* chore: exclude .js.map sourcemaps from published package (16 files, 23.8kB)

* perf(deps): drop lodash dependency; implement 7 helpers natively

Install footprint: 461 kB -> ~145 kB. The seven lodash helpers used
(isPlainObject, sum, max, min, groupBy, sortBy, chunk) were the entire
315 kB lodash package as a runtime dep; each is now a native inline
implementation (stable Array.sort, plain-object grouping, loop min/max/sum,
slice-based chunking). Runtime deps are now commander + hyparquet only —
we install only what we build.

* perf(deps): replace commander with mri (tiny 4kB arg parser); fix mri config-mutation bug; clean unknown-option errors
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* docs: rewrite README as end-user documentation

Drag the README back to an end-user pitch: remove coder narration (module
format internals, dependency/roadmap notes) and present the tool in plain
language for financial-data users and AI readers. Removes em dashes.
Add a patch changeset.

* docs: add npx quick-start option and fold install one-liner into quick start

* docs: note arbitrary input schemas via map in supported formats

* docs: reframe map as feed-data-as-is; condense README and cut repetition

* docs: note Parquet pipe input is file-only
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Thin stdio JSON-RPC adapter over the package's own CLI (runCli in-process);
no @modelcontextprotocol/sdk dependency. Single file-path tool
resample_ohlcv_file. Fix streaming CSV->CSV output bug (IncrementalWriter
now always writes array-shape rows). Update README tagline.
@adiled
adiled changed the base branch from main to dev August 27, 2026 18:08
@adiled adiled closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant