extract_document
Extract content from Microsoft Learn or GitHub URLs and store it in PocketBase for organized retrieval and full-text search.
Instructions
Extract document content from Microsoft Learn or GitHub URL and store in PocketBase
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | Microsoft Learn or GitHub URL to extract content from |
Implementation Reference
- server.js:450-486 (handler)The 'extract_document' tool handler registers the tool, defines its input schema (zod), and executes the logic to extract and store content from Microsoft Learn or GitHub URLs.
server.tool( 'extract_document', 'Extract document content from Microsoft Learn or GitHub URL and store in PocketBase', { url: z.string().url('Invalid URL format').describe('Microsoft Learn or GitHub URL to extract content from') }, async ({ url }) => { try { await authenticateWhenNeeded(); let docData; if (url.includes('learn.microsoft.com')) { docData = await extractFromMicrosoftLearn(url); } else if (url.includes('github.com') || url.includes('raw.githubusercontent.com')) { docData = await extractFromGitHub(url); } else { throw new Error('Unsupported URL. Only Microsoft Learn and GitHub URLs are supported.'); } const record = await storeDocument(docData); return { content: [{ type: 'text', text: `${record.isUpdate ? '🔄 Document updated' : '✅ Document extracted and stored'} successfully!\n\n` + `**Title:** ${record.title}\n` + `**ID:** ${record.id}\n` + `**Source:** ${docData.metadata.source}\n` + `**URL:** ${docData.metadata.url}\n` + `**Word Count:** ${docData.metadata.wordCount}\n` + `**Content Preview:** ${docData.content.substring(0, 200)}...` }] }; } catch (error) { return toolErrorHandler(error); } }