Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathNoDirectory path inside the container (default: /workspace)

Implementation Reference

  • 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,
        };
      }
    }
  • 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;
    }
  • 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,
            };
          }
        }
      );
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hannes221/kali-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server