> For the complete documentation index, see [llms.txt](https://support.attackforge.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://support.attackforge.com/app/modules/ai-mcp-and-skills/count-users.md).

# Count Users

#### Description <a href="#description" id="description"></a>

Returns the number of AttackForge users matching the optional `filter`. Use this when you only need a total (for reporting, paging decisions, or sanity checks) and do NOT need the user records themselves - call `find_users` for that. Administrators count every user; any other caller only ever counts their own user record, so the result is `0` or `1`. Deleted users are excluded unless `include_deleted` is set.

#### How To Enable <a href="#how-to-enable" id="how-to-enable"></a>

1. Go to `Users`
2. Select the user you would like to provide access to this tool
3. Click on `Access > MCP`
4. Click on `Add Tools`
5. Select the tool `count_users` and click `Add`

#### Example Prompts <a href="#example-prompts" id="example-prompts"></a>

* *How many users are there in AttackForge?*
* *How many consultants do we have?*
* *How many users have not logged in this year?*
* *How many accounts are blocked?*
* *How many users have MFA turned off?*
* *How many deleted users are there?*

#### Parameters <a href="#parameters" id="parameters"></a>

| Parameter         | Type    | Required | Description                                                                                                                                                                                |
| ----------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `filter`          | object  | No       | A MongoDB-style filter. Supported fields are listed below.                                                                                                                                 |
| `include_deleted` | boolean | No       | Include users that have been deleted. Defaults to `false`. Administrators only - ignored for any other caller. Combine with the `is_deleted` filter field to count only the deleted users. |

**Supported `filter` fields (any caller):**

| Field                     | Type / Values                                                                                                                                                                    |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                      | `ObjectId('<24 hex>')`                                                                                                                                                           |
| `email`                   | string                                                                                                                                                                           |
| `first_name`, `last_name` | string                                                                                                                                                                           |
| `username`                | string                                                                                                                                                                           |
| `custom_field_<key>`      | value of the user custom field `<key>`. Only keys configured to display in tables and viewable by the caller are accepted; discover keys via `get_field_structure(model="user")` |

**Supported `filter` fields (administrators only - anyone else is rejected):**

| Field                                        | Type / Values                                                                     |
| -------------------------------------------- | --------------------------------------------------------------------------------- |
| `created`, `modified`                        | ISO-8601 datetime                                                                 |
| `account_expiry`                             | ISO-8601 datetime                                                                 |
| `email_verified`                             | boolean                                                                           |
| `exempt_global_inactivity_policy`            | boolean                                                                           |
| `failed_logins`                              | integer                                                                           |
| `force_password_change`                      | boolean                                                                           |
| `is_deleted`                                 | boolean                                                                           |
| `last_active_on_app`, `last_active_on_ssapi` | ISO-8601 datetime                                                                 |
| `last_logged_in`                             | ISO-8601 datetime                                                                 |
| `last_login_type`                            | one of `'local'`, `'sso'`                                                         |
| `mfa_enabled`                                | boolean                                                                           |
| `role`                                       | one of `'admin'`, `'projectoperator'`, `'librarymod'`, `'consultant'`, `'client'` |
| `status`                                     | one of `'Active'`, `'Blocked'`, `'Invited'`                                       |

Any other field is rejected. `profile` is not filterable. A caller who is not an administrator is always restricted to their own user record, whatever the filter says.

> `mfa_enabled` is on for a user unless it has been explicitly set to `false` - users where it has never been set have it enabled. Matching on `true` covers both, so `{ mfa_enabled: { $eq: true } }` needs no special handling.

#### Example Response <a href="#example-response" id="example-response"></a>

```json
{
  "count": 42
}
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://support.attackforge.com/app/modules/ai-mcp-and-skills/count-users.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
