test_docs_path
Tests the document path configuration for the MCP Document Server to ensure proper access to markdown files.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "test_docs_path"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/index.js:17-35 (handler)The main handler logic for the 'test_docs_path' tool. It attempts to list all .md files in the '../documents/' directory using the listMarkdownFiles helper, resolves the directory path, and returns a text content block with the results or an error message if the directory cannot be read.
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:16-16 (schema)Empty input schema for 'test_docs_path', indicating the tool takes no parameters.
{}, - tools/index.js:15-36 (registration)Registration of the 'test_docs_path' tool within the registerTools function, specifying the name, schema, and handler.
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)Helper function imported and used by the test_docs_path handler to list Markdown files (.md) in the specified base directory, filtering out dotfiles.
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); } } - server.js:21-21 (registration)Invocation of registerTools which includes the registration of test_docs_path among other tools.
registerTools(mcpServer);