notebookllm 1.0.0__py3-none-any.whl → 2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,277 @@
1
+ Metadata-Version: 2.4
2
+ Name: notebookllm
3
+ Version: 2.0
4
+ Summary: Convert Jupyter notebooks to/from plain text for LLMs, and expose functionality via an MCP server.
5
+ Author-email: Yasir Raza <yasirabdali6@gmail.com>
6
+ Keywords: jupyter,notebook,llm,conversion,mcp,cli
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: nbformat
10
+ Requires-Dist: jupyter_client
11
+ Requires-Dist: mcp[cli]
12
+
13
+ # notebookllm
14
+
15
+ A Python package to bridge the gap between Jupyter Notebooks and Large Language Models (LLMs).
16
+
17
+ ## Why this package?
18
+
19
+ Current Large Language Models (LLMs) cannot directly read or process `.ipynb` files. This package provides a solution by converting `.ipynb` files to a simplified plain text format that LLMs can easily understand. It also allows converting Python files to `.ipynb` files.
20
+
21
+ ## Features
22
+
23
+ - Convert `.ipynb` files to a simplified plain text (.py, .txt or .r file) format.
24
+ - Convert Python or R (.py, .txt or .r files) to `.ipynb` files.
25
+ - The plain text (.py, .txt or .r) format preserves the structure of the notebook, including code and markdown cells, using `# %% [code]` and `# %% [markdown]` identifiers.
26
+ - The plain text (.py, .txt or .r) format can be easily parsed back into a `.ipynb` file.
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ pip install notebookllm
32
+ ```
33
+ or
34
+
35
+ ```bash
36
+ git clone https://github.com/yasirrazaa/notebookllm.git
37
+ cd notebookllm
38
+ pip install .
39
+ ```
40
+
41
+ ## Usage
42
+ ## CLI
43
+
44
+ ### `to_text`
45
+
46
+ Converts a `.ipynb` file to a simplified plain text format.
47
+
48
+ Usage:
49
+
50
+ ```bash
51
+ notebookllm to_text <ipynb_file> --output <output_file>
52
+ ```
53
+
54
+ - `<ipynb_file>`: Path to the `.ipynb` file.
55
+ - `--output <output_file>`: Path to save the plain text output. If not provided, the output will be printed to the console.
56
+
57
+ Example:
58
+
59
+ ```bash
60
+ notebookllm to_text my_notebook.ipynb --output my_notebook.txt
61
+ ```
62
+
63
+ ### `to_ipynb`
64
+
65
+ Converts a `.py` file to a `.ipynb` file.
66
+
67
+ Usage:
68
+
69
+ ```bash
70
+ notebookllm to_ipynb <py_file> --output <output_file>
71
+ ```
72
+
73
+ - `<py_file>`: Path to the `.py` file.
74
+ - `--output <output_file>`: Path to save the `.ipynb` output. If not provided, the output will be saved to `output.ipynb`.
75
+
76
+ Example:
77
+
78
+ ```bash
79
+ notebookllm to_ipynb my_script.py --output my_notebook.ipynb
80
+ ```
81
+
82
+ ## API
83
+
84
+ ```python
85
+ from notebookllm import Notebook
86
+
87
+ notebook = Notebook(filepath='notebook.ipynb') # Load existing notebook or create a new one
88
+ notebook.add_code_cell('print("Hello, world!")') # Add a code cell
89
+ notebook.add_markdown_cell('# This is a markdown cell') # Add a markdown cell
90
+ notebook.execute_cell(0) # Execute a cell
91
+ notebook.delete_cell(1) # Delete a cell
92
+ notebook.add_raw_cell('{"data": {"text/plain": "This is a raw cell"}}') # Add a raw cell
93
+ notebook.save('new_notebook.ipynb') # Save the notebook
94
+ notebook.edit_cell(0, 'print("Hello, world!")') # Edit a cell
95
+ notebook.save() # Save the changes
96
+ ````
97
+
98
+ ## Using `notebookllm` as an MCP Server
99
+
100
+ The `notebookllm` package includes an MCP (Model Context Protocol) server (`mcp_server.py`) that exposes notebook conversion and manipulation functionalities as tools for Large Language Models (LLMs). This allows LLMs to programmatically interact with Jupyter notebooks in a way that is token-efficient, cost-effective, and fast by focusing on plain text representations of notebook content rather than full, verbose notebook metadata.
101
+
102
+ ### Installation & Running the Server
103
+
104
+ Here’s how to install and run the `notebookllm` MCP server:
105
+
106
+ **1. Using `uvx` (Recommended for quick use)**
107
+
108
+ `uvx` allows you to run the server directly from its PyPI package without needing to install it into your global or project Python environment. This is ideal for quickly using the server with clients like Claude Desktop or VS Code.
109
+
110
+ * To run the server (assuming `notebookllm` is published to PyPI and provides a `notebookllm-server` command):
111
+ ```bash
112
+ uvx notebookllm-server
113
+ ```
114
+
115
+ **2. Using `pip` (Traditional installation)**
116
+
117
+ * Install the package from PyPI:
118
+ ```bash
119
+ pip install notebookllm
120
+ ```
121
+ * Run the server using the installed command:
122
+ ```bash
123
+ notebookllm-server
124
+ ```
125
+ *(If the package installs `mcp_server.py` as a module within the `notebookllm` package but doesn't define a direct `notebookllm-server` script, you might run it as `python -m notebookllm.mcp_server`.)*
126
+
127
+ ### Configuration with Clients
128
+
129
+ Once the server can be run using one of the methods above, you can configure various clients to use its tools.
130
+
131
+ **A. Claude Desktop**
132
+
133
+ Add the following to your `claude_desktop_config.json` file (typically found at `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, or `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
134
+
135
+ * **Using `uvx`:**
136
+ ```json
137
+ {
138
+ "mcpServers": {
139
+ "notebookllm": {
140
+ "command": "uvx",
141
+ "args": ["notebookllm-server"]
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ * **Using `pip` installation:**
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "notebookllm": {
152
+ "command": "notebookllm-server", // Or full path if not in PATH, or 'python'
153
+ "args": [] // If using 'python', args would be ['-m', 'notebookllm.mcp_server']
154
+ }
155
+ }
156
+ }
157
+ ```
158
+
159
+ **B. VS Code**
160
+
161
+ Add the following to your User Settings (JSON) file (`Ctrl + Shift + P` -> "Preferences: Open User Settings (JSON)") or to a `.vscode/mcp.json` file in your workspace (if using `.vscode/mcp.json`, omit the top-level `"mcp": { ... }` wrapper).
162
+
163
+ * **Using `uvx`:**
164
+ ```json
165
+ {
166
+ "mcp": {
167
+ "servers": {
168
+ "notebookllm": {
169
+ "command": "uvx",
170
+ "args": ["notebookllm-server"]
171
+ }
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ * **Using `pip` installation:**
178
+ ```json
179
+ {
180
+ "mcp": {
181
+ "servers": {
182
+ "notebookllm": {
183
+ "command": "notebookllm-server", // Or 'python'
184
+ "args": [] // If using 'python', args would be ['-m', 'notebookllm.mcp_server']
185
+ }
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ **C. Zed Editor**
192
+
193
+ Add the following to your Zed `settings.json` (accessible via `Zed > Settings > Open Settings (JSON)`):
194
+
195
+ * **Using `uvx`:**
196
+ ```json
197
+ {
198
+ "mcp_servers": {
199
+ "notebookllm": {
200
+ "command": "uvx",
201
+ "args": ["notebookllm-server"]
202
+ }
203
+ }
204
+ }
205
+ ```
206
+
207
+ * **Using `pip` installation:**
208
+ ```json
209
+ {
210
+ "mcp_servers": {
211
+ "notebookllm": {
212
+ "command": "notebookllm-server", // Or 'python'
213
+ "args": [] // If using 'python', args would be ['-m', 'notebookllm.mcp_server']
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ ### Available Tools
220
+
221
+ The MCP server exposes the following tools (refer to the `mcp_server.py` file within the `notebookllm` package for detailed descriptions and parameters):
222
+
223
+ * `load_notebook(filepath: str)`: Loads a `.ipynb` file into memory for efficient operations.
224
+ * `notebook_to_plain_text(input_filepath: str | None = None)`: Converts a notebook to token-efficient plain text.
225
+ * `plain_text_to_notebook_file(plain_text_content: str, output_filepath: str)`: Converts plain text back to a `.ipynb` file.
226
+ * `add_code_cell_to_loaded_notebook(code_content: str, position: int | None = None)`: Adds a code cell to the loaded notebook.
227
+ * `add_markdown_cell_to_loaded_notebook(markdown_content: str, position: int | None = None)`: Adds a markdown cell to the loaded notebook.
228
+ * `save_loaded_notebook(output_filepath: str | None = None)`: Saves the loaded notebook.
229
+
230
+ ### Debugging the Server
231
+
232
+ You can use the MCP Inspector to debug the server.
233
+
234
+ * **If using `uvx`:**
235
+ ```bash
236
+ npx @modelcontextprotocol/inspector uvx notebookllm-server
237
+ ```
238
+
239
+ * **If using a `pip` installed version (assuming `notebookllm-server` is the command):**
240
+ ```bash
241
+ npx @modelcontextprotocol/inspector notebookllm-server
242
+ ```
243
+ *(If running as a module: `npx @modelcontextprotocol/inspector python -m notebookllm.mcp_server`)*
244
+
245
+ Check the logs from your client application (e.g., Claude Desktop logs typically found in `~/Library/Logs/Claude/mcp*.log` on macOS or `%APPDATA%\Claude\mcp*.log` on Windows) for more detailed error messages from the server.
246
+
247
+ ### Development & Local Testing
248
+
249
+ If you are developing `notebookllm` locally:
250
+
251
+ 1. **Clone the repository:**
252
+ ```bash
253
+ git clone https://github.com/yasirrazaa/notebookllm.git # Or your fork
254
+ cd notebookllm
255
+ ```
256
+ 2. **Set up the environment using `uv`:**
257
+ ```bash
258
+ uv init # If not already done for this project
259
+ uv sync # Installs dependencies from pyproject.toml, including mcp[cli]
260
+ uv pip install -e . # Installs the notebookllm package in editable mode
261
+ ```
262
+ 3. **Run the local server for testing:**
263
+ * Using `mcp dev` for the MCP Inspector (recommended for interactive testing):
264
+ ```bash
265
+ uv run mcp dev mcp_server.py
266
+ ```
267
+ * Running the local `mcp_server.py` script directly:
268
+ ```bash
269
+ uv run python mcp_server.py
270
+ ```
271
+ * If you've installed in editable mode and defined the `notebookllm-server` script in your `pyproject.toml`, you can also test it as if it were installed:
272
+ ```bash
273
+ uv run notebookllm-server
274
+ ```
275
+
276
+ By providing these tools via MCP, `notebookllm` empowers LLMs to become more active participants in the notebook development and manipulation workflow, enhancing productivity and reducing manual effort by focusing on cost-effective, token-efficient operations.
277
+
@@ -0,0 +1,7 @@
1
+ notebookllm/__init__.py,sha256=yNaKn7kunOlKYbPcz-M0UUiiKTy4KtqGZlwzWtO7Ag4,34
2
+ notebookllm/notebookllm.py,sha256=z_T2g97Mk6Km2mjOC2hgwWixbQ0ccn-DBO-kJtD1ruI,12803
3
+ notebookllm-2.0.dist-info/METADATA,sha256=DthWkpDCrjKn6Cyk0V10XJvOO7mzGyNdYkvOojd_XAA,9394
4
+ notebookllm-2.0.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
5
+ notebookllm-2.0.dist-info/entry_points.txt,sha256=e5O60G98HBVOOF8_cY9YG-wLueoY3RsF1S897gVb6Us,82
6
+ notebookllm-2.0.dist-info/top_level.txt,sha256=Fm8CUjCpfnLmLmlD61xcg7z5vAYMJZYfJDuTS3iUs38,12
7
+ notebookllm-2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.6.0)
2
+ Generator: setuptools (80.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,2 +1,3 @@
1
1
  [console_scripts]
2
2
  notebookllm = cli:main
3
+ notebookllm-server = mcp_server:main_cli
cli.py DELETED
@@ -1,75 +0,0 @@
1
-
2
- import argparse
3
- from notebookllm import Notebook
4
- import sys
5
-
6
- def main():
7
- """
8
- Entry point for the notebookllm command-line tool.
9
-
10
- Parses command-line arguments and performs the appropriate action
11
- based on the provided command.
12
- """
13
- parser = argparse.ArgumentParser(
14
- description="Convert between .ipynb, .py, and plain text formats for LLMs"
15
- )
16
- subparsers = parser.add_subparsers(title="commands", dest="command")
17
-
18
- # Convert .ipynb to plain text
19
- to_text_parser = subparsers.add_parser(
20
- "to_text", help="Convert .ipynb to a simplified plain text format"
21
- )
22
- to_text_parser.add_argument("ipynb_file", help="Path to the .ipynb file")
23
- to_text_parser.add_argument(
24
- "--output", "-o", help="Path to save the plain text output", default=None
25
- )
26
-
27
- # Convert .py to .ipynb
28
- py_to_ipynb_parser = subparsers.add_parser(
29
- "to_ipynb", help="Convert .py,.txt or .r file to a .ipynb format"
30
- )
31
- py_to_ipynb_parser.add_argument("py_file", help="Path to the .py,.txt or .r file")
32
- py_to_ipynb_parser.add_argument(
33
- "--output", "-o", help="Path to save the .ipynb output", default=None
34
- )
35
-
36
- args = parser.parse_args()
37
-
38
- if args.command == "to_text":
39
- try:
40
- notebook = Notebook(args.ipynb_file)
41
- plain_text = notebook.to_plain_text()
42
- if args.output:
43
- with open(args.output, "w", encoding="utf-8") as f:
44
- f.write(plain_text)
45
- print(f"Saved to {args.output}")
46
- else:
47
- print(plain_text)
48
-
49
- except FileNotFoundError as e:
50
- print(f"Error: {e}", file=sys.stderr)
51
- sys.exit(1)
52
-
53
- elif args.command == "to_ipynb":
54
- try:
55
- with open(args.py_file, "r", encoding="utf-8") as f:
56
- file_content = f.read()
57
- notebook = Notebook.from_plain_text(file_content)
58
- if args.output:
59
- notebook.save(args.output)
60
- print(f"Saved to {args.output}")
61
- else:
62
- notebook.save("output.ipynb")
63
- print("Saved to output.ipynb")
64
-
65
- except FileNotFoundError as e:
66
- print(f"Error: {e}", file=sys.stderr)
67
- sys.exit(1)
68
-
69
- except ValueError as e:
70
- print(f"Error: {e}", file=sys.stderr)
71
- sys.exit(1)
72
-
73
-
74
- if __name__ == "__main__":
75
- main()
@@ -1,91 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: notebookllm
3
- Version: 1.0
4
- Description-Content-Type: text/markdown
5
- Requires-Dist: nbformat
6
- Requires-Dist: jupyter_client
7
-
8
- # notebookllm
9
-
10
- A Python package to bridge the gap between Jupyter Notebooks and Large Language Models (LLMs).
11
-
12
- ## Why this package?
13
-
14
- Current Large Language Models (LLMs) cannot directly read or process `.ipynb` files. This package provides a solution by converting `.ipynb` files to a simplified plain text format that LLMs can easily understand. It also allows converting Python files to `.ipynb` files.
15
-
16
- ## Features
17
-
18
- - Convert `.ipynb` files to a simplified plain text (.py, .txt or .r file) format.
19
- - Convert Python or R (.py, .txt or .r files) to `.ipynb` files.
20
- - The plain text (.py, .txt or .r) format preserves the structure of the notebook, including code and markdown cells, using `# %% [code]` and `# %% [markdown]` identifiers.
21
- - The plain text (.py, .txt or .r) format can be easily parsed back into a `.ipynb` file.
22
-
23
- ## Installation
24
-
25
- ```bash
26
- pip install notebookllm
27
- ```
28
- or
29
-
30
- ```bash
31
- git clone https://github.com/yasirrazaa/notebookllm.git
32
- cd notebookllm
33
- pip install .
34
- ```
35
-
36
- ## Usage
37
- ## CLI
38
-
39
- ### `to_text`
40
-
41
- Converts a `.ipynb` file to a simplified plain text format.
42
-
43
- Usage:
44
-
45
- ```bash
46
- notebookllm to_text <ipynb_file> --output <output_file>
47
- ```
48
-
49
- - `<ipynb_file>`: Path to the `.ipynb` file.
50
- - `--output <output_file>`: Path to save the plain text output. If not provided, the output will be printed to the console.
51
-
52
- Example:
53
-
54
- ```bash
55
- notebookllm to_text my_notebook.ipynb --output my_notebook.txt
56
- ```
57
-
58
- ### `to_ipynb`
59
-
60
- Converts a `.py` file to a `.ipynb` file.
61
-
62
- Usage:
63
-
64
- ```bash
65
- notebookllm to_ipynb <py_file> --output <output_file>
66
- ```
67
-
68
- - `<py_file>`: Path to the `.py` file.
69
- - `--output <output_file>`: Path to save the `.ipynb` output. If not provided, the output will be saved to `output.ipynb`.
70
-
71
- Example:
72
-
73
- ```bash
74
- notebookllm to_ipynb my_script.py --output my_notebook.ipynb
75
- ```
76
-
77
- ## API
78
-
79
- ```python
80
- from notebookllm import Notebook
81
-
82
- notebook = Notebook(filepath='notebook.ipynb') # Load existing notebook or create a new one
83
- notebook.add_code_cell('print("Hello, world!")') # Add a code cell
84
- notebook.add_markdown_cell('# This is a markdown cell') # Add a markdown cell
85
- notebook.execute_cell(0) # Execute a cell
86
- notebook.delete_cell(1) # Delete a cell
87
- notebook.add_raw_cell('{"data": {"text/plain": "This is a raw cell"}}') # Add a raw cell
88
- notebook.save('new_notebook.ipynb') # Save the notebook
89
- notebook.edit_cell(0, 'print("Hello, world!")') # Edit a cell
90
- notebook.save() # Save the changes
91
-
@@ -1,8 +0,0 @@
1
- cli.py,sha256=AtsKtdIBG7i8skxGZf3IgcU3xkuE2rO8CwKT_yxZnhs,2409
2
- notebookllm/__init__.py,sha256=yNaKn7kunOlKYbPcz-M0UUiiKTy4KtqGZlwzWtO7Ag4,34
3
- notebookllm/notebookllm.py,sha256=z_T2g97Mk6Km2mjOC2hgwWixbQ0ccn-DBO-kJtD1ruI,12803
4
- notebookllm-1.0.dist-info/METADATA,sha256=4XcL1BOja3PsNruhtp6PTo5Oh2Th4wLs-KGvfi7Q3As,2559
5
- notebookllm-1.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
- notebookllm-1.0.dist-info/entry_points.txt,sha256=mKGBNml107Ssh5erUt5Mh-LyzWrEIcIdLDVZQHa7z-o,41
7
- notebookllm-1.0.dist-info/top_level.txt,sha256=YwPXN4sC3rhK0sNsVF0B9XOY6B1YnLzXGUue1QFngZc,16
8
- notebookllm-1.0.dist-info/RECORD,,