notebooklm-mcp-server 0.1.4__tar.gz

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,30 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ name: Build and publish to PyPI
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ id-token: write # Required for trusted publishing (OIDC)
13
+
14
+ steps:
15
+ - name: Checkout repository
16
+ uses: actions/checkout@v4
17
+
18
+ - name: Install uv
19
+ uses: astral-sh/setup-uv@v4
20
+ with:
21
+ version: "latest"
22
+
23
+ - name: Set up Python
24
+ run: uv python install 3.11
25
+
26
+ - name: Build package
27
+ run: uv build
28
+
29
+ - name: Publish to PyPI
30
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,51 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+
28
+ # IDE
29
+ .idea/
30
+ .vscode/
31
+ *.swp
32
+ *.swo
33
+
34
+ # Testing
35
+ .pytest_cache/
36
+ .coverage
37
+ htmlcov/
38
+
39
+ # Misc
40
+ .DS_Store
41
+ *.log
42
+
43
+ # uv
44
+ .uv/
45
+ uv.lock
46
+
47
+ # Internal planning docs (do not push)
48
+ Studio_tools_plan.md
49
+
50
+ # Local project memory (personal, not shared)
51
+ CLAUDE.local.md
@@ -0,0 +1,214 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **NotebookLM MCP Server** - Provides programmatic access to NotebookLM (notebooklm.google.com) using internal APIs.
8
+
9
+ Tested with personal/free tier accounts. May work with Google Workspace accounts but has not been tested.
10
+
11
+ ## Development Commands
12
+
13
+ ```bash
14
+ # Install dependencies
15
+ uv tool install .
16
+
17
+ # Reinstall after code changes (ALWAYS clean cache first)
18
+ uv cache clean && uv tool install --force .
19
+
20
+ # Run the MCP server
21
+ notebooklm-mcp
22
+
23
+ # Run tests
24
+ uv run pytest
25
+
26
+ # Run a single test
27
+ uv run pytest tests/test_file.py::test_function -v
28
+ ```
29
+
30
+ **Python requirement:** >=3.11
31
+
32
+ ## Authentication (SIMPLIFIED!)
33
+
34
+ **You only need to provide COOKIES!** The CSRF token and session ID are now **automatically extracted** when needed.
35
+
36
+ ### Method 1: Chrome DevTools MCP (Recommended)
37
+
38
+ **Option A - Fast (Recommended):**
39
+ Extract CSRF token and session ID directly from network request - **no page fetch needed!**
40
+
41
+ ```python
42
+ # 1. Navigate to NotebookLM page
43
+ navigate_page(url="https://notebooklm.google.com/")
44
+
45
+ # 2. Get a batchexecute request (any NotebookLM API call)
46
+ get_network_request(reqid=<any_batchexecute_request>)
47
+
48
+ # 3. Save with all three fields from the network request:
49
+ save_auth_tokens(
50
+ cookies=<cookie_header>,
51
+ request_body=<request_body>, # Contains CSRF token
52
+ request_url=<request_url> # Contains session ID
53
+ )
54
+ ```
55
+
56
+ **Option B - Minimal (slower first call):**
57
+ Save only cookies, tokens extracted from page on first API call
58
+
59
+ ```python
60
+ save_auth_tokens(cookies=<cookie_header>)
61
+ ```
62
+
63
+ ### Method 2: Environment Variables
64
+
65
+ | Variable | Required | Description |
66
+ |----------|----------|-------------|
67
+ | `NOTEBOOKLM_COOKIES` | Yes | Full cookie header from Chrome DevTools |
68
+ | `NOTEBOOKLM_CSRF_TOKEN` | No | (DEPRECATED - auto-extracted) |
69
+ | `NOTEBOOKLM_SESSION_ID` | No | (DEPRECATED - auto-extracted) |
70
+
71
+ ### Token Expiration
72
+
73
+ - **Cookies**: Stable for weeks, but some rotate on each request
74
+ - **CSRF token**: Auto-refreshed on each client initialization
75
+ - **Session ID**: Auto-refreshed on each client initialization
76
+
77
+ When API calls fail with auth errors, re-extract fresh cookies from Chrome DevTools.
78
+
79
+ ## Architecture
80
+
81
+ ```
82
+ src/notebooklm_mcp/
83
+ ├── __init__.py # Package version
84
+ ├── server.py # FastMCP server with tool definitions
85
+ ├── api_client.py # Internal API client
86
+ ├── auth.py # Token caching and validation
87
+ └── auth_cli.py # CLI for Chrome-based auth (notebooklm-mcp-auth)
88
+ ```
89
+
90
+ **Executables:**
91
+ - `notebooklm-mcp` - The MCP server
92
+ - `notebooklm-mcp-auth` - CLI for extracting tokens (requires closing Chrome)
93
+
94
+ ## MCP Tools Provided
95
+
96
+ | Tool | Purpose |
97
+ |------|---------|
98
+ | `notebook_list` | List all notebooks |
99
+ | `notebook_create` | Create new notebook |
100
+ | `notebook_get` | Get notebook details |
101
+ | `notebook_describe` | Get AI-generated summary of notebook content with keywords |
102
+ | `source_describe` | Get AI-generated summary and keyword chips for a source |
103
+ | `notebook_rename` | Rename a notebook |
104
+ | `chat_configure` | Configure chat goal/style and response length |
105
+ | `notebook_delete` | Delete a notebook (REQUIRES confirmation) |
106
+ | `notebook_add_url` | Add URL/YouTube source |
107
+ | `notebook_add_text` | Add pasted text source |
108
+ | `notebook_add_drive` | Add Google Drive source |
109
+ | `notebook_query` | Ask questions (AI answers!) |
110
+ | `source_list_drive` | List sources with types, check Drive freshness |
111
+ | `source_sync_drive` | Sync stale Drive sources (REQUIRES confirmation) |
112
+ | `source_delete` | Delete a source from notebook (REQUIRES confirmation) |
113
+ | `research_start` | Start Web or Drive research to discover sources |
114
+ | `research_status` | Check research progress and get results |
115
+ | `research_import` | Import discovered sources into notebook |
116
+ | `audio_overview_create` | Generate audio podcasts (REQUIRES confirmation) |
117
+ | `video_overview_create` | Generate video overviews (REQUIRES confirmation) |
118
+ | `infographic_create` | Generate infographics (REQUIRES confirmation) |
119
+ | `slide_deck_create` | Generate slide decks (REQUIRES confirmation) |
120
+ | `report_create` | Generate reports - Briefing Doc, Study Guide, Blog Post, Custom (REQUIRES confirmation) |
121
+ | `flashcards_create` | Generate flashcards with difficulty options (REQUIRES confirmation) |
122
+ | `quiz_create` | Generate interactive quizzes (REQUIRES confirmation) |
123
+ | `data_table_create` | Generate data tables from sources (REQUIRES confirmation) |
124
+ | `mind_map_create` | Generate and save mind maps (REQUIRES confirmation) |
125
+ | `mind_map_list` | List all mind maps in a notebook |
126
+ | `studio_status` | Check studio artifact generation status |
127
+ | `studio_delete` | Delete studio artifacts (REQUIRES confirmation) |
128
+ | `save_auth_tokens` | Save tokens extracted via Chrome DevTools MCP |
129
+
130
+ **IMPORTANT - Operations Requiring Confirmation:**
131
+ - `notebook_delete` requires `confirm=True` - deletion is IRREVERSIBLE
132
+ - `source_delete` requires `confirm=True` - deletion is IRREVERSIBLE
133
+ - `source_sync_drive` requires `confirm=True` - always show stale sources first via `source_list_drive`
134
+ - All studio creation tools require `confirm=True` - show settings and get user approval first
135
+ - `studio_delete` requires `confirm=True` - list artifacts first via `studio_status`, deletion is IRREVERSIBLE
136
+
137
+ ## Features NOT Yet Implemented
138
+
139
+ - [ ] **Notes** - Save chat responses as notes
140
+ - [ ] **Share notebook** - Collaboration features
141
+ - [ ] **Export** - Download content
142
+
143
+ ## Troubleshooting
144
+
145
+ ### "401 Unauthorized" or "403 Forbidden"
146
+ - Cookies or CSRF token expired
147
+ - Re-extract from Chrome DevTools
148
+
149
+ ### "Invalid CSRF token"
150
+ - The `at=` value expired
151
+ - Must match the current session
152
+
153
+ ### Empty notebook list
154
+ - Session might be for a different Google account
155
+ - Verify you're logged into the correct account
156
+
157
+ ### Rate limit errors
158
+ - Free tier: ~50 queries/day
159
+ - Wait until the next day or upgrade to Plus
160
+
161
+ ## Documentation
162
+
163
+ ### API Reference
164
+
165
+ **For detailed API documentation** (RPC IDs, parameter structures, response formats), see:
166
+
167
+ **[docs/API_REFERENCE.md](./docs/API_REFERENCE.md)**
168
+
169
+ This includes:
170
+ - All discovered RPC endpoints and their parameters
171
+ - Source type structures (URL, text, Drive)
172
+ - Studio content creation (audio, video, reports, etc.)
173
+ - Research workflow details
174
+ - Mind map generation process
175
+ - Source metadata structures
176
+
177
+ Only read API_REFERENCE.md when:
178
+ - Debugging API issues
179
+ - Adding new features
180
+ - Understanding internal API behavior
181
+
182
+ ### MCP Test Plan
183
+
184
+ **For comprehensive MCP tool testing**, see:
185
+
186
+ **[docs/MCP_TEST_PLAN.md](./docs/MCP_TEST_PLAN.md)**
187
+
188
+ This includes:
189
+ - Step-by-step test cases for all 31 MCP tools
190
+ - Authentication and basic operations tests
191
+ - Source management and Drive sync tests
192
+ - Studio content generation tests (audio, video, infographics, etc.)
193
+ - Quick copy-paste test prompts for validation
194
+
195
+ Use this test plan when:
196
+ - Validating MCP server functionality after code changes
197
+ - Testing new tool implementations
198
+ - Debugging MCP tool issues
199
+
200
+ ## Contributing
201
+
202
+ When adding new features:
203
+
204
+ 1. Use Chrome DevTools MCP to capture the network request
205
+ 2. Document the RPC ID in docs/API_REFERENCE.md
206
+ 3. Add the param structure with comments
207
+ 4. Update the api_client.py with the new method
208
+ 5. Add corresponding tool in server.py
209
+ 6. Update the "Features NOT Yet Implemented" checklist
210
+ 7. Add test case to docs/MCP_TEST_PLAN.md
211
+
212
+ ## License
213
+
214
+ MIT License
@@ -0,0 +1,96 @@
1
+ # GEMINI.md
2
+
3
+ ## Project Overview
4
+
5
+ **NotebookLM MCP Server**
6
+
7
+ This project implements a Model Context Protocol (MCP) server that provides programmatic access to [NotebookLM](https://notebooklm.google.com). It allows AI agents and developers to interact with NotebookLM notebooks, sources, and query capabilities.
8
+
9
+ Tested with personal/free tier accounts. May work with Google Workspace accounts but has not been tested. This project relies on internal APIs (`batchexecute` RPCs).
10
+
11
+ ## Environment & Setup
12
+
13
+ The project uses `uv` for dependency management and tool installation.
14
+
15
+ ### Prerequisites
16
+ - Python 3.11+
17
+ - `uv` (Universal Python Package Manager)
18
+ - Google Chrome (for automated authentication)
19
+
20
+ ### Installation
21
+
22
+ **From PyPI (Recommended):**
23
+ ```bash
24
+ uv tool install notebooklm-mcp-server
25
+ # or: pip install notebooklm-mcp-server
26
+ ```
27
+
28
+ **From Source (Development):**
29
+ ```bash
30
+ git clone https://github.com/YOUR_USERNAME/notebooklm-mcp.git
31
+ cd notebooklm-mcp
32
+ uv tool install .
33
+ ```
34
+
35
+ ## Authentication (Simplified!)
36
+
37
+ **You only need to extract cookies** - the CSRF token and session ID are now auto-extracted when the MCP starts.
38
+
39
+ **Option 1: Chrome DevTools MCP (Recommended)**
40
+ If your AI assistant has Chrome DevTools MCP:
41
+ 1. Navigate to `notebooklm.google.com`
42
+ 2. Get cookies from any network request
43
+ 3. Call `save_auth_tokens(cookies=<cookie_header>)`
44
+
45
+ **Option 2: Manual (Environment Variables)**
46
+ Extract the `Cookie` header from Chrome DevTools Network tab:
47
+ ```bash
48
+ export NOTEBOOKLM_COOKIES="SID=xxx; HSID=xxx; SSID=xxx; ..."
49
+ ```
50
+
51
+ > **Note:** CSRF token and session ID are no longer needed - they are auto-extracted from the page HTML when the MCP initializes.
52
+
53
+ Cookies last for weeks. When they expire, re-extract fresh cookies.
54
+
55
+ ## Development Workflow
56
+
57
+ ### Building and Running
58
+
59
+ **Reinstalling after changes:**
60
+ Because `uv tool install` installs into an isolated environment, you must reinstall to see changes during development.
61
+ ```bash
62
+ uv cache clean
63
+ uv tool install --force .
64
+ ```
65
+
66
+ **Running the Server:**
67
+ ```bash
68
+ notebooklm-mcp
69
+ ```
70
+
71
+ ### Testing
72
+
73
+ Run the test suite using `pytest` via `uv`:
74
+ ```bash
75
+ # Run all tests
76
+ uv run pytest
77
+
78
+ # Run a specific test file
79
+ uv run pytest tests/test_api_client.py
80
+ ```
81
+
82
+ ## Project Structure
83
+
84
+ - `src/notebooklm_mcp/`
85
+ - `server.py`: Main entry point. Defines the MCP server and tools.
86
+ - `api_client.py`: The core logic. Contains the internal API calls.
87
+ - `auth.py`: Handles token validation, storage, and loading.
88
+ - `auth_cli.py`: Implementation of the `notebooklm-mcp-auth` CLI.
89
+ - `CLAUDE.md`: Contains detailed documentation on the internal RPC IDs and protocol specifics. **Refer to this file for API deep dives.**
90
+ - `pyproject.toml`: Project configuration and dependencies.
91
+
92
+ ## Key Conventions
93
+
94
+ - **Internal APIs:** This project relies on undocumented APIs. Changes to Google's internal API will break functionality.
95
+ - **RPC Protocol:** The API uses Google's `batchexecute` protocol. Responses often contain "anti-XSSI" prefixes (`)]}'`) that must be stripped.
96
+ - **Tools:** New features should be exposed as MCP tools in `server.py`.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Jacob Ben David
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.