@pan-sec/notebooklm-mcp 1.4.0

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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +289 -0
  3. package/SECURITY.md +539 -0
  4. package/dist/auth/auth-manager.d.ts +137 -0
  5. package/dist/auth/auth-manager.d.ts.map +1 -0
  6. package/dist/auth/auth-manager.js +984 -0
  7. package/dist/auth/auth-manager.js.map +1 -0
  8. package/dist/auth/mcp-auth.d.ts +102 -0
  9. package/dist/auth/mcp-auth.d.ts.map +1 -0
  10. package/dist/auth/mcp-auth.js +286 -0
  11. package/dist/auth/mcp-auth.js.map +1 -0
  12. package/dist/config.d.ts +89 -0
  13. package/dist/config.d.ts.map +1 -0
  14. package/dist/config.js +216 -0
  15. package/dist/config.js.map +1 -0
  16. package/dist/errors.d.ts +26 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +41 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/index.d.ts +32 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +371 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/library/notebook-library.d.ts +70 -0
  25. package/dist/library/notebook-library.d.ts.map +1 -0
  26. package/dist/library/notebook-library.js +279 -0
  27. package/dist/library/notebook-library.js.map +1 -0
  28. package/dist/library/types.d.ts +67 -0
  29. package/dist/library/types.d.ts.map +1 -0
  30. package/dist/library/types.js +8 -0
  31. package/dist/library/types.js.map +1 -0
  32. package/dist/resources/resource-handlers.d.ts +22 -0
  33. package/dist/resources/resource-handlers.d.ts.map +1 -0
  34. package/dist/resources/resource-handlers.js +216 -0
  35. package/dist/resources/resource-handlers.js.map +1 -0
  36. package/dist/session/browser-session.d.ts +108 -0
  37. package/dist/session/browser-session.d.ts.map +1 -0
  38. package/dist/session/browser-session.js +621 -0
  39. package/dist/session/browser-session.js.map +1 -0
  40. package/dist/session/session-manager.d.ts +77 -0
  41. package/dist/session/session-manager.d.ts.map +1 -0
  42. package/dist/session/session-manager.js +314 -0
  43. package/dist/session/session-manager.js.map +1 -0
  44. package/dist/session/session-timeout.d.ts +122 -0
  45. package/dist/session/session-timeout.d.ts.map +1 -0
  46. package/dist/session/session-timeout.js +281 -0
  47. package/dist/session/session-timeout.js.map +1 -0
  48. package/dist/session/shared-context-manager.d.ts +107 -0
  49. package/dist/session/shared-context-manager.d.ts.map +1 -0
  50. package/dist/session/shared-context-manager.js +447 -0
  51. package/dist/session/shared-context-manager.js.map +1 -0
  52. package/dist/tools/definitions/ask-question.d.ts +8 -0
  53. package/dist/tools/definitions/ask-question.d.ts.map +1 -0
  54. package/dist/tools/definitions/ask-question.js +211 -0
  55. package/dist/tools/definitions/ask-question.js.map +1 -0
  56. package/dist/tools/definitions/notebook-management.d.ts +3 -0
  57. package/dist/tools/definitions/notebook-management.d.ts.map +1 -0
  58. package/dist/tools/definitions/notebook-management.js +243 -0
  59. package/dist/tools/definitions/notebook-management.js.map +1 -0
  60. package/dist/tools/definitions/session-management.d.ts +3 -0
  61. package/dist/tools/definitions/session-management.d.ts.map +1 -0
  62. package/dist/tools/definitions/session-management.js +41 -0
  63. package/dist/tools/definitions/session-management.js.map +1 -0
  64. package/dist/tools/definitions/system.d.ts +3 -0
  65. package/dist/tools/definitions/system.d.ts.map +1 -0
  66. package/dist/tools/definitions/system.js +143 -0
  67. package/dist/tools/definitions/system.js.map +1 -0
  68. package/dist/tools/definitions.d.ts +12 -0
  69. package/dist/tools/definitions.d.ts.map +1 -0
  70. package/dist/tools/definitions.js +26 -0
  71. package/dist/tools/definitions.js.map +1 -0
  72. package/dist/tools/handlers.d.ts +213 -0
  73. package/dist/tools/handlers.d.ts.map +1 -0
  74. package/dist/tools/handlers.js +813 -0
  75. package/dist/tools/handlers.js.map +1 -0
  76. package/dist/tools/index.d.ts +8 -0
  77. package/dist/tools/index.d.ts.map +1 -0
  78. package/dist/tools/index.js +8 -0
  79. package/dist/tools/index.js.map +1 -0
  80. package/dist/types.d.ts +82 -0
  81. package/dist/types.d.ts.map +1 -0
  82. package/dist/types.js +5 -0
  83. package/dist/types.js.map +1 -0
  84. package/dist/utils/audit-logger.d.ts +140 -0
  85. package/dist/utils/audit-logger.d.ts.map +1 -0
  86. package/dist/utils/audit-logger.js +361 -0
  87. package/dist/utils/audit-logger.js.map +1 -0
  88. package/dist/utils/cert-pinning.d.ts +97 -0
  89. package/dist/utils/cert-pinning.d.ts.map +1 -0
  90. package/dist/utils/cert-pinning.js +328 -0
  91. package/dist/utils/cert-pinning.js.map +1 -0
  92. package/dist/utils/cleanup-manager.d.ts +133 -0
  93. package/dist/utils/cleanup-manager.d.ts.map +1 -0
  94. package/dist/utils/cleanup-manager.js +673 -0
  95. package/dist/utils/cleanup-manager.js.map +1 -0
  96. package/dist/utils/cli-handler.d.ts +16 -0
  97. package/dist/utils/cli-handler.d.ts.map +1 -0
  98. package/dist/utils/cli-handler.js +102 -0
  99. package/dist/utils/cli-handler.js.map +1 -0
  100. package/dist/utils/crypto.d.ts +175 -0
  101. package/dist/utils/crypto.d.ts.map +1 -0
  102. package/dist/utils/crypto.js +612 -0
  103. package/dist/utils/crypto.js.map +1 -0
  104. package/dist/utils/logger.d.ts +61 -0
  105. package/dist/utils/logger.d.ts.map +1 -0
  106. package/dist/utils/logger.js +92 -0
  107. package/dist/utils/logger.js.map +1 -0
  108. package/dist/utils/page-utils.d.ts +54 -0
  109. package/dist/utils/page-utils.d.ts.map +1 -0
  110. package/dist/utils/page-utils.js +405 -0
  111. package/dist/utils/page-utils.js.map +1 -0
  112. package/dist/utils/response-validator.d.ts +98 -0
  113. package/dist/utils/response-validator.d.ts.map +1 -0
  114. package/dist/utils/response-validator.js +352 -0
  115. package/dist/utils/response-validator.js.map +1 -0
  116. package/dist/utils/secrets-scanner.d.ts +126 -0
  117. package/dist/utils/secrets-scanner.d.ts.map +1 -0
  118. package/dist/utils/secrets-scanner.js +443 -0
  119. package/dist/utils/secrets-scanner.js.map +1 -0
  120. package/dist/utils/secure-memory.d.ts +130 -0
  121. package/dist/utils/secure-memory.d.ts.map +1 -0
  122. package/dist/utils/secure-memory.js +279 -0
  123. package/dist/utils/secure-memory.js.map +1 -0
  124. package/dist/utils/security.d.ts +83 -0
  125. package/dist/utils/security.d.ts.map +1 -0
  126. package/dist/utils/security.js +272 -0
  127. package/dist/utils/security.js.map +1 -0
  128. package/dist/utils/settings-manager.d.ts +37 -0
  129. package/dist/utils/settings-manager.d.ts.map +1 -0
  130. package/dist/utils/settings-manager.js +125 -0
  131. package/dist/utils/settings-manager.js.map +1 -0
  132. package/dist/utils/stealth-utils.d.ts +135 -0
  133. package/dist/utils/stealth-utils.d.ts.map +1 -0
  134. package/dist/utils/stealth-utils.js +398 -0
  135. package/dist/utils/stealth-utils.js.map +1 -0
  136. package/dist/utils/tool-validation.d.ts +93 -0
  137. package/dist/utils/tool-validation.d.ts.map +1 -0
  138. package/dist/utils/tool-validation.js +277 -0
  139. package/dist/utils/tool-validation.js.map +1 -0
  140. package/docs/SECURITY_IMPLEMENTATION_PLAN.md +437 -0
  141. package/docs/configuration.md +94 -0
  142. package/docs/tools.md +34 -0
  143. package/docs/troubleshooting.md +59 -0
  144. package/docs/usage-guide.md +245 -0
  145. package/package.json +82 -0
