Skip to main content
Glama

mcp-csv-server

An MCP server that lets an AI assistant preview, query, aggregate, and convert CSV/TSV data — safely, with no API key.

CI License: MIT Node MCP

Give Claude (or any MCP client) the ability to actually work with spreadsheets: filter rows, sum/average/group columns, and turn CSV into JSON — instead of eyeballing a pasted table and guessing. Pure TypeScript, dependency-light, and runnable with zero credentials, so a reviewer can try it in one command.

日本語の概要

AIアシスタント(Claude等)に「CSV/業務データを正しく扱う力」を与えるMCPサーバです。表をそのまま 読ませて推測させるのではなく、行の絞り込み・列の集計(合計/平均/最大最小)・グループ集計・JSON変換を ツールとして提供します。APIキー不要で動くので、その場で試せます。

  • 壊れにくいCSVパーサ:引用符・エスケープ("")・引用符内のカンマ/改行に対応(素朴なsplit(',')が壊れる実データを正しく処理)。

  • 型付きエラー+対処ヒント[UNKNOWN_COLUMN] Unknown column "x". Hint: Available columns: ... のように、AIにも人にも原因と対処が分かる。

  • 責務分離csv/(パース・クエリの純粋ロジック)/ tools/(MCPツール定義)/ server.ts(薄い配線)。

  • テスト:パーサ・クエリ・ツールを19本のユニットテストで検証(全エラー経路含む)。CI緑。

Related MCP server: mix_server

Tools

Tool

What it does

Key inputs

csv_preview

Columns, total row count, and a sample

csv, delimiter?, limit?

csv_query

Filter / select / aggregate / group / limit

csv, where?, select?, aggregate?, groupBy?, limit?

csv_to_json

Convert CSV/TSV to JSON records

csv, delimiter?, limit?

aggregate supports count, sum, avg, min, max; where ops are eq, ne, gt, gte, lt, lte, contains (ANDed together). Numbers tolerate thousands separators ("2,000"2000).

Install & run

git clone https://github.com/takuyahoritacromtech/mcp-csv-server.git
cd mcp-csv-server
npm install
npm run build

Use with Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "csv": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-csv-server/dist/index.js"]
    }
  }
}

Restart the client; the csv_preview, csv_query, and csv_to_json tools appear.

Quick smoke test (no client needed)

printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"smoke","version":"0"}}}' \
  | node dist/index.js
# → {"result":{...,"serverInfo":{"name":"mcp-csv-server",...}},"jsonrpc":"2.0","id":1}

Example: "total sales by region"

Given a csv_query call with:

{ "csv": "region,amount\nEast,1000\nWest,2000\nEast,500",
  "groupBy": "region",
  "aggregate": { "fn": "sum", "column": "amount" } }

the tool returns:

{ "columns": ["region", "sum_amount"],
  "rows": [{ "region": "East", "sum_amount": 1500 }, { "region": "West", "sum_amount": 2000 }],
  "rowCount": 2 }

Design notes (the "why")

  • A real CSV parser, not split(',') — a small RFC 4180 state machine handles quoting, escaped quotes, and embedded delimiters/newlines. This is where naive tools silently corrupt data.

  • Pure core, thin MCP shell — all logic lives in csv/ and tools/ as pure functions, so it is unit-tested without the protocol. server.ts only maps tools to the SDK and converts CsvError into clean tool errors.

  • Typed errors with hints — every failure (UNKNOWN_COLUMN, NON_NUMERIC_COLUMN, CSV_PARSE_ERROR, …) is actionable from the message alone.

  • Validated inputs — every tool input is a Zod schema, so malformed calls are rejected before any work happens.

Testing

npm run check   # typecheck + lint + test

19 unit tests cover CSV parsing (quoting, TSV, CRLF, ragged rows, empty, unterminated quotes), the query engine (filter/select/aggregate/group/limit + every error code), and the three tools.

License

MIT © Takuya Horita

Available Tools

3 tools
csv_previewPreview CSVA

Parse CSV/TSV text and return its columns, total row count, and a few sample rows.

ParametersJSON Schema
NameRequiredDescriptionDefault
csvYesRaw CSV/TSV text, including a header row.
delimiterNoField delimiter; defaults to ",".
limitNoSample rows to return (default 5).

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations, the description carries full burden. It accurately describes the main behavior (parsing, returning columns/row count/sample rows). It does not mention error handling or edge cases but is adequate for a simple preview tool without contradictions.

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?

