list_allowed_directories
Retrieve the list of directories permitted for exploration by this server, ensuring you know accessible paths before using other tools.
Instructions
Returns the list of directories that this MCP server is allowed to access. This is useful for understanding which directories can be explored or searched before attempting to use other tools. The allowed directories are configured when the server starts and cannot be modified at runtime.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/list-allowed.ts:15-38 (handler)The main handler function for the list_allowed_directories tool. Takes arguments and the allowed directories array, builds a formatted markdown string listing the accessible directories, and returns it as text content.
export async function handleListAllowed(args: any, allowedDirectories: string[]) { let result = "# Allowed Directories\n\n"; if (allowedDirectories.length === 0) { result += "No directories are currently allowed."; } else { result += `This MCP server has access to ${allowedDirectories.length} director${allowedDirectories.length === 1 ? 'y' : 'ies'}:\n\n`; allowedDirectories.forEach((dir, index) => { result += `${index + 1}. ${dir}\n`; }); result += "\nYou can use these directories with other tools like explore_project, search_files, etc."; } return { content: [ { type: "text", text: result } ] }; } - src/list-allowed.ts:4-12 (schema)Tool definition object including name 'list_allowed_directories', description, and an inputSchema with no required parameters (empty object).
export const listAllowedTool = { name: "list_allowed_directories", description: "Returns the list of directories that this MCP server is allowed to access. This is useful for understanding which directories can be explored or searched before attempting to use other tools. The allowed directories are configured when the server starts and cannot be modified at runtime.", inputSchema: { type: "object", properties: {}, required: [] } }; - src/index.ts:33-42 (registration)Registration of the listAllowedTool in the ListToolsRequestSchema handler, making the tool available to clients.
server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ exploreProjectTool, listAllowedTool, searchTool, renameFileTool, deleteFileTool, checkOutdatedTool ] - src/index.ts:52-54 (registration)Routing in CallToolRequestSchema handler: when the tool name is 'list_allowed_directories', the handler function handleListAllowed is called with the allowed directories array.
switch (request.params.name) { case "list_allowed_directories": return await handleListAllowed(args, ALLOWED_DIRECTORIES);