get_notebook_mcp_server 1.0.1 → 1.0.3
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/README.md +32 -2
- package/index.js +28 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,6 +41,36 @@ You can test the MCP server interactively using the MCP Inspector:
|
|
|
41
41
|
npx @modelcontextprotocol/inspector node index.js
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
### Running with npx
|
|
45
|
+
|
|
46
|
+
You can run the server directly without installing it using `npx`:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx get_notebook_mcp_server
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### MCP Configuration (Claude Desktop)
|
|
53
|
+
|
|
54
|
+
Add the following configuration to your `claude_desktop_config.json`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"get-notes": {
|
|
60
|
+
"command": "npx",
|
|
61
|
+
"args": [
|
|
62
|
+
"-y",
|
|
63
|
+
"get_notebook_mcp_server"
|
|
64
|
+
],
|
|
65
|
+
"env": {
|
|
66
|
+
"GET_API_KEY": "your_api_key_here",
|
|
67
|
+
"GET_NOTE_TOPIC_ID": "your_topic_id_here"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
44
74
|
### Tools
|
|
45
75
|
|
|
46
76
|
#### `search_knowledge`
|
|
@@ -48,7 +78,7 @@ Search the knowledge base with AI processing.
|
|
|
48
78
|
|
|
49
79
|
**Parameters:**
|
|
50
80
|
- `question` (string, required): The question to ask.
|
|
51
|
-
- `topic_ids` (array<string>,
|
|
81
|
+
- `topic_ids` (array<string>, optional): List of knowledge base IDs. If not provided, uses `GET_NOTE_TOPIC_ID` from environment.
|
|
52
82
|
- `deep_seek` (boolean): Enable deep thinking mode (default: true).
|
|
53
83
|
- `history` (array): Chat history for context.
|
|
54
84
|
|
|
@@ -57,7 +87,7 @@ Raw recall from knowledge base without AI synthesis.
|
|
|
57
87
|
|
|
58
88
|
**Parameters:**
|
|
59
89
|
- `question` (string, required): The question or query.
|
|
60
|
-
- `topic_id` (string,
|
|
90
|
+
- `topic_id` (string, optional): Knowledge base ID. If not provided, uses `GET_NOTE_TOPIC_ID` from environment.
|
|
61
91
|
- `top_k` (number): Number of results to return (default: 10).
|
|
62
92
|
- `intent_rewrite` (boolean): Enable intent rewrite (default: false).
|
|
63
93
|
|
package/index.js
CHANGED
|
@@ -13,6 +13,8 @@ import logger from './src/logger.js';
|
|
|
13
13
|
dotenv.config();
|
|
14
14
|
|
|
15
15
|
const API_KEY = process.env.GET_API_KEY;
|
|
16
|
+
const DEFAULT_TOPIC_ID = process.env.GET_NOTE_TOPIC_ID;
|
|
17
|
+
|
|
16
18
|
if (!API_KEY) {
|
|
17
19
|
logger.error('GET_API_KEY environment variable is required');
|
|
18
20
|
process.exit(1);
|
|
@@ -48,7 +50,7 @@ const SEARCH_KNOWLEDGE_TOOL = {
|
|
|
48
50
|
topic_ids: {
|
|
49
51
|
type: 'array',
|
|
50
52
|
items: { type: 'string' },
|
|
51
|
-
description: 'List of knowledge base IDs
|
|
53
|
+
description: 'List of knowledge base IDs. If not provided, uses the default configured topic ID.'
|
|
52
54
|
},
|
|
53
55
|
deep_seek: {
|
|
54
56
|
type: 'boolean',
|
|
@@ -67,7 +69,7 @@ const SEARCH_KNOWLEDGE_TOOL = {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
},
|
|
70
|
-
required: ['question'
|
|
72
|
+
required: ['question']
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
75
|
|
|
@@ -83,7 +85,7 @@ const RECALL_KNOWLEDGE_TOOL = {
|
|
|
83
85
|
},
|
|
84
86
|
topic_id: {
|
|
85
87
|
type: 'string',
|
|
86
|
-
description: 'Knowledge base ID'
|
|
88
|
+
description: 'Knowledge base ID. If not provided, uses the default configured topic ID.'
|
|
87
89
|
},
|
|
88
90
|
top_k: {
|
|
89
91
|
type: 'number',
|
|
@@ -96,7 +98,7 @@ const RECALL_KNOWLEDGE_TOOL = {
|
|
|
96
98
|
default: false
|
|
97
99
|
}
|
|
98
100
|
},
|
|
99
|
-
required: ['question'
|
|
101
|
+
required: ['question']
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
104
|
|
|
@@ -112,22 +114,23 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
112
114
|
|
|
113
115
|
switch (name) {
|
|
114
116
|
case 'search_knowledge': {
|
|
115
|
-
const params = args;
|
|
117
|
+
const params = { ...args };
|
|
118
|
+
|
|
119
|
+
// Handle default topic_ids
|
|
120
|
+
if (!params.topic_ids || params.topic_ids.length === 0) {
|
|
121
|
+
if (DEFAULT_TOPIC_ID) {
|
|
122
|
+
params.topic_ids = [DEFAULT_TOPIC_ID];
|
|
123
|
+
} else {
|
|
124
|
+
throw new Error('topic_ids is required (no default configured)');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
116
128
|
// Ensure topic_ids is array
|
|
117
129
|
if (!Array.isArray(params.topic_ids)) {
|
|
118
130
|
throw new Error('topic_ids must be an array');
|
|
119
131
|
}
|
|
120
132
|
|
|
121
133
|
const response = await apiClient.searchKnowledge(params);
|
|
122
|
-
// Handle stream or json response. For MCP tool, we typically wait for full response or handle stream if supported.
|
|
123
|
-
// The API guide says /stream is optional path, but client uses post /knowledge/search.
|
|
124
|
-
// If it returns stream, we might need to buffer it or use the non-stream version.
|
|
125
|
-
// For simplicity in this version, we assume non-stream JSON response unless stream param is explicitly handled.
|
|
126
|
-
// Actually the API guide shows stream response format. Let's assume we want the final answer.
|
|
127
|
-
// If the API returns a stream, axios might return a stream object.
|
|
128
|
-
|
|
129
|
-
// For now, let's assume standard JSON response if stream is not set to true in params.
|
|
130
|
-
// If the user wants stream, we might need a different approach, but MCP tools usually return text.
|
|
131
134
|
|
|
132
135
|
return {
|
|
133
136
|
content: [
|
|
@@ -140,7 +143,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
case 'recall_knowledge': {
|
|
143
|
-
const params = args;
|
|
146
|
+
const params = { ...args };
|
|
147
|
+
|
|
148
|
+
// Handle default topic_id
|
|
149
|
+
if (!params.topic_id) {
|
|
150
|
+
if (DEFAULT_TOPIC_ID) {
|
|
151
|
+
params.topic_id = DEFAULT_TOPIC_ID;
|
|
152
|
+
} else {
|
|
153
|
+
throw new Error('topic_id is required (no default configured)');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
144
157
|
const response = await apiClient.recallKnowledge(params);
|
|
145
158
|
return {
|
|
146
159
|
content: [
|