test_docs_path
Validate and test document paths on the MCP Document Server to ensure proper access and management of markdown files in local development environments.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/index.js:17-35 (handler)Inline handler for 'test_docs_path' MCP tool: resolves the documents directory, lists markdown files using helper, and returns formatted text response or error.async () => { const baseDir = '../documents/'; try { const files = await listMarkdownFiles(baseDir); return { content: [{ type: "text", text: `Directory path: ${path.resolve(baseDir)}\n\nFiles found:\n${files.join('\n')}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error reading directory: ${error.message}\n\nAttempted path: ${path.resolve(baseDir)}` }] }; } }
- tools/index.js:15-36 (registration)Registration of the 'test_docs_path' tool on the MCP server, with empty input schema and inline handler function.mcpServer.tool("test_docs_path", {}, async () => { const baseDir = '../documents/'; try { const files = await listMarkdownFiles(baseDir); return { content: [{ type: "text", text: `Directory path: ${path.resolve(baseDir)}\n\nFiles found:\n${files.join('\n')}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error reading directory: ${error.message}\n\nAttempted path: ${path.resolve(baseDir)}` }] }; } } );
- utils/fileUtils.js:32-51 (helper)Supporting utility function listMarkdownFiles that reads a directory, filters for .md files (excluding dotfiles), and handles common FS errors with custom FileSystemError.export async function listMarkdownFiles(baseDir) { try { const dirents = await fs.readdir(baseDir, { withFileTypes: true }); return dirents .filter(dirent => dirent.isFile() && dirent.name.toLowerCase().endsWith('.md') && !dirent.name.startsWith('.') ) .map(dirent => dirent.name); } catch (error) { if (error.code === 'ENOENT') { throw new FileSystemError('Directory not found', 'ENOENT'); } if (error.code === 'EACCES') { throw new FileSystemError('Permission denied', 'EACCES'); } throw new FileSystemError(`Error listing files: ${error.message}`, error.code); } }