Skip to main content
Glama
PancrePal-xiaoyibao

Get笔记 MCP Server

knowledge_recall

Search and retrieve raw content from Get笔记 knowledge bases to quickly find and preview relevant information without AI processing.

Instructions

在Get笔记知识库中召回相关内容,返回未经AI处理的原始结果。可用于快速查找和预览。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionYes要搜索的问题
topic_idNo知识库ID(单个)
topic_idsNo知识库ID列表(当前只支持1个)。注意:topic_id和topic_ids可都不提供,如果配置了GET_BIJI_DEFAULT_TOPIC_ID环境变量。优先使用topic_id
top_kNo返回相似度最高的N个结果
intent_rewriteNo是否进行问题意图重写
select_matrixNo是否对结果进行重选
historyNo对话历史,用于追问场景

Implementation Reference

  • Main handler for the knowledge_recall MCP tool: extracts parameters from request, invokes client.knowledgeRecall, formats results for readability (truncates content, adds index/score), and returns formatted JSON as tool response content.
    case 'knowledge_recall': {
      const { question, topic_id, topic_ids, top_k, intent_rewrite, select_matrix, history } = args as {
        question: string;
        topic_id?: string;
        topic_ids?: string[];
        top_k?: number;
        intent_rewrite?: boolean;
        select_matrix?: boolean;
        history?: ChatMessage[];
      };
    
      const result = await client.knowledgeRecall({
        question,
        topic_id,
        topic_ids,
        top_k,
        intent_rewrite,
        select_matrix,
        history,
      });
    
      // 格式化输出
      const formattedResults = result.c.data.map((item, index) => ({
        index: index + 1,
        title: item.title || '无标题',
        content: item.content.substring(0, 500) + (item.content.length > 500 ? '...' : ''),
        score: item.score.toFixed(4),
        type: item.type,
        source: item.recall_source,
      }));
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify({
              total: result.c.data.length,
              results: formattedResults,
            }, null, 2),
          },
        ],
      };
    }
  • src/index.ts:79-128 (registration)
    Tool registration in the tools array: defines name 'knowledge_recall', description, and detailed inputSchema for MCP listTools response.
    {
      name: 'knowledge_recall',
      description: '在Get笔记知识库中召回相关内容,返回未经AI处理的原始结果。可用于快速查找和预览。',
      inputSchema: {
        type: 'object',
        properties: {
          question: {
            type: 'string',
            description: '要搜索的问题',
          },
          topic_id: {
            type: 'string',
            description: '知识库ID(单个)',
          },
          topic_ids: {
            type: 'array',
            items: { type: 'string' },
            description: '知识库ID列表(当前只支持1个)。注意:topic_id和topic_ids可都不提供,如果配置了GET_BIJI_DEFAULT_TOPIC_ID环境变量。优先使用topic_id',
          },
          top_k: {
            type: 'number',
            description: '返回相似度最高的N个结果',
            default: 10,
          },
          intent_rewrite: {
            type: 'boolean',
            description: '是否进行问题意图重写',
            default: false,
          },
          select_matrix: {
            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'],
      },
    },
  • TypeScript interface defining the input parameters for knowledge_recall (KnowledgeRecallRequest), used by the client.
    export interface KnowledgeRecallRequest {
      question: string;
      topic_id?: string;        // 单个知识库ID,优先使用
      topic_ids?: string[];     // 知识库ID列表(当前只支持1个)
      top_k?: number;
      intent_rewrite?: boolean;
      select_matrix?: boolean;
      history?: ChatMessage[];
    }
  • Core helper function in GetBijiClient: handles HTTP POST to API endpoint '/knowledge/search/recall', manages default topic_id, rate limiting, error handling, and validation.
    async knowledgeRecall(params: KnowledgeRecallRequest): Promise<KnowledgeRecallResponse> {
      await this.rateLimiter.waitForSlot();
    
      // 如果没有提供topic_id和topic_ids,但配置了默认topic_id,则使用默认值
      if (!params.topic_id && (!params.topic_ids || params.topic_ids.length === 0)) {
        if (this.config.defaultTopicId) {
          params.topic_id = this.config.defaultTopicId;
        } else {
          throw new Error('topic_id or topic_ids is required, or set GET_BIJI_DEFAULT_TOPIC_ID in environment');
        }
      }
    
      try {
        const response = await this.client.post<KnowledgeRecallResponse>(
          '/knowledge/search/recall',
          params
        );
        
        if (response.data.h.c !== 0) {
          throw new Error(response.data.h.e || 'Unknown error');
        }
    
        return response.data;
      } catch (error: any) {
        const errorMsg = error.response?.data?.h?.e || error.message;
        logger.error('Knowledge recall failed', { error: errorMsg, params });
        throw new Error(`Knowledge recall failed: ${errorMsg}`);
      }
    }
  • TypeScript interface defining the response structure from the knowledge_recall API call (KnowledgeRecallResponse).
    export interface KnowledgeRecallResponse {
      h: {
        c: number;
        e: string;
        s: number;
        t: number;
        apm: string;
      };
      c: {
        data: RecallItem[];
      };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PancrePal-xiaoyibao/get_biji_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server