Skip to main content
Glama

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"] } } ]; }

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