Skip to main content
Glama
YmSaki
by YmSaki
README.md
# ipynb-mcp

ローカルの Jupyter Notebook (`.ipynb`) にセルを追加・編集し、ノートブックで指定されたカーネル上で単一セルを実行する小さな stdio MCP サーバーです。

## セットアップ

Python 3.10 以上と [uv](https://docs.astral.sh/uv/) を使います。

```powershell
uv sync
```

`ipykernel` は依存関係に含まれるため、通常はカーネルの追加インストールは不要です。

対象ノートブックの `metadata.kernelspec.name` が設定されていれば、そのカーネルを使います。未設定の場合は `IPYNB_MCP_DEFAULT_KERNEL`、次に `python3`、最後にインストール済みカーネルの名前順で先頭を選びます。

## MCP クライアントへの登録

クライアントからこのコマンドを stdio MCP サーバーとして起動するよう設定します。

```json
{
  "mcpServers": {
    "jupyter-notebook": {
      "command": "uv",
      "args": [
        "--directory",
        "C:\\programing\\ipynb-mcp",
        "run",
        "ipynb-mcp"
      ]
    }
  }
}
```

## ツール

- `notebook_info(path)`: セル一覧とカーネル情報を取得
- `read_cell(path, index)`: セル内容を取得
- `add_cell(path, source, cell_type="code", index=null)`: セルを追加。ファイルがなければ新規作成
- `edit_cell(path, index, source, cell_type=null)`: セル内容と任意で種類を変更
- `run_cell(path, index, timeout_seconds=120)`: コードセルを実行し、出力をノートブックへ保存
- `restart_kernel(path)`: カーネルを再起動して変数などの状態を消去

セル番号はすべて 0 始まりです。カーネルはノートブックごとにサーバープロセス内で維持されるため、セル間で変数を引き継げます。サーバーを終了するとカーネルも終了します。

## 開発時の確認

```powershell
uv run pytest
```

TDQS

A3.7/5.0

Scored across 6 tools

Disambiguation5/5

Each tool targets a distinct operation: reading metadata, reading a cell, adding, editing, running, or restarting the kernel. There is minimal overlap and an agent can clearly select the right tool for the intended action.

Naming Consistency4/5

Most tools follow a clear verb_noun pattern: read_cell, add_cell, edit_cell, run_cell, restart_kernel. notebook_info is the only slight deviation, being noun_noun rather than get_notebook_info, but it remains readable and consistent with the overall style.

Tool Count5/5

Six tools is a well-scoped set for notebook manipulation. Each tool serves a clear and necessary purpose without unnecessary bloat.

Completeness3/5

The core lifecycle of reading, adding, editing, and executing cells is covered, and restart_kernel handles execution-state resets. However, a delete_cell operation is missing, which is a notable gap for editing workflows, and there is no way to reorder cells.

Maintenance

ActivityMaintained
ResponsivenessNo issues