lspace_add_content
Add text snippets, files, or URLs to the Lspace MCP Server for automated knowledge base generation. Specify repository ID, content type, and details to organize and store information efficiently.
Instructions
๐ 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'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | No | The actual content text (for text_snippet) or file content (for file_upload). For files, use base64 encoding for binary data. | |
| fileName | No | File name (REQUIRED for file_upload type). Example: 'my-document.md' | |
| inputType | Yes | Content type: 'text_snippet' for text, 'file_upload' for files, 'web_url' to fetch from URL. | |
| metadata | No | Optional metadata like tags, categories, etc. | |
| repositoryId | Yes | The ID of the Lspace repository. Use 'lspace_list_repositories' first to get repository IDs. | |
| title | No | Optional title for the content. Example: 'Installation Guide', 'Meeting Notes' | |
| url | No | The URL to fetch content from (REQUIRED for web_url type). Example: 'https://example.com/doc' | |
| user | No | Optional user identifier. Example: 'john.doe' |
Implementation Reference
- lspace-mcp-server.js:589-702 (handler)The main handler for the 'lspace_add_content' MCP tool. Validates input parameters (repositoryId, inputType, content, etc.), handles different input types ('file_upload', 'text_snippet', 'web_url'), maps parameters to an input object, calls this.orchestratorService.processInput(input) to perform the core logic, and returns a formatted success response with processing details.case 'lspace_add_content': const { repositoryId: repoId, inputType, content, fileName, url, title } = args; if (!repoId || !inputType) { return { jsonrpc: "2.0", id, error: { code: -32000, message: `Missing required parameters for lspace_add_content:\n` + `โข repositoryId: Get this from 'lspace_list_repositories'\n` + `โข inputType: Use 'text_snippet', 'file_upload', or 'web_url'\n\n` + `Example: repositoryId='b3fcb584-5fd9-4098-83b8-8c5d773d86eb', inputType='text_snippet', content='My text', title='My Title'` } }; } try { let input; // Map MCP input parameters to orchestrator service input types switch (inputType) { case 'file_upload': if (!fileName || !content) { return { jsonrpc: "2.0", id, error: { code: -32000, message: 'Missing required parameters for file_upload: fileName, content' } }; } input = { type: 'file_upload', repositoryId: repoId, fileName, content }; break; case 'text_snippet': if (!content) { return { jsonrpc: "2.0", id, error: { code: -32000, message: 'Missing required parameter for text_snippet: content' } }; } input = { type: 'text_snippet', repositoryId: repoId, content, title }; break; case 'web_url': if (!url) { return { jsonrpc: "2.0", id, error: { code: -32000, message: 'Missing required parameter for web_url: url' } }; } input = { type: 'web_url', repositoryId: repoId, url }; break; default: return { jsonrpc: "2.0", id, error: { code: -32000, message: `Unsupported input type: ${inputType}. Supported types: file_upload, text_snippet, web_url` } }; } // Process the input using orchestrator service const result = await this.orchestratorService.processInput(input); return { jsonrpc: "2.0", id, result: { content: [ { type: "text", text: `Content Successfully Processed!\n\nType: ${inputType}\nRepository: ${repoId}\n${fileName ? `File: ${fileName}\n` : ''}${url ? `URL: ${url}\n` : ''}${title ? `Title: ${title}\n` : ''}\n\nRaw Input Path: ${result.rawInputPath || 'N/A'}\nKnowledge Base Updated: ${result.knowledgeBaseUpdated}\nKB Article Path: ${result.knowledgeBasePath || 'N/A'}\n\nMessage: ${result.message || 'Content processed successfully'}` } ] } }; } catch (error) { return { jsonrpc: "2.0", id, error: { code: -32000, message: `Error processing content: ${error.message}` } }; }
- lspace-mcp-server.js:154-195 (schema)Input/output schema and description for the 'lspace_add_content' tool, defining parameters like repositoryId (required), inputType (enum: text_snippet, file_upload, web_url), content, fileName, url, title, user, metadata.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"] } },
- lspace-mcp-server.js:125-300 (registration)The getTools() method registers 'lspace_add_content' (and other tools) by returning the tools list for the MCP 'tools/list' endpoint.getTools() { 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"] } } ]; }