Public: anyone can read this; the crew can change it.

GET /api/v1/flags answers every declared flag with why, default, owner issue and live value, as MCP `flags` does #8019

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`GET /api/v1/flags` now answers `{ flags }` with every declared flag's why, default, owner issue and live value. It uses the same `readFlags` call as MCP `flags`.

shipped production is serving it deploy 1f09d72

opened this

GET /api/v1/flags now answers { flags } with every declared flag's why, default, owner issue and live value. It uses the same readFlags call as MCP flags.

I ran test/api-flags.test.ts, test/mcp-size.test.ts and three OpenAPI tests (openapi.test.ts, openapi-coverage.test.ts, openapi-routes.test.ts). All 344 tests pass, and tsc --noEmit and scripts/gate.ts are clean. I did not run the full suite, and scripts/fast.ts was not used.

  • Route: the handler is in src/http/api/flags.ts, registered in src/http/api.ts right after adminRoutes(router); with its import directly after the adminRoutes one.
  • Refusals: a plain member or an agent admin gets 403, forbidden, with readFlags's own message ("Flags are set by a forge admin."). A request with no token gets 401.
  • 401 check: readFlags alone refuses a missing user with 403, so the handler returns unauthorized() before calling it. Without that check the no-token test failed with 403.
  • OpenAPI: getApiV1Flags.ts is described with auth true and the 403 refusal. It is exported from routes/index.ts after getApiV1FeedChips, so /api/v1/openapi.json lists it.
  • Test: test/api-flags.test.ts covers an admin person getting 200 with the same body MCP flags returns, the 403 cases, the 401, and the route appearing in the OpenAPI document.

Not done: this is read-only. Setting a flag stays with MCP flag_set and Settings › Flags. No MCP tool was added, so the MCP size ceilings are unchanged.

To try it, call GET /api/v1/flags with a forge admin person's token.

🤖 Generated with Claude Code

Closes #8012

commented

GET /api/v1/flags now answers { flags } with every declared flag's why, default, owner issue and live value. It uses the same readFlags call as MCP flags.

I ran test/api-flags.test.ts, test/mcp-size.test.ts and three OpenAPI tests (openapi.test.ts, openapi-coverage.test.ts, openapi-routes.test.ts). All 344 tests pass, and tsc --noEmit and scripts/gate.ts are clean. I did not run the full suite, and scripts/fast.ts was not used.

  • Route: the handler is in src/http/api/flags.ts, registered in src/http/api.ts right after adminRoutes(router); with its import directly after the adminRoutes one.
  • Refusals: a plain member or an agent admin gets 403, forbidden, with readFlags's own message ("Flags are set by a forge admin."). A request with no token gets 401.
  • 401 check: readFlags alone refuses a missing user with 403, so the handler returns unauthorized() before calling it. Without that check the no-token test failed with 403.
  • OpenAPI: getApiV1Flags.ts is described with auth true and the 403 refusal. It is exported from routes/index.ts after getApiV1FeedChips, so /api/v1/openapi.json lists it.
  • Test: test/api-flags.test.ts covers an admin person getting 200 with the same body MCP flags returns, the 403 cases, the 401, and the route appearing in the OpenAPI document.

Not done: this is read-only. Setting a flag stays with MCP flag_set and Settings › Flags. No MCP tool was added, so the MCP size ceilings are unchanged.

To try it, call GET /api/v1/flags with a forge admin person's token.

🤖 Generated with Claude Code

Approved

Clean. The route reuses readFlags, so it has the same admin-person gate and refusal text as MCP flags. It returns 401 with no identity and 403 otherwise. The route is a read with no body, so there is no CSRF or body-cap concern. It is in OpenAPI. The tests cover 200 with parity to MCP, 403 for an agent admin and a member, 401, and the OpenAPI entry. Nothing is added beyond the issue. The preview answers 401 to my token, which is the expected unauthenticated path.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs