Skip to main content
Glama

sync_knowledge

Sync Outline Wiki documents to vector storage to enable AI-powered search and RAG-based Q&A functionality.

Instructions

Sync documents to vector store for AI-powered search. Run this before using ask_wiki.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
collectionIdNo

Implementation Reference

  • The primary handler function for the 'sync_knowledge' tool. It fetches a list of documents from the Outline API (optionally filtered by collection), retrieves the full text content for each, constructs WikiDocument objects, and syncs them to the 'brain' vector store using brain.syncDocuments(). Handles errors and returns sync statistics.
    async sync_knowledge(args: { collectionId?: string }) { if (!brain.isEnabled()) { return { error: ERROR_MESSAGES.SMART_FEATURES_DISABLED }; } // Step 1: Fetch document list from Outline const payload: Record<string, unknown> = { limit: 100 }; if (args.collectionId) { payload.collectionId = args.collectionId; } const { data: docList } = await apiCall(() => apiClient.post<OutlineDocument[]>('/documents.list', payload) ); if (!docList || docList.length === 0) { return { message: ERROR_MESSAGES.NO_DOCUMENTS_FOUND, synced: 0 }; } // Step 2: Fetch full content for each document (list API may truncate text) const wikiDocs: WikiDocument[] = []; let fetchErrors = 0; for (const doc of docList) { try { const { data: fullDoc } = await apiCall(() => apiClient.post<OutlineDocument>('/documents.info', { id: doc.id }) ); if (fullDoc && fullDoc.text) { wikiDocs.push({ id: fullDoc.id, title: fullDoc.title, text: fullDoc.text, url: `${baseUrl}${fullDoc.url}`, collectionId: fullDoc.collectionId, }); } } catch { fetchErrors++; } } if (wikiDocs.length === 0) { return { message: ERROR_MESSAGES.NO_DOCUMENTS_WITH_CONTENT, synced: 0, errors: fetchErrors, }; } // Step 3: Sync to brain (vectorize) const result = await brain.syncDocuments(wikiDocs); return { message: `Successfully synced ${result.documents} documents (${result.chunks} chunks).`, documents: result.documents, chunks: result.chunks, skipped: docList.length - wikiDocs.length, errors: fetchErrors, }; },
  • Zod schema definition for the input parameters of the sync_knowledge tool, which accepts an optional collectionId (UUID string).
    export const syncKnowledgeSchema = z.object({ collectionId: collectionId.optional(), });
  • Registration of the 'sync_knowledge' tool in the allTools array. Converts the Zod schema to JSON Schema using zodToJsonSchema and defines the tool with name, description, and inputSchema for MCP compatibility.
    createTool( 'sync_knowledge', 'Sync documents to vector store for AI-powered search. Run this before using ask_wiki.', 'sync_knowledge' ),
  • Inclusion of the syncKnowledgeSchema in the central toolSchemas object, which maps tool names to their Zod schemas. Used by tools.ts to generate MCP tool definitions.
    sync_knowledge: syncKnowledgeSchema,

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/huiseo/outline-smart-mcp'

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