@@ -0,0 +1,245 @@
1
+ # Advanced Usage Guide
2
+
3
+ This guide covers advanced usage patterns, best practices, and detailed examples for the NotebookLM MCP server.
4
+
5
+ > 📘 For installation and quick start, see the main [README](../README.md).
6
+
7
+ ## Research Patterns
8
+
9
+ ### The Iterative Research Pattern
10
+
11
+ The server is designed to make your agent **ask questions automatically** with NotebookLM. Here's how to leverage this:
12
+
13
+ 1. **Start with broad context**
14
+ ```
15
+ "Before implementing the webhook system, research the complete webhook architecture in NotebookLM, including error handling, retry logic, and security considerations."
16
+ ```
17
+
18
+ 2. **The agent will automatically**:
19
+ - Ask an initial question to NotebookLM
20
+ - Read the reminder at the end of each response
21
+ - Ask follow-up questions to gather more details
22
+ - Continue until it has comprehensive understanding
23
+ - Only then provide you with a complete answer
24
+
25
+ 3. **Session management**
26
+ - The agent maintains the same `session_id` throughout the research
27
+ - This preserves context across multiple questions
28
+ - Sessions auto-cleanup after 15 minutes of inactivity
29
+
30
+ ### Deep Dive Example
31
+
32
+ ```
33
+ User: "I need to implement OAuth2 with refresh tokens. Research the complete flow first."
34
+
35
+ Agent behavior:
36
+ 1. Asks NotebookLM: "How does OAuth2 refresh token flow work?"
37
+ 2. Gets answer with reminder to ask more
38
+ 3. Asks: "What are the security best practices for storing refresh tokens?"
39
+ 4. Asks: "How to handle token expiration and renewal?"
40
+ 5. Asks: "What are common implementation pitfalls?"
41
+ 6. Synthesizes all answers into comprehensive implementation plan
42
+ ```
43
+
44
+ ## Notebook Management Strategies
45
+
46
+ ### Multi-Project Setup
47
+
48
+ Organize notebooks by project or domain:
49
+
50
+ ```
51
+ Production Docs Notebook → APIs, deployment, monitoring
52
+ Development Notebook → Local setup, debugging, testing
53
+ Architecture Notebook → System design, patterns, decisions
54
+ Legacy Code Notebook → Old systems, migration guides
55
+ ```
56
+
57
+ ### Notebook Switching Patterns
58
+
59
+ ```
60
+ "For this bug fix, use the Legacy Code notebook."
61
+ "Switch to the Architecture notebook for this design discussion."
62
+ "Use the Production Docs for deployment steps."
63
+ ```
64
+
65
+ ### Metadata Best Practices
66
+
67
+ When adding notebooks, provide rich metadata:
68
+ ```
69
+ "Add this notebook with description: 'Complete React 18 documentation including hooks, performance, and migration guides' and tags: react, frontend, hooks, performance"
70
+ ```
71
+
72
+ ## Authentication Management
73
+
74
+ ### Account Rotation Strategy
75
+
76
+ Free tier provides 50 queries/day per account. Maximize usage:
77
+
78
+ 1. **Primary account** → Main development work
79
+ 2. **Secondary account** → Testing and validation
80
+ 3. **Backup account** → Emergency queries when others are exhausted
81
+
82
+ ```
83
+ "Switch to secondary account" → When approaching limit
84
+ "Check health status" → Verify which account is active
85
+ ```
86
+
87
+ ### Handling Auth Failures
88
+
89
+ The agent can self-repair authentication:
90
+
91
+ ```
92
+ "NotebookLM says I'm logged out—repair authentication"
93
+ ```
94
+
95
+ This triggers: `get_health` → `setup_auth` → `get_health`
96
+
97
+ ## Advanced Configuration
98
+
99
+ ### Performance Optimization
100
+
101
+ For faster interactions during development:
102
+ ```bash
103
+ STEALTH_ENABLED=false # Disable human-like typing
104
+ TYPING_WPM_MAX=500 # Increase typing speed
105
+ HEADLESS=false # See what's happening
106
+ ```
107
+
108
+ ### Debugging Sessions
109
+
110
+ Enable browser visibility to watch the live conversation:
111
+ ```
112
+ "Research this issue and show me the browser"
113
+ ```
114
+
115
+ Your agent automatically enables browser visibility for that research session.
116
+
117
+ ### Session Management
118
+
119
+ Monitor active sessions:
120
+ ```
121
+ "List all active NotebookLM sessions"
122
+ "Close inactive sessions to free resources"
123
+ "Reset the stuck session for notebook X"
124
+ ```
125
+
126
+ ## Complex Workflows
127
+
128
+ ### Multi-Stage Research
129
+
130
+ For complex implementations requiring multiple knowledge sources:
131
+
132
+ ```
133
+ Stage 1: "Research the API structure in the API notebook"
134
+ Stage 2: "Switch to Architecture notebook and research the service patterns"
135
+ Stage 3: "Use the Security notebook to research authentication requirements"
136
+ Stage 4: "Synthesize all findings into implementation plan"
137
+ ```
138
+
139
+ ### Validation Workflow
140
+
141
+ Cross-reference information across notebooks:
142
+
143
+ ```
144
+ 1. "In Production notebook, find the current API version"
145
+ 2. "Switch to Migration notebook, check compatibility notes"
146
+ 3. "Verify in Architecture notebook if this aligns with our patterns"
147
+ ```
148
+
149
+ ## Tool Integration Patterns
150
+
151
+ ### Direct Tool Calls
152
+
153
+ For manual scripting, capture and reuse session IDs:
154
+
155
+ ```json
156
+ // First call - capture session_id
157
+ {
158
+ "tool": "ask_question",
159
+ "question": "What is the webhook structure?",
160
+ "notebook_id": "abc123"
161
+ }
162
+
163
+ // Follow-up - reuse session_id
164
+ {
165
+ "tool": "ask_question",
166
+ "question": "Show me error handling examples",
167
+ "session_id": "captured_session_id_here"
168
+ }
169
+ ```
170
+
171
+ ### Resource URIs
172
+
173
+ Access library data programmatically:
174
+ - `notebooklm://library` - Full library JSON
175
+ - `notebooklm://library/{id}` - Specific notebook metadata
176
+
177
+ ## Best Practices
178
+
179
+ ### 1. **Context Preservation**
180
+ - Always let the agent complete its research cycle
181
+ - Don't interrupt between questions in a research session
182
+ - Use descriptive notebook names for easy switching
183
+
184
+ ### 2. **Knowledge Base Quality**
185
+ - Upload comprehensive documentation to NotebookLM
186
+ - Merge related docs into single notebooks (up to 500k words)
187
+ - Update notebooks when documentation changes
188
+
189
+ ### 3. **Error Recovery**
190
+ - The server auto-recovers from browser crashes
191
+ - Sessions rebuild automatically if context is lost
192
+ - Profile corruption triggers automatic cleanup
193
+
194
+ ### 4. **Resource Management**
195
+ - Close unused sessions to free memory
196
+ - The server maintains max 10 concurrent sessions
197
+ - Inactive sessions auto-close after 15 minutes
198
+
199
+ ### 5. **Security Considerations**
200
+ - Use dedicated Google accounts for NotebookLM
201
+ - Never share authentication profiles between projects
202
+ - Backup `library.json` for important notebook collections
203
+
204
+ ## Troubleshooting Patterns
205
+
206
+ ### When NotebookLM returns incomplete answers
207
+ ```
208
+ "The answer seems incomplete. Ask NotebookLM for more specific details about [topic]"
209
+ ```
210
+
211
+ ### When hitting rate limits
212
+ ```
213
+ "We've hit the rate limit. Re-authenticate with the backup account"
214
+ ```
215
+
216
+ ### When browser seems stuck
217
+ ```
218
+ "Reset all NotebookLM sessions and try again"
219
+ ```
220
+
221
+ ## Example Conversations
222
+
223
+ ### Complete Feature Implementation
224
+ ```
225
+ User: "I need to implement a webhook system with retry logic"
226
+
227
+ You: "Research webhook patterns with retry logic in NotebookLM first"
228
+ Agent: [Researches comprehensively, asking 4-5 follow-up questions]
229
+ Agent: "Based on my research, here's the implementation..."
230
+ [Provides detailed code with patterns from NotebookLM]
231
+ ```
232
+
233
+ ### Architecture Decision
234
+ ```
235
+ User: "Should we use microservices or monolith for this feature?"
236
+
237
+ You: "Research our architecture patterns and decision criteria in the Architecture notebook"
238
+ Agent: [Gathers context about existing patterns, scalability needs, team constraints]
239
+ Agent: "According to our architecture guidelines..."
240
+ [Provides recommendation based on documented patterns]
241
+ ```
242
+
243
+ ---
244
+
245
+ Remember: The power of this integration lies in letting your agent **ask multiple questions** – gathering context and building comprehensive understanding before responding. Don't rush the research phase!
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@pan-sec/notebooklm-mcp",
3
+ "version": "1.4.0",
4
+ "description": "Security-hardened MCP server for NotebookLM API with input validation, rate limiting, and log sanitization",
5
+ "type": "module",
6
+ "bin": {
7
+ "notebooklm-mcp": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "postbuild": "chmod +x dist/index.js",
12
+ "watch": "tsc --watch",
13
+ "dev": "tsx watch src/index.ts",
14
+ "prepare": "npm run build",
15
+ "test": "npx vitest run",
16
+ "test:watch": "npx vitest",
17
+ "security-check": "npm audit",
18
+ "security-scan": "medusa scan . --fail-on high"
19
+ },
20
+ "keywords": [
21
+ "mcp",
22
+ "notebooklm",
23
+ "gemini",
24
+ "ai",
25
+ "claude",
26
+ "security",
27
+ "hardened"
28
+ ],
29
+ "author": "Pantheon Security <support@pantheonsecurity.io> (https://pantheonsecurity.io)",
30
+ "contributors": [
31
+ "Gérôme Dexheimer <hello@geromedexheimer.de> (https://github.com/PleasePrompto) - Original Author"
32
+ ],
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/Pantheon-Security/notebooklm-mcp-secure.git"
37
+ },
38
+ "homepage": "https://github.com/Pantheon-Security/notebooklm-mcp-secure#readme",
39
+ "bugs": {
40
+ "url": "https://github.com/Pantheon-Security/notebooklm-mcp-secure/issues"
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "README.md",
45
+ "SECURITY.md",
46
+ "LICENSE",
47
+ "docs"
48
+ ],
49
+ "dependencies": {
50
+ "@modelcontextprotocol/sdk": "^1.0.0",
51
+ "@noble/post-quantum": "^0.2.1",
52
+ "dotenv": "^16.4.0",
53
+ "env-paths": "^3.0.0",
54
+ "globby": "^14.1.0",
55
+ "patchright": "^1.48.2",
56
+ "zod": "^3.22.0"
57
+ },
58
+ "devDependencies": {
59
+ "@types/node": "^20.11.0",
60
+ "tsx": "^4.7.0",
61
+ "typescript": "^5.3.3"
62
+ },
63
+ "engines": {
64
+ "node": ">=18.0.0"
65
+ },
66
+ "securityHardening": {
67
+ "inputValidation": true,
68
+ "urlWhitelisting": true,
69
+ "rateLimiting": true,
70
+ "logSanitization": true,
71
+ "credentialMasking": true,
72
+ "auditLogging": true,
73
+ "sessionTimeout": true,
74
+ "mcpAuthentication": true,
75
+ "responseValidation": true,
76
+ "postQuantumEncryption": true,
77
+ "secretsScanning": true,
78
+ "certificatePinning": true,
79
+ "memoryScubbing": true,
80
+ "medusaIntegration": true
81
+ }
82
+ }