knowledge_search
Search the Get笔记 knowledge base using AI-enhanced queries to find processed answers. Supports follow-up questions with conversation history.
Instructions
在Get笔记知识库中进行AI增强搜索,返回经过深度处理的答案。支持对话历史追问。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| question | Yes | 要搜索的问题 | |
| topic_ids | No | 知识库ID列表(当前只支持1个)。如果配置了GET_BIJI_DEFAULT_TOPIC_ID环境变量,可省略此参数 | |
| deep_seek | Yes | 是否启用深度思考 | |
| refs | No | 是否返回引用来源 | |
| history | No | 对话历史,用于追问场景 |
Implementation Reference
- src/index.ts:38-78 (registration)Registration of the 'knowledge_search' tool including name, description, and detailed input schema.{ name: 'knowledge_search', description: '在Get笔记知识库中进行AI增强搜索,返回经过深度处理的答案。支持对话历史追问。', inputSchema: { type: 'object', properties: { question: { type: 'string', description: '要搜索的问题', }, topic_ids: { type: 'array', items: { type: 'string' }, description: '知识库ID列表(当前只支持1个)。如果配置了GET_BIJI_DEFAULT_TOPIC_ID环境变量,可省略此参数', }, deep_seek: { type: 'boolean', description: '是否启用深度思考', default: true, }, refs: { type: 'boolean', description: '是否返回引用来源', default: false, }, history: { type: 'array', items: { type: 'object', properties: { content: { type: 'string' }, role: { type: 'string', enum: ['user', 'assistant'] }, }, required: ['content', 'role'], }, description: '对话历史,用于追问场景', }, }, required: ['question', 'deep_seek'], }, },
- src/index.ts:152-177 (handler)MCP server handler for 'knowledge_search' tool: extracts parameters from request and delegates execution to GetBijiClient.knowledgeSearch, formats result as text content.case 'knowledge_search': { const { question, topic_ids, deep_seek, refs, history } = args as { question: string; topic_ids?: string[]; deep_seek: boolean; refs?: boolean; history?: ChatMessage[]; }; const result = await client.knowledgeSearch({ question, topic_ids, deep_seek, refs, history, }); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/client.ts:71-104 (handler)Core handler implementation in GetBijiClient: applies rate limiting, handles default topic_ids, performs HTTP POST to '/knowledge/search' API endpoint, and manages errors.async knowledgeSearch(params: KnowledgeSearchRequest): Promise<any> { await this.rateLimiter.waitForSlot(); // 如果没有提供topic_ids且配置了默认topic_id,则使用默认值 if (!params.topic_ids || params.topic_ids.length === 0) { if (this.config.defaultTopicId) { params.topic_ids = [this.config.defaultTopicId]; logger.debug('Using default topic_id', { topic_id: this.config.defaultTopicId }); } else { throw new Error('topic_ids is required or set GET_BIJI_DEFAULT_TOPIC_ID in environment'); } } try { const response = await this.client.post('/knowledge/search', params); return response.data; } catch (error: any) { const errorMsg = error.response?.data?.h?.e || error.message; const statusCode = error.response?.status; logger.error('Knowledge search failed', { error: errorMsg, statusCode, params: { ...params, topic_ids: params.topic_ids }, responseData: error.response?.data }); if (statusCode === 403) { throw new Error(`Knowledge search failed: Authentication error (403). Please check your GET_BIJI_API_KEY is valid.`); } throw new Error(`Knowledge search failed: ${errorMsg}`); } }
- src/types.ts:6-12 (schema)TypeScript interface defining the input parameters for knowledge_search (KnowledgeSearchRequest), matching the tool's inputSchema.export interface KnowledgeSearchRequest { question: string; topic_ids?: string[]; // 可选,如果配置了defaultTopicId deep_seek: boolean; refs?: boolean; history?: ChatMessage[]; }