Skip to content

feat: project type (Gateway/Outpost/Console), gateway gating, whoami/list/use updates#237

Open
leggetter wants to merge 3 commits intoclaude/hookdeck-gateway-mcp-Xe6WQfrom
feat/project-type
Open

feat: project type (Gateway/Outpost/Console), gateway gating, whoami/list/use updates#237
leggetter wants to merge 3 commits intoclaude/hookdeck-gateway-mcp-Xe6WQfrom
feat/project-type

Conversation

@leggetter
Copy link
Collaborator

@leggetter leggetter commented Mar 14, 2026

Summary

This PR adds project type (Gateway, Outpost, Console) across the CLI: config, whoami, project list/use, and gateway gating so that Event Gateway commands only run when the current project is a Gateway project. It also updates MCP tools to expose type and excludes outbound projects from the list.


Changes

  • Config: project_type (gateway, outpost, console) with fallback from legacy project_mode; set on login (interactive, client, CI, MCP).
  • whoami: Prints a Project type: Gateway (or Outpost/Console) line.
  • project list: Human output shows Org / Project (current?) | Type; --output json returns id, org, project, type, current; --type gateway|outpost|console filter.
  • project use: Uses normalized project list; match by project id or org/project display name.
  • gateway: All hookdeck gateway ... subcommands run requireGatewayProject in PersistentPreRunE; if the current project is not Gateway, the command fails with a clear error (see below).
  • MCP: tool_projects returns type; tool_login persists type; outbound projects excluded from list.
  • Tests: Unit tests for project_type, normalize, gateway gating; acceptance tests for whoami project type and project list (with HOOKDECK_CLI_TESTING_CLI_KEY + hookdeck login --api-key for list tests only).

Example: whoami

hookdeck whoami now includes the current project type:

Using profile default (use -p flag to use a different config profile)

Logged in as Jane Doe (jane@example.com) on project Ecommerce Production in organization Acme
Project type: Gateway

Example: project list (human)

Default output format: Org / Project (current?) | Type.

$ hookdeck project list
Acme / Ecommerce Production (current) | Gateway
Acme / Ecommerce Staging | Gateway
Acme / Outpost Sender | Outpost

Filter by type:

$ hookdeck project list --type gateway
Acme / Ecommerce Production (current) | Gateway
Acme / Ecommerce Staging | Gateway

Example: project list (JSON)

--output json returns an array of objects with id, org, project, type, and current:

$ hookdeck project list --output json
[
  {
    "id": "proj_abc123",
    "org": "Acme",
    "project": "Ecommerce Production",
    "type": "gateway",
    "current": true
  },
  {
    "id": "proj_def456",
    "org": "Acme",
    "project": "Ecommerce Staging",
    "type": "gateway",
    "current": false
  },
  {
    "id": "proj_ghi789",
    "org": "Acme",
    "project": "Outpost Sender",
    "type": "outpost",
    "current": false
  }
]

Example: project use

Switching by project id or by org/project name:

$ hookdeck project use proj_def456
Switched to project Ecommerce Staging (proj_def456).

$ hookdeck project use "Acme" "Ecommerce Production"
Switched to project Ecommerce Production (proj_abc123).

Gateway restriction (only Gateway projects)

All commands under hookdeck gateway (e.g. gateway connection list, gateway source create, gateway mcp) only run when the current project is a Gateway project. If the current project is Outpost or Console, the command fails before calling the API.

This avoids running Event Gateway–specific operations against non-Gateway projects and gives a clear, actionable error.

Example: running a gateway command on a non-Gateway project

If the current project is an Outpost (or Console) project and you run any gateway subcommand:

$ hookdeck gateway connection list
Error: this command requires a Gateway project; current project type is Outpost. Use 'hookdeck project use' to switch to a Gateway project

Same idea for Console:

$ hookdeck gateway source list
Error: this command requires a Gateway project; current project type is Console. Use 'hookdeck project use' to switch to a Gateway project

The user can run hookdeck project list (optionally with --type gateway) and hookdeck project use <id-or-org/project> to switch to a Gateway project, then re-run the gateway command.


Acceptance tests

New in this PR: 7 acceptance tests — 1 whoami subtest and 6 project-list tests (list human, list JSON, invalid --type, filter by type, filter by org, filter by org+project). The table below lists every test that exercises this PR’s behavior (including 2 existing project_use tests in the same file that are not new).

Command What it tests
hookdeck whoami Output includes a line Project type: ... and one of Gateway, Outpost, or Console.
hookdeck project use --local with --hookdeck-config Command fails with an error containing "cannot be used together" (flag conflict; no API). (existing)
Local config helpers Creating .hookdeck/config.toml and reading it back yields the expected project_id (no API). (existing)
hookdeck project list Exit 0; human output includes the type column and at least one of Gateway, Outpost, or Console.
hookdeck project list --output json Exit 0; stdout is a JSON array; each element has id, org, project, type (gateway, outpost, or console), and current.
hookdeck project list --type invalid Exit non-zero; error message contains "invalid" and lists valid types (gateway, outpost, console).
hookdeck project list --type gateway --output json Exit 0; every returned item has type equal to "gateway" (filter by type).
hookdeck project list <org_substring> --output json Exit 0; every returned item’s org contains the substring (filter by org).
hookdeck project list <org_sub> <project_sub> --output json Exit 0; every returned item’s org and project contain the substrings (filter by org and project).

Project list tests (the six hookdeck project list* rows above, except invalid --type) require a CLI key (HOOKDECK_CLI_TESTING_CLI_KEY), because API and CI keys cannot list or switch projects. When that env var is unset, those tests are skipped with a clear message. When set, the test runner authenticates via hookdeck login --api-key $HOOKDECK_CLI_TESTING_CLI_KEY. See test/acceptance/README.md for setup.

…list/use updates

- Add project_type to config (gateway, outpost, console) with fallback from project_mode
- whoami: show Project type line
- project list: show type column; --output json with id, org, project, type, current; --type filter
- project use: use normalized list, match by id or org/project display
- gateway: PersistentPreRunE requires Gateway project; block on Outpost/Console with clear error
- MCP: tool_projects returns type; tool_login persists type; outbound excluded
- Acceptance: project list tests require HOOKDECK_CLI_TESTING_CLI_KEY, auth via login --api-key

Made-with: Cursor
@leggetter leggetter changed the base branch from main to claude/hookdeck-gateway-mcp-Xe6WQ March 14, 2026 12:56
…ests

- TestProjectListFilterByType: project list --type gateway --output json, assert all items type gateway
- TestProjectListFilterByOrgProject: project list <org_substring> --output json, assert org contains substring
Both require HOOKDECK_CLI_TESTING_CLI_KEY (skip with clear message when unset).

Made-with: Cursor
…tests

- TestProjectListInvalidType: project list --type invalid returns error (no CLI key)
- TestProjectListFilterByOrgAndProject: project list <org> <project> --output json filters by both substrings

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant