@musashishao/agent-kit 1.9.0 → 1.9.1
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.
- package/.agent/agents/ai-asset-factory.md +700 -0
- package/.agent/agents/ai-audio-factory.md +503 -0
- package/.agent/agents/game-developer.md +4 -4
- package/.agent/agents/orchestrator.md +113 -3
- package/.agent/agents/project-planner.md +67 -0
- package/.agent/agents/unity-mobile-master.md +949 -0
- package/.agent/mcp/config/registry.json +65 -51
- package/.agent/mcp/servers/notebooklm/README.md +114 -0
- package/.agent/mcp/servers/notebooklm/package.json +35 -0
- package/.agent/mcp/servers/notebooklm/src/auth/chrome.ts +225 -0
- package/.agent/mcp/servers/notebooklm/src/auth/index.ts +1 -0
- package/.agent/mcp/servers/notebooklm/src/index.ts +516 -0
- package/.agent/mcp/servers/notebooklm/src/services/index.ts +3 -0
- package/.agent/mcp/servers/notebooklm/src/services/library.ts +217 -0
- package/.agent/mcp/servers/notebooklm/src/services/notebooklm.ts +380 -0
- package/.agent/mcp/servers/notebooklm/tsconfig.json +15 -0
- package/.agent/mcp-gateway/README.md +169 -20
- package/.agent/mcp-gateway/package.json +22 -7
- package/.agent/mcp-gateway/src/auth/index.ts +55 -0
- package/.agent/mcp-gateway/src/auth/middleware.ts +242 -0
- package/.agent/mcp-gateway/src/auth/oauth.ts +462 -0
- package/.agent/mcp-gateway/src/auth/scopes.ts +227 -0
- package/.agent/mcp-gateway/src/index.ts +252 -105
- package/.agent/mcp-gateway/src/observability/index.ts +5 -0
- package/.agent/mcp-gateway/src/observability/otel.ts +405 -0
- package/.agent/mcp-gateway/src/transports/index.ts +5 -0
- package/.agent/mcp-gateway/src/transports/streamableHttp.ts +235 -0
- package/.agent/rules/CODEX.md +89 -0
- package/.agent/rules/CODE_RULES.md +73 -0
- package/.agent/rules/GEMINI.md +25 -0
- package/.agent/rules/MEMORY_STATE.md +110 -0
- package/.agent/rules/REFERENCE.md +33 -141
- package/.agent/rules/REF_SKILLS.md +116 -0
- package/.agent/rules/REF_WORKFLOWS.md +81 -0
- package/.agent/scripts/ak_cli.py +106 -5
- package/.agent/scripts/memory_manager.py +48 -9
- package/.agent/skills/anti-hallucination/SKILL.md +295 -0
- package/.agent/skills/anti-hallucination/scripts/check_hallucination.py +299 -0
- package/.agent/skills/bifurcation-analysis/SKILL.md +56 -0
- package/.agent/skills/brainstorming/SKILL.md +80 -6
- package/.agent/skills/decision-memory/SKILL.md +317 -0
- package/.agent/skills/emergence-detector/SKILL.md +230 -0
- package/.agent/skills/emergence-detector/scripts/check_emergence.py +265 -0
- package/.agent/skills/explained-qa/SKILL.md +142 -0
- package/.agent/skills/explained-qa/game-terminology.md +214 -0
- package/.agent/skills/game-development/ai-dialogue-engine/SKILL.md +442 -0
- package/.agent/skills/game-development/ai-graphics-generator/SKILL.md +463 -0
- package/.agent/skills/game-development/ai-playtest-framework/SKILL.md +570 -0
- package/.agent/skills/game-development/camera-systems/SKILL.md +607 -0
- package/.agent/skills/game-development/card-battle-engine/SKILL.md +618 -0
- package/.agent/skills/game-development/character-controller-3d/SKILL.md +908 -0
- package/.agent/skills/game-development/cloud-save-sync/SKILL.md +527 -0
- package/.agent/skills/game-development/combat-system/SKILL.md +748 -0
- package/.agent/skills/game-development/compliance-rating/SKILL.md +277 -0
- package/.agent/skills/game-development/crossplatform-build/SKILL.md +386 -0
- package/.agent/skills/game-development/cultivation-progression/SKILL.md +520 -0
- package/.agent/skills/game-development/data-driven-balance/SKILL.md +535 -0
- package/.agent/skills/game-development/game-analytics-integrator/SKILL.md +410 -0
- package/.agent/skills/game-development/game-audio-advanced/SKILL.md +646 -0
- package/.agent/skills/game-development/game-economy-designer/SKILL.md +375 -0
- package/.agent/skills/game-development/game-marketing/SKILL.md +85 -0
- package/.agent/skills/game-development/game-state-manager/SKILL.md +883 -0
- package/.agent/skills/game-development/hybrid-game-spec/SKILL.md +220 -0
- package/.agent/skills/game-development/inventory-quest/SKILL.md +747 -0
- package/.agent/skills/game-development/liveops/SKILL.md +308 -0
- package/.agent/skills/game-development/localization/SKILL.md +286 -0
- package/.agent/skills/game-development/mobile-input-patterns/SKILL.md +343 -0
- package/.agent/skills/game-development/monetization-strategy/SKILL.md +94 -0
- package/.agent/skills/game-development/multiplayer-master/SKILL.md +727 -0
- package/.agent/skills/game-development/narrative-branching/SKILL.md +593 -0
- package/.agent/skills/game-development/procedural-level-ai/SKILL.md +367 -0
- package/.agent/skills/game-development/prototyping-rapid/SKILL.md +205 -0
- package/.agent/skills/game-development/spec-ecosystem/SKILL.md +155 -0
- package/.agent/skills/game-development/spec-ecosystem/decision-log-format.md +129 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/PLAN-template.md +178 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/SPEC-template.md +110 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/TASKS-template.md +156 -0
- package/.agent/skills/game-development/survival-systems/SKILL.md +493 -0
- package/.agent/skills/game-development/testing-qa/SKILL.md +270 -0
- package/.agent/skills/game-development/unity-mobile-optimization/SKILL.md +271 -0
- package/.agent/skills/intent-capture/SKILL.md +65 -0
- package/.agent/skills/mcp-composition/SKILL.md +362 -0
- package/.agent/skills/mcp-observability/SKILL.md +323 -0
- package/.agent/skills/mcp-security/SKILL.md +314 -0
- package/.agent/skills/trust-spectrum/SKILL.md +291 -0
- package/.agent/skills/vibe-coding-guard/SKILL.md +328 -0
- package/.agent/templates/AGENTS.game.md +63 -0
- package/.agent/templates/docs/WORKFLOW_GUIDE.en.md +100 -0
- package/.agent/templates/docs/WORKFLOW_GUIDE.vi.md +100 -0
- package/.agent/workflows/ai-agent.md +2 -0
- package/.agent/workflows/autofix.md +1 -0
- package/.agent/workflows/brainstorm.md +1 -0
- package/.agent/workflows/context.md +1 -0
- package/.agent/workflows/create.md +39 -8
- package/.agent/workflows/dashboard.md +1 -0
- package/.agent/workflows/debug.md +14 -0
- package/.agent/workflows/deploy.md +14 -0
- package/.agent/workflows/enhance.md +44 -0
- package/.agent/workflows/gamekit-init.md +177 -0
- package/.agent/workflows/gamekit-launch.md +338 -0
- package/.agent/workflows/gamekit-plan.md +204 -0
- package/.agent/workflows/gamekit-qa.md +153 -0
- package/.agent/workflows/gamekit-spec.md +243 -0
- package/.agent/workflows/gamekit-tasks.md +208 -0
- package/.agent/workflows/marketing.md +2 -0
- package/.agent/workflows/next.md +1 -0
- package/.agent/workflows/orchestrate.md +12 -0
- package/.agent/workflows/pentest.md +2 -0
- package/.agent/workflows/plan.md +42 -0
- package/.agent/workflows/preview.md +1 -0
- package/.agent/workflows/quality.md +1 -0
- package/.agent/workflows/saas.md +2 -0
- package/.agent/workflows/spec.md +42 -0
- package/.agent/workflows/status.md +1 -0
- package/.agent/workflows/test.md +14 -0
- package/.agent/workflows/ui-ux-pro-max.md +1 -0
- package/bin/cli.js +411 -111
- package/package.json +1 -2
- package/.agent/agents/game-asset-curator.md +0 -317
- package/.agent/agents/game-narrative-designer.md +0 -310
- package/.agent/agents/game-qa-agent.md +0 -441
- package/.agent/workflows/game-prototype.md +0 -154
- package/docs/AI_DATA_INFRASTRUCTURE.md +0 -288
- package/docs/CHANGELOG_AI_INFRA.md +0 -141
- package/docs/MIGRATION_GUIDE_V1.9.md +0 -55
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* NotebookLM MCP Server for Agent Kit
|
|
4
|
+
*
|
|
5
|
+
* Custom implementation with:
|
|
6
|
+
* - Chrome OAuth for Google login
|
|
7
|
+
* - Local library with tags and skill-linking
|
|
8
|
+
* - Agent Kit native integration
|
|
9
|
+
*
|
|
10
|
+
* @author Agent Kit
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
14
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
login,
|
|
19
|
+
loadAuthState,
|
|
20
|
+
logout as authLogout,
|
|
21
|
+
AuthState
|
|
22
|
+
} from "./auth/index.js";
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
listNotebooks,
|
|
26
|
+
queryNotebook,
|
|
27
|
+
createNotebook,
|
|
28
|
+
addSource,
|
|
29
|
+
getSources,
|
|
30
|
+
} from "./services/notebooklm.js";
|
|
31
|
+
|
|
32
|
+
import {
|
|
33
|
+
addToLibrary,
|
|
34
|
+
searchLibrary,
|
|
35
|
+
removeFromLibrary,
|
|
36
|
+
linkToSkill,
|
|
37
|
+
getRecentlyUsed,
|
|
38
|
+
markAsUsed,
|
|
39
|
+
LibraryEntry,
|
|
40
|
+
} from "./services/library.js";
|
|
41
|
+
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// MCP Server
|
|
44
|
+
// ============================================================================
|
|
45
|
+
|
|
46
|
+
const server = new McpServer({
|
|
47
|
+
name: "notebooklm",
|
|
48
|
+
version: "1.0.0",
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Tool: notebooklm_login
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
server.tool(
|
|
56
|
+
"notebooklm_login",
|
|
57
|
+
"Đăng nhập NotebookLM bằng tài khoản Google. Mở Chrome để bạn đăng nhập.",
|
|
58
|
+
{},
|
|
59
|
+
async () => {
|
|
60
|
+
try {
|
|
61
|
+
const state = await login();
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: "text",
|
|
67
|
+
text: JSON.stringify({
|
|
68
|
+
success: true,
|
|
69
|
+
email: state.email,
|
|
70
|
+
message: "Đăng nhập NotebookLM thành công!",
|
|
71
|
+
}, null, 2),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: JSON.stringify({
|
|
81
|
+
error: `Đăng nhập thất bại: ${error}`,
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
// Tool: notebooklm_status
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
server.tool(
|
|
95
|
+
"notebooklm_status",
|
|
96
|
+
"Kiểm tra trạng thái đăng nhập NotebookLM",
|
|
97
|
+
{},
|
|
98
|
+
async () => {
|
|
99
|
+
const state = loadAuthState();
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
content: [
|
|
103
|
+
{
|
|
104
|
+
type: "text",
|
|
105
|
+
text: JSON.stringify({
|
|
106
|
+
authenticated: state.isAuthenticated,
|
|
107
|
+
email: state.email,
|
|
108
|
+
lastChecked: state.lastChecked,
|
|
109
|
+
}, null, 2),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
// Tool: notebooklm_logout
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
server.tool(
|
|
121
|
+
"notebooklm_logout",
|
|
122
|
+
"Đăng xuất khỏi NotebookLM và xóa dữ liệu đăng nhập",
|
|
123
|
+
{},
|
|
124
|
+
async () => {
|
|
125
|
+
authLogout();
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
content: [
|
|
129
|
+
{
|
|
130
|
+
type: "text",
|
|
131
|
+
text: JSON.stringify({
|
|
132
|
+
success: true,
|
|
133
|
+
message: "Đã đăng xuất và xóa dữ liệu đăng nhập",
|
|
134
|
+
}, null, 2),
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// Tool: notebooklm_list_notebooks
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
|
|
145
|
+
server.tool(
|
|
146
|
+
"notebooklm_list_notebooks",
|
|
147
|
+
"Liệt kê tất cả notebooks trong NotebookLM của bạn",
|
|
148
|
+
{},
|
|
149
|
+
async () => {
|
|
150
|
+
try {
|
|
151
|
+
const notebooks = await listNotebooks();
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
content: [
|
|
155
|
+
{
|
|
156
|
+
type: "text",
|
|
157
|
+
text: JSON.stringify({
|
|
158
|
+
count: notebooks.length,
|
|
159
|
+
notebooks,
|
|
160
|
+
}, null, 2),
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
} catch (error) {
|
|
165
|
+
return {
|
|
166
|
+
content: [
|
|
167
|
+
{
|
|
168
|
+
type: "text",
|
|
169
|
+
text: JSON.stringify({ error: `${error}` }),
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// Tool: notebooklm_query
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
server.tool(
|
|
182
|
+
"notebooklm_query",
|
|
183
|
+
"Hỏi đáp dựa trên nội dung notebook. Trả về câu trả lời với citations nếu có.",
|
|
184
|
+
{
|
|
185
|
+
notebook_id: z.string().describe("ID của notebook (lấy từ list_notebooks)"),
|
|
186
|
+
question: z.string().describe("Câu hỏi của bạn"),
|
|
187
|
+
include_citations: z.boolean().optional().describe("Có bao gồm trích dẫn nguồn không"),
|
|
188
|
+
},
|
|
189
|
+
async ({ notebook_id, question, include_citations }) => {
|
|
190
|
+
try {
|
|
191
|
+
// Mark as used in library
|
|
192
|
+
markAsUsed(notebook_id);
|
|
193
|
+
|
|
194
|
+
const result = await queryNotebook(notebook_id, question, {
|
|
195
|
+
includeCitations: include_citations
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
content: [
|
|
200
|
+
{
|
|
201
|
+
type: "text",
|
|
202
|
+
text: JSON.stringify({
|
|
203
|
+
question,
|
|
204
|
+
answer: result.answer,
|
|
205
|
+
citations: result.citations,
|
|
206
|
+
}, null, 2),
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
};
|
|
210
|
+
} catch (error) {
|
|
211
|
+
return {
|
|
212
|
+
content: [
|
|
213
|
+
{
|
|
214
|
+
type: "text",
|
|
215
|
+
text: JSON.stringify({ error: `${error}` }),
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
// Tool: notebooklm_create_notebook
|
|
225
|
+
// ---------------------------------------------------------------------------
|
|
226
|
+
|
|
227
|
+
server.tool(
|
|
228
|
+
"notebooklm_create_notebook",
|
|
229
|
+
"Tạo một notebook mới trong NotebookLM",
|
|
230
|
+
{
|
|
231
|
+
title: z.string().describe("Tên của notebook"),
|
|
232
|
+
},
|
|
233
|
+
async ({ title }) => {
|
|
234
|
+
try {
|
|
235
|
+
const notebook = await createNotebook(title);
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
content: [
|
|
239
|
+
{
|
|
240
|
+
type: "text",
|
|
241
|
+
text: JSON.stringify({
|
|
242
|
+
success: true,
|
|
243
|
+
notebook,
|
|
244
|
+
message: `Đã tạo notebook "${title}"`,
|
|
245
|
+
}, null, 2),
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
};
|
|
249
|
+
} catch (error) {
|
|
250
|
+
return {
|
|
251
|
+
content: [
|
|
252
|
+
{
|
|
253
|
+
type: "text",
|
|
254
|
+
text: JSON.stringify({ error: `${error}` }),
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
// ---------------------------------------------------------------------------
|
|
263
|
+
// Tool: notebooklm_add_source
|
|
264
|
+
// ---------------------------------------------------------------------------
|
|
265
|
+
|
|
266
|
+
server.tool(
|
|
267
|
+
"notebooklm_add_source",
|
|
268
|
+
"Thêm nguồn tài liệu (URL hoặc text) vào notebook",
|
|
269
|
+
{
|
|
270
|
+
notebook_id: z.string().describe("ID của notebook"),
|
|
271
|
+
source_type: z.enum(["url", "text"]).describe("Loại nguồn: url hoặc text"),
|
|
272
|
+
content: z.string().describe("URL hoặc nội dung text"),
|
|
273
|
+
},
|
|
274
|
+
async ({ notebook_id, source_type, content }) => {
|
|
275
|
+
try {
|
|
276
|
+
const source = await addSource(notebook_id, source_type, content);
|
|
277
|
+
|
|
278
|
+
return {
|
|
279
|
+
content: [
|
|
280
|
+
{
|
|
281
|
+
type: "text",
|
|
282
|
+
text: JSON.stringify({
|
|
283
|
+
success: true,
|
|
284
|
+
source,
|
|
285
|
+
message: `Đã thêm nguồn vào notebook`,
|
|
286
|
+
}, null, 2),
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
};
|
|
290
|
+
} catch (error) {
|
|
291
|
+
return {
|
|
292
|
+
content: [
|
|
293
|
+
{
|
|
294
|
+
type: "text",
|
|
295
|
+
text: JSON.stringify({ error: `${error}` }),
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
// ---------------------------------------------------------------------------
|
|
304
|
+
// Tool: notebooklm_get_sources
|
|
305
|
+
// ---------------------------------------------------------------------------
|
|
306
|
+
|
|
307
|
+
server.tool(
|
|
308
|
+
"notebooklm_get_sources",
|
|
309
|
+
"Liệt kê các nguồn trong một notebook",
|
|
310
|
+
{
|
|
311
|
+
notebook_id: z.string().describe("ID của notebook"),
|
|
312
|
+
},
|
|
313
|
+
async ({ notebook_id }) => {
|
|
314
|
+
try {
|
|
315
|
+
const sources = await getSources(notebook_id);
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
content: [
|
|
319
|
+
{
|
|
320
|
+
type: "text",
|
|
321
|
+
text: JSON.stringify({
|
|
322
|
+
count: sources.length,
|
|
323
|
+
sources,
|
|
324
|
+
}, null, 2),
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
};
|
|
328
|
+
} catch (error) {
|
|
329
|
+
return {
|
|
330
|
+
content: [
|
|
331
|
+
{
|
|
332
|
+
type: "text",
|
|
333
|
+
text: JSON.stringify({ error: `${error}` }),
|
|
334
|
+
},
|
|
335
|
+
],
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
// ---------------------------------------------------------------------------
|
|
342
|
+
// Tool: notebooklm_library_add
|
|
343
|
+
// ---------------------------------------------------------------------------
|
|
344
|
+
|
|
345
|
+
server.tool(
|
|
346
|
+
"notebooklm_library_add",
|
|
347
|
+
"Lưu notebook vào thư viện local với tags và mô tả. Hỗ trợ skill-linking.",
|
|
348
|
+
{
|
|
349
|
+
notebook_id: z.string().describe("ID của notebook"),
|
|
350
|
+
notebook_url: z.string().describe("URL của notebook"),
|
|
351
|
+
title: z.string().describe("Tiêu đề"),
|
|
352
|
+
description: z.string().optional().describe("Mô tả ngắn"),
|
|
353
|
+
tags: z.array(z.string()).optional().describe("Tags (ví dụ: ['react', 'frontend'])"),
|
|
354
|
+
skills: z.array(z.string()).optional().describe("Agent Kit skills liên quan (ví dụ: ['react-patterns'])"),
|
|
355
|
+
},
|
|
356
|
+
async ({ notebook_id, notebook_url, title, description, tags, skills }) => {
|
|
357
|
+
const entry = addToLibrary(notebook_id, notebook_url, title, {
|
|
358
|
+
description,
|
|
359
|
+
tags,
|
|
360
|
+
skills,
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
content: [
|
|
365
|
+
{
|
|
366
|
+
type: "text",
|
|
367
|
+
text: JSON.stringify({
|
|
368
|
+
success: true,
|
|
369
|
+
entry,
|
|
370
|
+
message: `Đã lưu "${title}" vào thư viện`,
|
|
371
|
+
}, null, 2),
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
// ---------------------------------------------------------------------------
|
|
379
|
+
// Tool: notebooklm_library_search
|
|
380
|
+
// ---------------------------------------------------------------------------
|
|
381
|
+
|
|
382
|
+
server.tool(
|
|
383
|
+
"notebooklm_library_search",
|
|
384
|
+
"Tìm kiếm trong thư viện local theo tags, skills, hoặc từ khóa",
|
|
385
|
+
{
|
|
386
|
+
tags: z.array(z.string()).optional().describe("Lọc theo tags"),
|
|
387
|
+
skills: z.array(z.string()).optional().describe("Lọc theo skills"),
|
|
388
|
+
query: z.string().optional().describe("Tìm trong title/description"),
|
|
389
|
+
},
|
|
390
|
+
async ({ tags, skills, query }) => {
|
|
391
|
+
const results = searchLibrary({ tags, skills, query });
|
|
392
|
+
|
|
393
|
+
return {
|
|
394
|
+
content: [
|
|
395
|
+
{
|
|
396
|
+
type: "text",
|
|
397
|
+
text: JSON.stringify({
|
|
398
|
+
count: results.length,
|
|
399
|
+
entries: results,
|
|
400
|
+
}, null, 2),
|
|
401
|
+
},
|
|
402
|
+
],
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
// ---------------------------------------------------------------------------
|
|
408
|
+
// Tool: notebooklm_library_recent
|
|
409
|
+
// ---------------------------------------------------------------------------
|
|
410
|
+
|
|
411
|
+
server.tool(
|
|
412
|
+
"notebooklm_library_recent",
|
|
413
|
+
"Hiển thị các notebooks đã dùng gần đây",
|
|
414
|
+
{
|
|
415
|
+
limit: z.number().optional().describe("Số lượng tối đa (mặc định: 5)"),
|
|
416
|
+
},
|
|
417
|
+
async ({ limit }) => {
|
|
418
|
+
const results = getRecentlyUsed(limit || 5);
|
|
419
|
+
|
|
420
|
+
return {
|
|
421
|
+
content: [
|
|
422
|
+
{
|
|
423
|
+
type: "text",
|
|
424
|
+
text: JSON.stringify({
|
|
425
|
+
count: results.length,
|
|
426
|
+
entries: results,
|
|
427
|
+
}, null, 2),
|
|
428
|
+
},
|
|
429
|
+
],
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
// ---------------------------------------------------------------------------
|
|
435
|
+
// Tool: notebooklm_skill_link
|
|
436
|
+
// ---------------------------------------------------------------------------
|
|
437
|
+
|
|
438
|
+
server.tool(
|
|
439
|
+
"notebooklm_skill_link",
|
|
440
|
+
"Liên kết notebook với một Agent Kit skill (ví dụ: react-patterns)",
|
|
441
|
+
{
|
|
442
|
+
entry_id: z.string().describe("ID trong thư viện local"),
|
|
443
|
+
skill_name: z.string().describe("Tên skill (từ .agent/skills/)"),
|
|
444
|
+
},
|
|
445
|
+
async ({ entry_id, skill_name }) => {
|
|
446
|
+
const entry = linkToSkill(entry_id, skill_name);
|
|
447
|
+
|
|
448
|
+
if (!entry) {
|
|
449
|
+
return {
|
|
450
|
+
content: [
|
|
451
|
+
{
|
|
452
|
+
type: "text",
|
|
453
|
+
text: JSON.stringify({ error: "Entry không tồn tại" }),
|
|
454
|
+
},
|
|
455
|
+
],
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return {
|
|
460
|
+
content: [
|
|
461
|
+
{
|
|
462
|
+
type: "text",
|
|
463
|
+
text: JSON.stringify({
|
|
464
|
+
success: true,
|
|
465
|
+
entry,
|
|
466
|
+
message: `Đã liên kết với skill "${skill_name}"`,
|
|
467
|
+
}, null, 2),
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
// ---------------------------------------------------------------------------
|
|
475
|
+
// Resource: library
|
|
476
|
+
// ---------------------------------------------------------------------------
|
|
477
|
+
|
|
478
|
+
server.resource(
|
|
479
|
+
"library-list",
|
|
480
|
+
"notebooklm://library",
|
|
481
|
+
async () => {
|
|
482
|
+
const entries = searchLibrary();
|
|
483
|
+
|
|
484
|
+
return {
|
|
485
|
+
contents: [
|
|
486
|
+
{
|
|
487
|
+
uri: "notebooklm://library",
|
|
488
|
+
mimeType: "application/json",
|
|
489
|
+
text: JSON.stringify(entries, null, 2),
|
|
490
|
+
},
|
|
491
|
+
],
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
// ============================================================================
|
|
497
|
+
// Main
|
|
498
|
+
// ============================================================================
|
|
499
|
+
|
|
500
|
+
async function main() {
|
|
501
|
+
const state = loadAuthState();
|
|
502
|
+
|
|
503
|
+
if (!state.isAuthenticated) {
|
|
504
|
+
console.error("⚠️ Chưa đăng nhập NotebookLM.");
|
|
505
|
+
console.error(' Dùng tool "notebooklm_login" để đăng nhập.');
|
|
506
|
+
} else {
|
|
507
|
+
console.error(`✅ Đã đăng nhập: ${state.email || "Unknown"}`);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const transport = new StdioServerTransport();
|
|
511
|
+
await server.connect(transport);
|
|
512
|
+
|
|
513
|
+
console.error("🎓 NotebookLM MCP Server for Agent Kit running on stdio");
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
main().catch(console.error);
|