Skip to main content
Glama
Lspace-io

Lspace MCP Server

Official
by Lspace-io

lspace_search_knowledge_base

Query the Lspace repository's knowledge base using natural language. Automatically syncs with remote content to provide accurate answers to questions like 'How do I configure X?' or 'What are the testing procedures?'

Instructions

🔍 SEARCH: Query the knowledge base using natural language. Automatically syncs with remote before searching to ensure latest content. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb', queryText='What are the testing procedures?'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryTextYesNatural language query about the knowledge base content. Examples: 'What are the main topics?', 'How do I configure X?', 'Tell me about testing procedures'
repositoryIdYesThe ID of the Lspace repository to query. Use 'lspace_list_repositories' first to get repository IDs.

Implementation Reference

  • Handler for the 'lspace_search_knowledge_base' tool. Validates inputs, syncs repository, retrieves repository, calls LLMService.queryKnowledgeBase, and formats the response with answer and sources.
    case 'lspace_search_knowledge_base':
      const { repositoryId, queryText } = args;
      if (!repositoryId || !queryText) {
        return {
          jsonrpc: "2.0",
          id,
          error: {
            code: -32000,
            message: 'Missing required parameters: repositoryId, queryText'
          }
        };
      }
      
      try {
        // Ensure services are initialized
        if (!this.isInitialized || !this.repositoryManager || !this.orchestratorService || !this.orchestratorService.llmService) {
          return {
            jsonrpc: "2.0", id, error: { code: -32000, message: 'MCP server or required services not initialized.' }
          };
        }
    
        // Sync with remote before searching (for GitHub repositories)
        try {
          await this.repositoryManager.syncWithRemote(repositoryId);
        } catch (syncError) {
          console.warn(`[MCP Server] Failed to sync repository ${repositoryId} before searching: ${syncError.message}. Proceeding with local version.`);
          // Continue with search even if sync fails
        }
        
        const repository = this.repositoryManager.getRepository(repositoryId);
        if (!repository) {
          return {
            jsonrpc: "2.0",
            id,
            error: { code: -32000, message: `Repository with ID ${repositoryId} not found.` }
          };
        }
    
        // Call the LLMService's queryKnowledgeBase method
        const searchResult = await this.orchestratorService.llmService.queryKnowledgeBase(repository, queryText);
        
        // searchResult is { answer: string, sources: string[] }
        const responseText = `Search Query: "${queryText}"\n\nAnswer:\n${searchResult.answer}\n\nSources:\n${searchResult.sources.join('\n') || 'No specific sources cited by LLM.'}`;
        
        return {
          jsonrpc: "2.0",
          id,
          result: {
            content: [
              {
                type: "text",
                text: responseText
              }
            ]
          }
        };
      } catch (error) {
        console.error(`[MCP Server] Error during knowledge base search for repo ${repositoryId}:`, error);
        return {
          jsonrpc: "2.0",
          id,
          error: {
            code: -32000,
            message: `Error during knowledge base search: ${error.message}`
          }
        };
      }
  • Input schema definition and description for the 'lspace_search_knowledge_base' tool, including parameters repositoryId and queryText.
    {
      name: "lspace_search_knowledge_base",
      description: "🔍 SEARCH: Query the knowledge base using natural language. Automatically syncs with remote before searching to ensure latest content. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb', queryText='What are the testing procedures?'",
      inputSchema: {
        type: "object",
        properties: {
          repositoryId: {
            type: "string",
            description: "The ID of the Lspace repository to query. Use 'lspace_list_repositories' first to get repository IDs."
          },
          queryText: {
            type: "string",
            description: "Natural language query about the knowledge base content. Examples: 'What are the main topics?', 'How do I configure X?', 'Tell me about testing procedures'"
          }
        },
        required: ["repositoryId", "queryText"]
      }
    },
  • The tool is registered in the getTools() method which returns the list of available tools for the MCP 'tools/list' call.
      return [
        // === REPOSITORY MANAGEMENT ===
        {
          name: "lspace_list_repositories",
          description: "📋 SETUP: List all repositories currently managed by Lspace.",
          inputSchema: {
            type: "object",
            properties: {},
            required: []
          }
        },
        {
          name: "lspace_get_repository_info",
          description: "â„šī¸ SETUP: Get detailed configuration for a specific repository.",
          inputSchema: {
            type: "object",
            properties: {
              repositoryName: {
                type: "string",
                description: "The unique name of the repository."
              }
            },
            required: ["repositoryName"]
          }
        },
    
        // === CONTENT CREATION (PRIMARY WORKFLOW) ===
        {
          name: "lspace_add_content",
          description: "🚀 CREATE: Add content for automatic knowledge base generation. This is the PRIMARY tool for adding ANY content to lspace. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb', inputType='text_snippet', content='My documentation text', title='New Guide'",
          inputSchema: {
            type: "object",
            properties: {
              repositoryId: {
                type: "string",
                description: "The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs."
              },
              inputType: {
                type: "string",
                description: "Content type: 'text_snippet' for text, 'file_upload' for files, 'web_url' to fetch from URL.",
                enum: ["text_snippet", "file_upload", "web_url"]
              },
              content: {
                type: "string",
                description: "The actual content text (for text_snippet) or file content (for file_upload). For files, use base64 encoding for binary data."
              },
              fileName: {
                type: "string",
                description: "File name (REQUIRED for file_upload type). Example: 'my-document.md'"
              },
              url: {
                type: "string",
                description: "The URL to fetch content from (REQUIRED for web_url type). Example: 'https://example.com/doc'"
              },
              title: {
                type: "string",
                description: "Optional title for the content. Example: 'Installation Guide', 'Meeting Notes'"
              },
              user: {
                type: "string",
                description: "Optional user identifier. Example: 'john.doe'"
              },
              metadata: {
                type: "object",
                description: "Optional metadata like tags, categories, etc."
              }
            },
            required: ["repositoryId", "inputType"]
          }
        },
    
        // === KNOWLEDGE BASE INTERACTION ===
        {
          name: "lspace_search_knowledge_base",
          description: "🔍 SEARCH: Query the knowledge base using natural language. Automatically syncs with remote before searching to ensure latest content. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb', queryText='What are the testing procedures?'",
          inputSchema: {
            type: "object",
            properties: {
              repositoryId: {
                type: "string",
                description: "The ID of the Lspace repository to query. Use 'lspace_list_repositories' first to get repository IDs."
              },
              queryText: {
                type: "string",
                description: "Natural language query about the knowledge base content. Examples: 'What are the main topics?', 'How do I configure X?', 'Tell me about testing procedures'"
              }
            },
            required: ["repositoryId", "queryText"]
          }
        },
        {
          name: "lspace_browse_knowledge_base",
          description: "📖 BROWSE: Read existing knowledge base files/directories (read-only). Automatically syncs with remote before browsing to ensure latest content. Example: To list files in 'Lspace Official Docs' root, use repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb', operation='list_directory', path='.'",
          inputSchema: {
            type: "object",
            properties: {
              repositoryId: {
                type: "string",
                description: "The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs."
              },
              operation: {
                type: "string", 
                description: "Operation type: 'list_directory' to see files/folders, 'read_file' to read file contents. Use 'lspace_add_content' for content creation.",
                enum: ["read_file", "list_directory"]
              },
              path: {
                type: "string",
                description: "Path relative to repository root. Use '.' for root directory, 'folder/file.txt' for specific files."
              }
            },
            required: ["repositoryId", "operation", "path"]
          }
        },
    
        // === KNOWLEDGE BASE HISTORY & REVERT ===
        {
          name: "lspace_list_knowledge_base_history",
          description: "📜 HISTORY: List all changes made to the knowledge base in human-friendly format. Shows both file uploads and knowledge base generations separately. Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb'",
          inputSchema: {
            type: "object",
            properties: {
              repositoryId: {
                type: "string",
                description: "The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs."
              },
              limit: {
                type: "number",
                description: "Maximum number of changes to return (default: 20)"
              },
              changeType: {
                type: "string",
                description: "Filter by type of change: 'file_upload', 'knowledge_base_generation', or 'both'",
                enum: ["file_upload", "knowledge_base_generation", "both"]
              }
            },
            required: ["repositoryId"]
          }
        },
        {
          name: "lspace_undo_knowledge_base_changes",
          description: "🔄 UNDO: Revert knowledge base changes using human-friendly commands. Can undo file uploads, KB generations, or both. Examples: 'undo changes for test.txt', 'undo last 3 changes', 'remove test.txt completely'",
          inputSchema: {
            type: "object",
            properties: {
              repositoryId: {
                type: "string",
                description: "The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs."
              },
              filename: {
                type: "string",
                description: "Target a specific file. Example: 'test.txt', 'meeting-notes.md'"
              },
              changeId: {
                type: "string",
                description: "Specific change ID from 'lspace_list_knowledge_base_history'"
              },
              lastNChanges: {
                type: "number",
                description: "Undo the last N changes. Example: 1 for last change, 3 for last 3 changes"
              },
              revertType: {
                type: "string",
                description: "What to revert: 'file_upload' (remove file), 'knowledge_base_generation' (keep file, regenerate KB), 'both' (remove everything)",
                enum: ["file_upload", "knowledge_base_generation", "both"]
              },
              regenerateAfterRevert: {
                type: "boolean",
                description: "For knowledge_base_generation reverts, trigger automatic regeneration (default: false)"
              }
            },
            required: ["repositoryId"]
          }
        }
      ];
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and adds valuable behavioral context: it discloses automatic syncing with remote content before searching (ensuring freshness) and provides an example of parameter usage. However, it doesn't mention rate limits, authentication needs, or error handling.

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

Conciseness5/5

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

The description is efficiently structured with a clear emoji icon, capitalized action word, and a single explanatory sentence followed by a concrete example. Every sentence earns its place without redundancy.

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

Completeness3/5

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

For a search tool with 2 parameters, 100% schema coverage, and no output schema, the description is adequate but could be more complete. It explains the core behavior and provides an example, but doesn't describe return format, pagination, or error cases, which would help the agent use it correctly.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value beyond the schema by showing an example parameter combination, but doesn't explain semantics or constraints not already in the schema descriptions.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Query the knowledge base using natural language' with a specific verb ('search') and resource ('knowledge base'). It distinguishes from siblings like 'lspace_browse_knowledge_base' by emphasizing natural language querying, though it doesn't explicitly contrast with all siblings.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning automatic syncing with remote content and provides an example, but lacks explicit guidance on when to use this tool versus alternatives like 'lspace_browse_knowledge_base' or 'lspace_list_knowledge_base_history'. No exclusions or prerequisites are stated.

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

Related 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/Lspace-io/lspace-server'

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