Single sentence that front-loads the purpose and is entirely focused. No unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with no output schema, the description explains return values (columns, row count, sample rows) adequately. It could benefit from mentioning error handling, but overall it is complete enough for a preview tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing baseline 3. The description reinforces the overall purpose but adds minimal parameter-specific meaning beyond what the schema already documents (e.g., 'a few sample rows' aligns with limit parameter).

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?

The description clearly states it parses CSV/TSV and returns columns, total row count, and sample rows, which is a specific verb+resource. It distinguishes itself from siblings (csv_query, csv_to_json) by focusing on previewing structure and sample data.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternative siblings. The description implies usage for previewing but does not provide explicit when-to-use or when-not-to-use instructions.

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

csv_queryQuery CSVA

Filter, select, aggregate (count/sum/avg/min/max), group, and limit CSV/TSV rows declaratively.

ParametersJSON Schema
NameRequiredDescriptionDefault
csvYes
delimiterNo
selectNoColumns to return (default all).
whereNoRow filters, ANDed together.
groupByNoGroup rows by this column (with aggregate).
aggregateNoAggregate, e.g. {fn:"sum",column:"amount"}.
limitNo

TDQS

A3.5/5.0
Behavior2/5

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

No annotations are present, so the description carries the full burden. It lacks disclosure of behavioral traits such as read-only nature, side effects, or resource constraints beyond the schema's limit field. The description only lists operations.

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?

A single sentence efficiently enumerates all supported operations without redundancy. Every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 parameters, nested objects, no output schema), the description adequately outlines core capabilities but lacks details on default delimiter, ordering, or usage examples. Gaps remain for a fully informed invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 57%, with descriptions for select, where, groupBy, and aggregate. The tool description adds the list of aggregate functions but does not add meaning for undocumented parameters like csv and delimiter. Overall, the description provides marginal additional value.

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?

The description clearly states the tool's ability to filter, select, aggregate (with specific functions listed), group, and limit CSV/TSV rows. This distinguishes it from siblings like csv_preview and csv_to_json, which have different purposes.

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

Usage Guidelines3/5

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

The description implies usage for declarative queries but does not explicitly state when to use it over alternatives. No when-not or exclusion criteria are provided.

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

csv_to_jsonCSV to JSONB

Convert CSV/TSV text into an array of JSON records.

ParametersJSON Schema
NameRequiredDescriptionDefault
csvYes
delimiterNo
limitNo

TDQS

B3.2/5.0
Behavior2/5

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

No annotations provided, so description carries full burden. Only states 'convert' without disclosing behavior like error handling, encoding, or how headers are treated. Minimal beyond the basic action.

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

Conciseness4/5

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

One sentence, ten words, front-loaded with key info. Efficient but could include a bit more detail without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple conversion tool without output schema or annotations, description lacks essential details like assuming first row as headers, output structure, or validation. Sibling tools don't clarify context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but description adds no meaning beyond schema. Parameters like delimiter and limit are not explained; agent must rely on names. Does not compensate for lack of schema descriptions.

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 'Convert CSV/TSV text into an array of JSON records,' specifying the verb, resource, and output format. Distinguishes from siblings csv_preview and csv_query.

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

Usage Guidelines3/5

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

Implied usage for converting CSV/TSV to JSON, but no explicit guidance on when not to use or how to choose between siblings. No when-to-use vs when-not-to-use.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.0
    • First observedcsv_preview
    • First observedcsv_query
    • First observedcsv_to_json

TDQS

A3.8/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a distinct purpose: preview shows structure, query filters/aggregates, to_json converts format. No overlap or ambiguity.

Naming Consistency5/5

All tools follow the consistent pattern 'csv_' + verb: csv_preview, csv_query, csv_to_json. Naming is uniform and predictable.

Tool Count5/5

Three tools cover the essential CSV operations (preview, query, convert) without being too sparse or excessive. Well-scoped for the domain.

Completeness4/5

Covers core operations but lacks write/update or other format conversions (e.g., to JSON is included, but to other formats like XML is missing). Minor gaps exist.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    AI-first CSV analysis tool that enables AI agents to analyze, query, and audit large CSV files directly within conversations, turning raw data into actionable insights.
    2
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with local CSV and Parquet data files through natural language queries, facilitating tasks like summarizing datasets or retrieving specific information.
    5
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables querying Excel and CSV files using SQL via natural language, allowing AI assistants to analyze data without manual SQL writing.
    1
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI assistants to query tabular data (CSV/TSV) using natural language with cell-level citations, supporting multi-tenant workspaces, access control, and semantic search.
    27
    MIT