> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/stackai-tools/knowledge-base-access/list-knowledge-base-contents.md).

# List Knowledge Base Contents

List the files and folders in a selected knowledge base directory. Use this tool when you need to locate a file by its path rather than by its meaning.

## Use this tool

1. Select **Directory**.
2. Enter **Path**. Use `/` for the root of the selected knowledge base.
3. Choose whether **List All Children** should include nested folders. Set **Max Files Per Folder** to control the size of the listing.
4. Run the tool and use **Directory Tree** to identify the file path for [Read Knowledge Base File](https://docs.stackai.com/stackai-tools/knowledge-base-access/read-knowledge-base-file.md).

## Behavior and limits

The output is a directory listing, not the text inside the files. A per-folder limit can omit entries. Enable the knowledge base permission setting when access must be checked for the signed-in user.

## Inputs

| Field | Parameter       | Description                                                                              |
| ----- | --------------- | ---------------------------------------------------------------------------------------- |
| Path  | `absolute_path` | The absolute path to the directory to list inside of the knowledge base. Default: `"/"`. |

## Configuration

| Field                                      | Parameter                    | Description                                                                                                                                  |
| ------------------------------------------ | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Max Files Per Folder                       | `max_files_per_folder`       | Limit to the number of children files to list per folder. Lower this value to reduce the number of tokens used by the tool. Default: `1000`. |
| List All Children                          | `list_all_children`          | Whether to recursively list all children files and folders of the directory, or only the immediate children. Default: `true`.                |
| Directory (required)                       | `selected_kb_items`          | The directory to list.                                                                                                                       |
| Enforce StackAI knowledge base permissions | `enforce_end_user_kb_access` | Require the end user to hold a role on the knowledge base being explored. Default: `false`.                                                  |

## Outputs

| Field          | Parameter        | Description                                 |
| -------------- | ---------------- | ------------------------------------------- |
| Directory Tree | `directory_tree` | The directory contents as a tree structure. |

## Related guides

* [Retrieval Settings and Result Ranking](https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/retrieval-settings-and-result-ranking.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/stackai-tools/knowledge-base-access/list-knowledge-base-contents.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
