list_files
Browse directory contents in a Kali Linux container to view files and folders for security testing workflows.
Instructions
List files in a directory inside the Kali Linux container.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Directory path inside the container (default: /workspace) |
Implementation Reference
- src/tools/filesystem.ts:71-88 (handler)MCP tool handler implementation for "list_files" in filesystem.ts. It calls the docker-manager's listFiles method.
async ({ path }) => { try { const listing = await docker.listFiles(path ?? "/workspace"); return { content: [{ type: "text", text: listing }], }; } catch (err) { return { content: [ { type: "text", text: `Failed to list files: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true, }; } } - src/docker-manager.ts:253-259 (handler)Backend implementation of listFiles in DockerManager, which executes the "ls -la" command inside the container.
async listFiles(containerPath: string = "/workspace"): Promise<string> { const result = await this.executeCommand(`ls -la ${containerPath}`); if (result.exitCode !== 0) { throw new Error(`Failed to list files: ${result.stderr}`); } return result.stdout; } - src/tools/filesystem.ts:62-90 (registration)Tool registration block for "list_files" within the registerFilesystemTools function.
server.tool( "list_files", "List files in a directory inside the Kali Linux container.", { path: z .string() .optional() .describe("Directory path inside the container (default: /workspace)"), }, async ({ path }) => { try { const listing = await docker.listFiles(path ?? "/workspace"); return { content: [{ type: "text", text: listing }], }; } catch (err) { return { content: [ { type: "text", text: `Failed to list files: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true, }; } } ); }