Skip to main content
Glama
Gakuji3

csv-analyzer-mcp

by Gakuji3

CSV Analyzer MCP

Model Context Protocol (MCP) を使って CSV ファイルを分析し、統計情報を提供するサーバーであり、AI アシスタントツールとしても利用できます。

  • LLM が発見・呼び出し可能なツールを公開

  • ユーザー入力(CSV ファイルパス)を処理

  • 構造化された結果を返す

  • Claude for Desktop および他の MCP 互換クライアントと統合

機能

  • CSV 分析: 統計情報の計算と分析

  • サマリー取得: CSV 構造の JSON 形式サマリー

  • 型アノテーション: Python 3.12+ 対応

  • ロギング: stderr へのログ出力

  • エラーハンドリング: ファイル I/O と入力検証

  • MCP 互換性: 複数の MCP クライアントに対応

Related MCP server: mcp-csv-database

クイックスタート

前提条件

インストール

# プロジェクトディレクトリに移動
cd csv-analyzer-mcp

# 仮想環境を作成して依存パッケージをインストール
uv venv
source .venv/bin/activate  # Windows の場合: .venv\Scripts\activate

# 開発モードでパッケージをインストール
uv sync

サーバーの実行

# uv 経由(開発時に推奨)
uv run csv-analyzer-mcp

# または、venv をアクティベート後
python -m csv_analyzer_mcp.main

サーバーが起動し、MCP クライアント接続を STDIO でリッスンします。

Claude for Desktop との統合

