Skip to content

feat(kodena): add 'kodena logs' command + 'kodena_get_script_logs' MCP tool#72

Merged
sutisnamulyana merged 3 commits into
mainfrom
feat/kodena-logs-command
Jun 24, 2026
Merged

feat(kodena): add 'kodena logs' command + 'kodena_get_script_logs' MCP tool#72
sutisnamulyana merged 3 commits into
mainfrom
feat/kodena-logs-command

Conversation

@sutisnamulyana

Copy link
Copy Markdown
Member

M3 of PLAN-kodena-script-observability. Surfaces a deployed Kodena script's native Workers Logs in the terminal and to agents.

What

  • CLI: kodena logs <slug> — reads recent log events (console.* + per-invocation summaries) for one of the active project's scripts. Flags: --since 15m|1h|1d, --level error|warn|info|log|debug, --json. Renders one line per event (time / level / message / [rayId]); prints a friendly "no logs in the selected window" message instead of erroring on an empty result.
  • MCP: read-only kodena_get_script_logs tool (same call) so an agent can fetch logs to debug a tenant function.

Both call the kodena backend's GET /kodena/scripts/:slug/logs (the M2 endpoint) on the shared dashboard+CLI /kodena/* gateway surface — which accepts a koda_… CLI token or a dashboard JWT — matching every existing kodena command. (Not /cli/kodena/*, which is CLI-token-only and isn't even wired in the gateway.)

Tenant safety

The backend resolves the slug to a row owned by the caller's org + project before reading; a foreign slug 404s with no Cloudflare call. Nothing tenant-crossing here.

Tests

@sawala/kodena 103 tests + @sawala/kodena-mcp 95 tests pass; workspace typecheck clean. MCP registry count assertions bumped 20→21 / 10→11 read-only. Changeset included (minor bump for both packages).

🤖 Generated with Claude Code

…logs

M3 of PLAN-kodena-script-observability. New top-level command calls the kodena
backend's GET /kodena/scripts/:slug/logs (M2) with optional --since (15m/2h/1d)
and --level filters, and a --json mode. Renders one line per event
(timestamp / level / message / [rayId]); prints a friendly empty-window message
instead of erroring when there are no recent events.

Uses the shared /kodena/* gateway surface (accepts both a koda_ CLI token and a
dashboard JWT) like every other kodena command — NOT /cli/kodena/*, which is
CLI-token-only and would lock the M4 dashboard tab out of the same endpoint.
Project-scoped: requires an active org + project, sent as x-org-id/x-project-id.
M3 (optional MCP surface) of PLAN-kodena-script-observability. Mirrors the
kodena logs CLI command: calls GET /kodena/scripts/:slug/logs with optional
since/level and returns the normalized { timestamp, level, message, rayId }
events so an agent can debug a deployed tenant function. Registered among the
read-only (M2) tools; registry count assertions bumped 20→21 / 10→11 read.
@sutisnamulyana sutisnamulyana merged commit b244bf5 into main Jun 24, 2026
1 check passed
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