List Allowed Directories
list_allowed_directoriesDisplay all directories the server can access, including subdirectories, to identify available paths for file operations.
Instructions
Returns the list of directories that this server is allowed to access. Subdirectories within these allowed directories are also accessible. Use this to understand which directories and their nested paths are available before trying to access files.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes |
Implementation Reference
- src/filesystem/index.ts:683-703 (registration)Registers the 'list_allowed_directories' tool via server.registerTool() with its name, metadata (inputSchema, outputSchema, annotations), and handler.
server.registerTool( "list_allowed_directories", { title: "List Allowed Directories", description: "Returns the list of directories that this server is allowed to access. " + "Subdirectories within these allowed directories are also accessible. " + "Use this to understand which directories and their nested paths are available " + "before trying to access files.", inputSchema: {}, outputSchema: { content: z.string() }, annotations: { readOnlyHint: true } }, async () => { const text = `Allowed directories:\n${allowedDirectories.join('\n')}`; return { content: [{ type: "text" as const, text }], structuredContent: { content: text } }; } ); - src/filesystem/index.ts:696-702 (handler)The handler function that lists allowed directories: reads from the `allowedDirectories` array and returns them as formatted text.
async () => { const text = `Allowed directories:\n${allowedDirectories.join('\n')}`; return { content: [{ type: "text" as const, text }], structuredContent: { content: text } }; } - src/filesystem/index.ts:685-694 (schema)Input/output schema and metadata for list_allowed_directories: empty inputSchema, outputSchema specifying content as string, and readOnlyHint annotation.
{ title: "List Allowed Directories", description: "Returns the list of directories that this server is allowed to access. " + "Subdirectories within these allowed directories are also accessible. " + "Use this to understand which directories and their nested paths are available " + "before trying to access files.", inputSchema: {}, outputSchema: { content: z.string() }, annotations: { readOnlyHint: true } - src/filesystem/lib.ts:11-21 (helper)The `allowedDirectories` variable (module-level array) and the `getAllowedDirectories()` export that returns a copy of it.
let allowedDirectories: string[] = []; // Function to set allowed directories from the main module export function setAllowedDirectories(directories: string[]): void { allowedDirectories = [...directories]; } // Function to get current allowed directories export function getAllowedDirectories(): string[] { return [...allowedDirectories]; }