Skip to main content
Glama
ikungsjl

MCP Knowledge Base Server

by ikungsjl

query_knowledge_base

Search indexed documents to find answers to questions using semantic similarity matching with configurable result limits and relevance thresholds.

Instructions

查询知识库

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
questionYes查询问题
max_resultsNo最大返回结果数
thresholdNo相似度阈值

Implementation Reference

  • MCP tool handler for 'query_knowledge_base' that extracts query parameters, invokes KnowledgeBase.query method, formats the response including question, answer, confidence score, and source snippets.
    case 'query_knowledge_base': {
      const { question, max_results, threshold } = args as {
        question: string;
        max_results?: number;
        threshold?: number;
      };
      
      const response = await this.knowledgeBase.query({
        question,
        maxResults: max_results,
        threshold
      });
    
      let resultText = `问题: ${question}\n\n答案: ${response.answer}\n\n置信度: ${(response.confidence * 100).toFixed(1)}%\n\n来源:\n`;
      
      response.sources.forEach((source, index) => {
        resultText += `${index + 1}. ${source.document.title} (相似度: ${(source.score * 100).toFixed(1)}%)\n`;
        resultText += `   片段: ${source.snippet}\n\n`;
      });
    
      return {
        content: [
          {
            type: 'text',
            text: resultText
          }
        ]
      };
    }
  • Input schema definition for the 'query_knowledge_base' tool, specifying parameters for question, max_results, and threshold.
    {
      name: 'query_knowledge_base',
      description: '查询知识库',
      inputSchema: {
        type: 'object',
        properties: {
          question: {
            type: 'string',
            description: '查询问题'
          },
          max_results: {
            type: 'number',
            description: '最大返回结果数',
            default: 5
          },
          threshold: {
            type: 'number',
            description: '相似度阈值',
            default: 0.1
          }
        },
        required: ['question']
      }
    },
  • Core implementation of the knowledge base query logic, handling search, answer generation, and confidence calculation using private helper methods.
    async query(request: QueryRequest): Promise<QueryResponse> {
      const { question, maxResults = this.config.maxSearchResults, threshold = this.config.similarityThreshold } = request;
      
      // 简单的关键词搜索实现
      const results = this.searchDocuments(question, maxResults, threshold);
      
      // 生成答案
      const answer = this.generateAnswer(question, results);
      
      return {
        answer,
        sources: results,
        confidence: this.calculateConfidence(results)
      };
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure but offers none. It doesn't indicate whether this is a read-only operation, what the response format might be, whether there are rate limits or authentication requirements, or how results are returned (e.g., relevance-ranked). For a query tool with 3 parameters and no output schema, this leaves critical behavior undocumented.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While technically concise with just three Chinese characters, this is a case of severe under-specification rather than effective conciseness. The description doesn't earn its place - it provides no useful information beyond the tool name itself. Good conciseness balances brevity with information value, which this completely lacks.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (query operation with 3 parameters), absence of annotations, and lack of output schema, the description is completely inadequate. It doesn't explain what the tool returns, how results are structured, what the threshold parameter means in practice, or any behavioral characteristics. For a query tool that presumably returns ranked results, this leaves the agent with insufficient context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters documented in the schema itself ('question', 'max_results', 'threshold'). The description adds no additional meaning beyond what the schema provides about parameter purposes or usage. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter information in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '查询知识库' (Query knowledge base) is a tautology that essentially restates the tool name 'query_knowledge_base' in Chinese. It provides no specific verb or resource details, doesn't explain what kind of querying occurs (e.g., semantic search, keyword matching), and doesn't distinguish this from sibling tools like 'get_document' or 'list_documents' that also retrieve information from the knowledge base.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides absolutely no guidance on when to use this tool versus alternatives. There's no mention of when this tool is appropriate (e.g., for natural language questions vs. structured queries) or when to use sibling tools like 'get_document' (for specific documents) or 'list_documents' (for browsing). The agent receives no usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/ikungsjl/mcp-knowledge-base'

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