このMCPサーバーを Claude for Desktop と一緒に使用するには:

  1. Claude設定ファイルを探します:

    # macOS/Linux
    code ~/Library/Application\ Support/Claude/claude_desktop_config.json
    
    # Windows
    code $env:AppData\Claude\claude_desktop_config.json
  2. サーバー設定を追加します:

    {
      "mcpServers": {
        "csv-analyzer": {
          "command": "uv",
          "args": [
            "--directory",
            "/ABSOLUTE/PATH/TO/csv-analyzer-mcp",
            "run",
            "csv-analyzer-mcp"
          ]
        }
      }
    }
  3. /ABSOLUTE/PATH/TO/csv-analyzer-mcp を実際のパスに置き換えます(例:/Users/username/python/csv-analyzer-mcp

  4. Claude for Desktop を再起動します

  5. Claude で、コネクター メニューに「csv-analyzer」サーバーが利用可能として表示されるようになります。以下でテストできます:

    • 「このCSVを分析して: /path/to/your/file.csv」

    • 「data.csvの構造をまとめて」

ツール

1. analyze_csv

CSV ファイルの包括的な統計分析

入力:

  • file_path (文字列): CSV ファイルへのパス

出力: 以下を含むフォーマット済みレポート:

  • 行数と列数

  • 列名とデータ型

  • 列ごとの統計(数値列: 最小値、最大値、平均値、標準偏差、中央値、文字列列: ユニーク値数)

  • 全体サマリー(数値列、欠損値、メモリ使用量)

例:

ユーザー: 「/Users/john/data/sales.csv を分析して」

Claude: [analyze_csv ツールを呼び出し]

出力:
======================================================================
CSV 分析レポート
======================================================================

基本情報
  行数:          1000
  列数:          5
  列名:          date, product, amount, region, discount

列の統計情報
  ...

2. get_csv_summary

CSV 構造の JSON フォーマット済みクイックサマリー

入力:

  • file_path (文字列): CSV ファイルへのパス

出力: 以下を含む JSON オブジェクト:

  • rows: 行数

  • columns: 列数

  • column_names: すべての列名のリスト

  • column_types: 列型の辞書

  • numeric_columns: 数値列のリスト

  • total_missing_values: 欠損値の数

例:

{
  "rows": 1000,
  "columns": 5,
  "column_names": ["date", "product", "amount", "region", "discount"],
  "column_types": {
    "date": "object",
    "product": "object",
    "amount": "float64",
    "region": "object",
    "discount": "int64"
  },
  "numeric_columns": ["amount", "discount"],
  "total_missing_values": 12
}

アーキテクチャ

csv-analyzer-mcp/
├── pyproject.toml              # プロジェクトメタデータ、依存関係、エントリポイント
├── README.md                   # このファイル
├── .gitignore                  # Git無視パターン
│
├── src/csv_analyzer_mcp/
│   ├── __init__.py            # パッケージ初期化とバージョン
│   ├── main.py                # サーバーエントリポイントと STDIO トランスポート設定
│   ├── tools.py               # MCP ツール定義(@mcp.tool デコレータ)
│   ├── utils.py               # ヘルパー関数(CSV読込、統計処理)
│   └── py.typed               # PEP 561 型ヒントマーカー
│
├── examples/
│   ├── sample.csv             # テスト用サンプルデータ
│   └── example_usage.md       # 使用例
│
└── tests/ (オプション)
    ├── test_utils.py
    └── test_tools.py

モジュール概要

  • main.py: FastMCP サーバーを初期化し、STDIO トランスポートで実行します。これは MCP サーバーのエントリポイントです。

  • tools.py: @mcp.tool() デコレータを使用して MCP ツールを定義します。各関数は LLM クライアントが利用可能なツールになります。

  • utils.py: ビジネスロジックを含みます:

    • read_csv_file(): エラー処理付きで CSV を安全に読み込み

    • calculate_statistics(): pandas を使用して統計を計算

    • format_statistics_report(): 出力を人間が読みやすいテキストにフォーマット

動作原理

┌─────────────┐
│ Claude for  │
│ Desktop     │
└──────┬──────┘
       │ (JSON-RPC over STDIO)
       │
   ┌───▼────────────────────┐
   │ MCP サーバープロセス   │
   │ (csv-analyzer-mcp)     │
   └───┬────────────────────┘
       │
   ┌───▼────────────────────┐
   │ tools.py               │
   │ - analyze_csv          │
   │ - get_csv_summary      │
   └───┬────────────────────┘
       │
   ┌───▼────────────────────┐
   │ utils.py               │
   │ - read_csv_file()      │
   │ - calculate_statistics │
   │ - format_report()      │
   └────────────────────────┘

フロー:

  1. Claude がCSV分析に関する質問をします

  2. Claude のクライアントが JSON-RPC リクエストをこの MCP サーバーに送信します

  3. tools.py モジュールがリクエストを受け取ります

  4. utils.py が実際のファイル読み込みと計算を実行します

  5. 結果をフォーマットして JSON-RPC レスポンスとして返送します

  6. Claude は結果をユーザーに表示します

サンプルデータ

examples/sample.csv に 12行5列のサンプル従業員データが含まれています:

説明

name

文字列

従業員フルネーム

age

整数

従業員年齢

salary

整数

年間給与(USD)

department

文字列

部門名

hire_date

日付

採用日(YYYY-MM-DD形式)

使用例

Claude for Desktop での使用

Claude for Desktop を開いて、以下のように質問できます:

例 1: CSV ファイルの詳細分析

ユーザー: 「/Users/username/python/csv-analyzer-mcp/examples/sample.csv ファイルを分析してもらえますか?」

Claude: [analyze_csv ツールを呼び出し]

出力:
======================================================================
CSV 分析レポート
======================================================================

基本情報
  行数:          12
  列数:          5
  列名:          name, age, salary, department, hire_date

列の統計情報

  name (型: object)
    非null値:   12
    null値:     0
    ユニーク値: 12

  age (型: int64)
    非null値:   12
    null値:     0
    最小値:     26
    最大値:     52
    平均値:     36.25
    標準偏差:   8.91
    中央値:     34.5

  salary (型: int64)
    非null値:   12
    null値:     0
    最小値:     65000
    最大値:     105000
    平均値:     83916.67
    標準偏差:   11899.63
    中央値:     84500.0

  department (型: object)
    非null値:   12
    null値:     0
    ユニーク値: 5

  hire_date (型: object)
    非null値:   12
    null値:     0
    ユニーク値: 12

サマリー
  数値列:       age, salary
  欠損値の合計: 0
  メモリ使用量: 0.18 MB

======================================================================

例 2: CSV 構造のクイックサマリー

ユーザー: 「/Users/username/python/csv-analyzer-mcp/examples/sample.csv の JSON サマリーをください」

Claude: [get_csv_summary ツールを呼び出し]

出力:
{
  "rows": 12,
  "columns": 5,
  "column_names": ["name", "age", "salary", "department", "hire_date"],
  "column_types": {
    "name": "object",
    "age": "int64",
    "salary": "int64",
    "department": "object",
    "hire_date": "object"
  },
  "numeric_columns": ["age", "salary"],
  "total_missing_values": 0
}

トラブルシューティング

Claude for Desktop にサーバーが表示されない

  1. claude_desktop_config.json が正しくフォーマットされているか確認してください(有効な JSON)

  2. プロジェクトディレクトリへの絶対パスが正しいか確認してください

  3. Claude for Desktop を再起動してください(macOS では Cmd+Q で完全に終了)

  4. ログを確認: tail -f ~/Library/Logs/Claude/mcp*.log

CSV ファイルが見つからないエラー

  • 絶対パスまたは現在の作業ディレクトリに相対的なパスを使用してください

  • ファイルが存在し、読み取り可能か確認: ls -la /path/to/file.csv

最初の実行時の「許可が拒否されました」エラー

macOS/Linux では、実行許可を与える必要がある場合があります:

chmod +x /Users/username/python/csv-analyzer-mcp

さらに詳しく

ライセンス

MIT ライセンス - LICENSE ファイルの詳細を参照してください。

Available Tools

2 tools
analyze_csvA

CSVファイルを分析して基本統計情報を返します。

このツールは以下の包括的な統計を計算します:

  • 行数と列数

  • 列名とデータ型

  • 数値列の場合: 最小値、最大値、平均値、標準偏差、中央値

  • 文字列列の場合: ユニーク値の数

  • 全体統計: 欠損値の合計、メモリ使用量

Args: file_path: 分析対象の CSV ファイルへの絶対パスまたは相対パス 例: "/path/to/data.csv" または "data.csv"

Returns: 統計情報と洞察を含むフォーマット済みのテキストレポート ファイルが読み込めない場合または空の場合はエラーメッセージを返します

Example: >>> await analyze_csv("/Users/username/data.csv") # フォーマット済みの統計レポートを返します

ParametersJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior4/5

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

With no annotations provided, the description carries the full behavioral disclosure burden. It details exactly which statistics are computed, states that the return is a formatted text report, and specifies error conditions for unreadable or empty files. It does not cover potential size limits or encoding concerns, but for a read-only analysis tool this is solid coverage.

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?

The description is well-structured with a clear purpose statement, a bulleted list of statistics, an Args section, a Returns section, and an example. Every element contributes value and there is no redundancy, making it easy to scan.

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?

Given the output schema exists (signal true), the description does not need to detail return fields. It covers input semantics, output format, error behavior, and an example, so an agent can invoke it correctly. The only notable gap is the lack of routeing relative to the sibling tool get_csv_summary.

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?

The input schema has 0% coverage, so the description must define file_path. It does so clearly, explaining that it accepts absolute or relative paths and providing a concrete example. This is useful beyond the raw schema, though it stops short of mentioning supported file extensions or size constraints.

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

Purpose4/5

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

The description clearly states the verb ('analyze'), the resource ('CSV file'), and the outcome ('basic statistical information'). However, it does not mention the sibling tool get_csv_summary or explain how it differs, so an agent must infer the distinction.

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?

The description includes an example invocation and describes the file_path argument, but gives no explicit guidance about when to use this tool versus get_csv_summary, nor any conditions or exclusions. The usage context is entirely implicit.

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

get_csv_summaryA

CSV ファイルの JSON 形式でのクイックサマリーを取得します。

このツールは CSV ファイルの構造と基本情報の簡潔なサマリーを提供します。 プログラマティックな処理に有用です。

Args: file_path: CSV ファイルへの絶対パスまたは相対パス

Returns: 以下の情報を含む JSON 文字列: - rows: 行数 - columns: 列数 - column_names: 列名のリスト - column_types: 列名とデータ型の辞書 - numeric_columns: 数値列の列名リスト - total_missing_values: 欠損値の数

Example: >>> await get_csv_summary("/Users/username/data.csv") # JSON サマリーを返します

ParametersJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.6/5.0
Behavior4/5

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

With no annotations, the description carries the burden of disclosure and does a good job by enumerating the exact return fields (rows, columns, column_names, etc.) and providing an example invocation. It does not cover error handling or file access behavior, but for a read-only summary tool the essential behavioral contract is clear.

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?

The description is well-structured with Args, Returns, and Example sections, and the first sentence immediately conveys the purpose. A few phrases like 'this tool provides' are slightly redundant but not wasteful.

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 single-parameter tool, the definition provides parameter semantics, detailed return values, and an example, giving an agent enough to invoke it correctly. The main gap is not addressing how it relates to analyze_csv, which is a minor context shortfall.

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?

The schema provides no description for file_path (0% coverage), so the description's clarification that it accepts 'absolute or relative path' adds essential meaning. The example also demonstrates realistic usage, though no additional constraints or formats are specified.

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

Purpose4/5

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

The description clearly states the action ('get a quick summary' of a CSV file) and the output format (JSON). It identifies the resource precisely, but does not differentiate from the sibling tool analyze_csv, so it falls just short of a 5.

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?

Beyond the generic note that it is 'useful for programmatic processing', the description gives no guidance on when to use this tool versus analyze_csv or any exclusions. No alternatives or selection criteria are mentioned.

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. Dates show when Glama detected each change.

  1. 2 tool updatesv0.1.0
    • First observedanalyze_csv
    • First observedget_csv_summary

TDQS

A3.6/5.0
Disambiguation2/5

Both tools operate on the same CSV file and return overlapping information such as row count, column names, column types, and missing values. get_csv_summary is essentially a subset of analyze_csv, so an agent could easily select the wrong one despite the output format difference.

Naming Consistency5/5

Both tool names follow a consistent verb_noun snake_case pattern: analyze_csv and get_csv_summary. The naming style is uniform and predictable.

Tool Count3/5

Two tools is borderline for a CSV analyzer server. The count is not extreme, but the tools are highly redundant, which makes the set feel thin and not fully justified.

Completeness4/5

The core CSV analysis need is covered through basic statistics and a JSON summary. Minor gaps exist, such as no raw data preview or per-column analysis controls, but agents can work around these for typical summary tasks.

Maintenance

ActivitySlowing
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    Not graded
    maintenance
    An MCP server that enables AI assistants to load, query, and analyze local CSV files using tools for filtering, aggregation, and grouping. It provides capabilities to describe schemas, calculate statistics, and sample data directly from CSV files.
    6
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI models to interact with local CSV and Parquet data through MCP tools, providing summarization and analysis capabilities.
    1
    -
  • F
    license
    A
    quality
    D
    maintenance
    Enables LLMs to generate visual summary reports from CSV datasets using MCP Resources, Tools, and Prompts, without exposing raw data to the model.
    10
    -

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/Gakuji3/csv-analyzer-mcp'

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