mcp-server-knowledgebase 0.2.0__tar.gz → 0.2.1__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,413 @@
1
+ Metadata-Version: 2.5
2
+ Name: mcp-server-knowledgebase
3
+ Version: 0.2.1
4
+ Summary: MCP server for Viking Knowledge Base Service
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: aiohttp>=3.11.14
8
+ Requires-Dist: mcp[cli]<3,>=2.1.1
9
+ Requires-Dist: volcengine>=1.0.171
10
+ Description-Content-Type: text/markdown
11
+
12
+ # Viking Knowledge Base MCP Server
13
+
14
+ [简体中文](README_zh.md)
15
+
16
+ ## Overview
17
+
18
+ Viking Knowledge Base MCP Server lets MCP clients such as Claude Desktop,
19
+ Cursor, Cline, and Trae interact with VolcEngine Viking Knowledge Base. It
20
+ supports managing and inspecting collections and documents, and searching for
21
+ relevant knowledge chunks.
22
+
23
+ ## Features
24
+
25
+ - Add a document to a knowledge base collection by URL
26
+ - Get document information and processing status
27
+ - List documents with cursor pagination
28
+ - Get collection information and build status
29
+ - List collections in the configured project
30
+ - Search a collection with optional document filtering
31
+ - Authenticate with either a Viking API key or VolcEngine AK/SK credentials
32
+ - Run over stdio or stateless Streamable HTTP
33
+
34
+ ## Prerequisites
35
+
36
+ - Python 3.10 or later
37
+ - A Viking Knowledge Base API key, or VolcEngine AK/SK credentials
38
+
39
+ ## Installation
40
+
41
+ Install from PyPI:
42
+
43
+ ```bash
44
+ pip install mcp-server-knowledgebase
45
+ ```
46
+
47
+ Or install it as a persistent command-line tool with `uv`:
48
+
49
+ ```bash
50
+ uv tool install mcp-server-knowledgebase
51
+ ```
52
+
53
+ For local development, clone the repository and install this package in
54
+ editable mode:
55
+
56
+ ```bash
57
+ git clone https://github.com/volcengine/mcp-server.git
58
+ cd mcp-server/server/mcp_server_knowledgebase
59
+ uv pip install -e .
60
+ ```
61
+
62
+ ## Configuration
63
+
64
+ ### Authentication
65
+
66
+ Configure at least one authentication method:
67
+
68
+ - API key: set `VIKING_API_KEY`. Requests use
69
+ `Authorization: Bearer <VIKING_API_KEY>`.
70
+ - AK/SK: set both `VOLCENGINE_ACCESS_KEY` and
71
+ `VOLCENGINE_SECRET_KEY`. Requests use VolcEngine SignerV4 authentication.
72
+
73
+ When both methods are configured, `VIKING_API_KEY` takes precedence. If no API
74
+ key is set, the access key and secret key must be configured together.
75
+
76
+ ### Environment variables
77
+
78
+ | Environment variable | Description | Default |
79
+ |---|---|---|
80
+ | `VIKING_API_KEY` | Viking Knowledge Base API key; takes precedence when configured | - |
81
+ | `VOLCENGINE_ACCESS_KEY` | VolcEngine access key | - |
82
+ | `VOLCENGINE_SECRET_KEY` | VolcEngine secret key | - |
83
+ | `KNOWLEDGE_BASE_PROJECT` | Viking Knowledge Base project | `default` |
84
+ | `KNOWLEDGE_BASE_REGION` | VolcEngine region used for AK/SK signing | `cn-north-1` |
85
+ | `KNOWLEDGE_BASE_TIMEOUT` | Upstream request timeout in seconds | `30` |
86
+ | `MCP_SERVER_HOST` | Streamable HTTP bind host | `127.0.0.1` |
87
+ | `MCP_SERVER_PORT` | Streamable HTTP port; falls back to `PORT` | `8000` |
88
+ | `STREAMABLE_HTTP_PATH` | Streamable HTTP endpoint path | `/mcp` |
89
+
90
+ ## Running the server
91
+
92
+ Run with the default stdio transport:
93
+
94
+ ```bash
95
+ mcp-server-knowledgebase
96
+ ```
97
+
98
+ Run the published package without installing it persistently:
99
+
100
+ ```bash
101
+ uvx --from mcp-server-knowledgebase mcp-server-knowledgebase
102
+ ```
103
+
104
+ Or run the module directly from a source checkout:
105
+
106
+ ```bash
107
+ python -m mcp_server_knowledgebase.server --transport stdio
108
+ ```
109
+
110
+ Run with stateless Streamable HTTP:
111
+
112
+ ```bash
113
+ mcp-server-knowledgebase --transport streamable-http
114
+ ```
115
+
116
+ The default endpoint is `http://127.0.0.1:8000/mcp`. Set
117
+ `MCP_SERVER_HOST=0.0.0.0` only when deploying behind a trusted gateway.
118
+
119
+ ### MCP protocol and deployment security
120
+
121
+ The server uses MCP Python SDK 2.x and supports protocol revision `2026-07-28`,
122
+ including stateless `server/discover` negotiation. The SDK also handles older
123
+ handshake-based clients. Legacy HTTP+SSE is not exposed because it is
124
+ deprecated by the `2026-07-28` specification.
125
+
126
+ Streamable HTTP does not turn the configured Viking API key or VolcEngine
127
+ AK/SK into client authentication. Protect remote deployments with an
128
+ authentication gateway or MCP-compatible OAuth, and never expose service
129
+ credentials to callers.
130
+
131
+ ## Available tools
132
+
133
+ - [`add_doc`](https://www.volcengine.com/docs/84313/1254624): Add a document by URL
134
+ - [`get_doc`](https://www.volcengine.com/docs/84313/1254615): Get document information and processing status
135
+ - [`list_docs`](https://docs.volcengine.com/docs/84313/2477871?lang=zh): List documents with cursor pagination
136
+ - [`get_collection`](https://www.volcengine.com/docs/84313/1254602): Get collection information
137
+ - [`list_collections`](https://www.volcengine.com/docs/84313/1254596): List collections in the configured project
138
+ - [`search_knowledge`](https://www.volcengine.com/docs/84313/1350012): Search knowledge in a collection
139
+
140
+ ### `add_doc`
141
+
142
+ Add a supported document to a collection by URL.
143
+
144
+ ```python
145
+ add_doc(
146
+ collection_name="product_docs",
147
+ add_type="url",
148
+ doc_id="product_guide_2026",
149
+ doc_name="Product Guide",
150
+ doc_type="pdf",
151
+ url="https://example.com/product-guide.pdf",
152
+ )
153
+ ```
154
+
155
+ Parameters:
156
+
157
+ - `collection_name` (required): Target collection name.
158
+ - `add_type` (required): Currently only `"url"` is supported.
159
+ - `doc_id` (required): Unique ID containing only letters, numbers, and
160
+ underscores. It must start with a letter and contain 1–128 characters.
161
+ - `doc_name` (required): Document name containing 1–256 characters.
162
+ - `doc_type` (required): One of `xlsx`, `csv`, `jsonl`, `txt`, `doc`, `docx`,
163
+ `pdf`, `markdown`, `faq.xlsx`, or `pptx`.
164
+ - `url` (required): Accessible URL of the document.
165
+
166
+ Example result:
167
+
168
+ ```json
169
+ {
170
+ "collection_name": "product_docs",
171
+ "doc_id": "product_guide_2026"
172
+ }
173
+ ```
174
+
175
+ ### `get_doc`
176
+
177
+ Get a document's metadata and processing status.
178
+
179
+ ```python
180
+ get_doc(
181
+ collection_name="product_docs",
182
+ doc_id="product_guide_2026",
183
+ )
184
+ ```
185
+
186
+ Parameters:
187
+
188
+ - `collection_name` (required): Collection containing the document.
189
+ - `doc_id` (required): Document ID.
190
+
191
+ Example result:
192
+
193
+ ```json
194
+ {
195
+ "collection_name": "product_docs",
196
+ "doc_id": "product_guide_2026",
197
+ "doc_name": "Product Guide",
198
+ "doc_type": "pdf",
199
+ "url": "https://example.com/product-guide.pdf",
200
+ "add_type": "url",
201
+ "create_time": 1788220800,
202
+ "update_time": 1788220860,
203
+ "point_num": 53,
204
+ "status": {
205
+ "process_status": 0,
206
+ "failed_code": null
207
+ }
208
+ }
209
+ ```
210
+
211
+ `process_status` values: `0` completed, `1` failed, `2` or `3` queued, `5`
212
+ deleting, and `6` processing. Fields not returned by Viking are `null`;
213
+ additional upstream document fields are preserved.
214
+
215
+ ### `list_docs`
216
+
217
+ List documents in a collection using cursor pagination.
218
+
219
+ ```python
220
+ list_docs(
221
+ collection_name="product_docs",
222
+ limit=2,
223
+ next_token=None,
224
+ )
225
+ ```
226
+
227
+ Parameters:
228
+
229
+ - `collection_name` (required): Collection whose documents will be listed.
230
+ - `limit` (optional): Number of documents to return, from 1 to 100. Defaults
231
+ to `100`.
232
+ - `next_token` (optional): Opaque cursor returned by the previous call. Omit
233
+ it for the first page. An empty cursor in the result means all documents
234
+ have been returned.
235
+
236
+ Example result:
237
+
238
+ ```json
239
+ {
240
+ "collection_name": "product_docs",
241
+ "total_num": 3,
242
+ "count": 2,
243
+ "doc_list": [
244
+ {
245
+ "collection_name": "product_docs",
246
+ "doc_id": "product_guide_2026",
247
+ "doc_name": "Product Guide",
248
+ "doc_type": "pdf",
249
+ "url": "https://example.com/product-guide.pdf",
250
+ "add_type": "url",
251
+ "create_time": 1788220800,
252
+ "update_time": 1788220860,
253
+ "point_num": 53,
254
+ "status": {
255
+ "process_status": 0
256
+ },
257
+ "brief_summary": "An introduction to the product.",
258
+ "total_tokens": 345
259
+ }
260
+ ],
261
+ "has_more": true,
262
+ "next_token": "opaque-cursor-for-next-page"
263
+ }
264
+ ```
265
+
266
+ `total_num` is `null` when Viking does not provide it. Document entries
267
+ preserve additional upstream fields such as summaries and token counts.
268
+
269
+ ### `get_collection`
270
+
271
+ Get information and build status for a collection.
272
+
273
+ ```python
274
+ get_collection(collection_name="product_docs")
275
+ ```
276
+
277
+ Parameters:
278
+
279
+ - `collection_name` (required): Collection name.
280
+
281
+ Example result:
282
+
283
+ ```json
284
+ {
285
+ "collection_name": "product_docs",
286
+ "description": "Product manuals and release notes",
287
+ "status": 1
288
+ }
289
+ ```
290
+
291
+ Collection status values: `-1` pending build, `0` building, `1` completed,
292
+ `2` failed, and `3` changing.
293
+
294
+ ### `list_collections`
295
+
296
+ List all collections in the globally configured project.
297
+
298
+ ```python
299
+ list_collections()
300
+ ```
301
+
302
+ This tool has no parameters.
303
+
304
+ Example result:
305
+
306
+ ```json
307
+ {
308
+ "collection_list": [
309
+ {
310
+ "collection_name": "product_docs",
311
+ "description": "Product manuals and release notes"
312
+ },
313
+ {
314
+ "collection_name": "support_faq",
315
+ "description": "Frequently asked support questions"
316
+ }
317
+ ]
318
+ }
319
+ ```
320
+
321
+ ### `search_knowledge`
322
+
323
+ Search for relevant chunks in a collection. An optional document filter can
324
+ include or exclude matching document field values.
325
+
326
+ ```python
327
+ search_knowledge(
328
+ query="How do I reset my password?",
329
+ collection_name="support_faq",
330
+ limit=3,
331
+ doc_filter={
332
+ "op": "must",
333
+ "field": "doc_id",
334
+ "conds": ["account_guide"],
335
+ },
336
+ )
337
+ ```
338
+
339
+ Parameters:
340
+
341
+ - `query` (required): Search query.
342
+ - `collection_name` (required): Collection to search.
343
+ - `limit` (optional): Maximum number of chunks to return, from 1 to 100.
344
+ Defaults to `3`.
345
+ - `doc_filter` (optional): Object with the following fields:
346
+ - `op`: `"must"` to include matches or `"must_not"` to exclude them.
347
+ - `field`: Document field to filter, such as `"doc_id"`.
348
+ - `conds`: Non-empty list of values to match.
349
+
350
+ Example result:
351
+
352
+ ```json
353
+ {
354
+ "result_list": [
355
+ {
356
+ "id": "chunk_001",
357
+ "content": "Open Account Settings and select Reset Password.",
358
+ "doc_id": "account_guide",
359
+ "doc_name": "Account Guide"
360
+ }
361
+ ]
362
+ }
363
+ ```
364
+
365
+ `doc_id` and `doc_name` are `null` when Viking does not provide document
366
+ metadata. A non-null `doc_id` can be passed directly to `get_doc`.
367
+
368
+ ## MCP client configuration
369
+
370
+ Example stdio configuration using `uvx` and a Viking API key:
371
+
372
+ ```json
373
+ {
374
+ "mcpServers": {
375
+ "knowledgebase": {
376
+ "command": "uvx",
377
+ "args": [
378
+ "--from",
379
+ "mcp-server-knowledgebase>=0.2.1",
380
+ "mcp-server-knowledgebase"
381
+ ],
382
+ "env": {
383
+ "VIKING_API_KEY": "your-viking-api-key",
384
+ "KNOWLEDGE_BASE_PROJECT": "your-project-name",
385
+ "KNOWLEDGE_BASE_REGION": "cn-north-1"
386
+ }
387
+ }
388
+ }
389
+ }
390
+ ```
391
+
392
+ You can instead configure both `VOLCENGINE_ACCESS_KEY` and
393
+ `VOLCENGINE_SECRET_KEY`. If all three credentials are present,
394
+ `VIKING_API_KEY` takes precedence.
395
+
396
+ ## Troubleshooting
397
+
398
+ 1. Authentication errors
399
+ - Verify the API key or AK/SK credentials.
400
+ - When using AK/SK, configure both values together.
401
+ - Check that the credentials can access the configured project and collection.
402
+ 2. Connection timeouts
403
+ - Check network connectivity to the VolcEngine API.
404
+ - Adjust `KNOWLEDGE_BASE_TIMEOUT` when necessary.
405
+ 3. Empty results
406
+ - Verify the project and collection names.
407
+ - For search, try a broader query or remove the document filter.
408
+ - For document listing, continue only with the exact `next_token` returned
409
+ by the previous call.
410
+
411
+ ## License
412
+
413
+ This project is licensed under the [MIT License](https://github.com/volcengine/mcp-server/blob/main/LICENSE).