Inspect and manage Fly.io apps, Machines, logs, and metrics with dry-run mutations.
- Apps
- fly
- flyio
- machines
- apps
- openapi
- graphql
- logs
- metrics
- prometheus
- outages
- infrastructure
- License
- MIT
- Published
- August 22, 2026
- Pinned commit
36bcca1- Rating
- No ratings yet
- Forks
- 0
- Stars
- 0
- Adaptation effort
- —
README
@kody/fly
Intent
Official Fly.io helpers so Kody agents can inspect the caller's organizations,
apps, Machines, logs, and Prometheus metrics — not a shared platform org. Auth
is a saved API token, not OAuth. Reads are free-form. Machine start, stop, and
destroy support dryRun: true; destroy also requires confirm: true.
This listing is meant to be forked. After you fork, save your own flyApiToken
and call the helpers in your account. No Fly app names or organization slugs
are baked into the package.
Agent setup
- Create a token at fly.io/dashboard → Account → Access Tokens. A read token is enough for apps, Machines, logs, and metrics. Start/stop/destroy need a token that can mutate Machines.
- Save it in Kody (do not paste the value in chat):
- In the account secrets UI, approve hosts
api.machines.devandapi.fly.io. - Share this listing as https://kody.codes/@kody/fly
Auth
API token (secret-backed). There is no Fly OAuth integration. Do not open
/connect/oauth for Fly.
| Secret | Purpose |
|---|---|
flyApiToken | Fly API token (flyctl tokens create or dashboard Access Tokens) |
- Machines REST (
api.machines.dev) usesAuthorization: Bearer. - GraphQL, app logs, and Prometheus (
api.fly.io) useBearer/FlyV1.
Hosts
api.machines.dev— Machines REST (apps, Machines, token info, mutations)api.fly.io— GraphQL, app logs, Prometheus
Multi-account
Pass account: "work" to use secret flyApiToken-work. Or pass
secretName: "flyApiToken-staging". There are no hard-coded account aliases
or organization slugs.
When organizationSlug is omitted, the package lists organizations visible to
the token: one org is used automatically; multiple orgs require an explicit slug.
Exports
kody:@kody/fly— action dispatcher (defaults tosmoke-test); also re-exports every helper belowkody:@kody/fly/organizations— list or resolve organizations via GraphQLkody:@kody/fly/apps— list/get apps via Machines RESTkody:@kody/fly/machines— list/get machines; start/stop/destroy withdryRunkody:@kody/fly/machine-count— count machines grouped by state and appkody:@kody/fly/app-machines— list machines for one app byappNameorappIdkody:@kody/fly/logs— fetch and summarize app logs for a time windowkody:@kody/fly/metrics— Fly Prometheus instant/range queries and common app metricskody:@kody/fly/graphql— custom GraphQL querieskody:@kody/fly/docs— API patterns and export discovery metadatakody:@kody/fly/smoke-test— dry-run self-check, then a live org/apps read whenflyApiTokenexistskody:@kody/fly/scheduled-status— no-argument machine-count wrapper used by the disabled job
Mutation safety
- Pass
dryRun: trueonstartMachine,stopMachine, ordestroyMachineto return{ dryRun: true, method, path }without contacting Fly. destroyMachinealso throws unlessconfirm: true.- Do not destroy anyone's machines from a smoke test or scheduled job.
import { startMachine, destroyMachine } from 'kody:@kody/fly/machines'
const preview = await startMachine({
appName: 'my-app',
machineId: '148e26d9b3e089',
dryRun: true,
})
const destroyed = await destroyMachine({
appName: 'my-app',
machineId: '148e26d9b3e089',
confirm: true,
})Jobs
The machine-status job is declared disabled. It is a no-argument wrapper
around scheduled-status (read-only machine counts). Enable it only after you
confirm the token, hosts, and organization slug you want it to use.
Smoke test
import fly from 'kody:@kody/fly'
export default async function main() {
return await fly()
}Without flyApiToken this still returns { ok: true, live: false } plus the
setup URL. With the secret saved it lists organizations and a sample of apps —
no writes.
Example
import fly from 'kody:@kody/fly'
export default async function main() {
return await fly({
action: 'list-apps',
organizationSlug: 'my-org',
})
}Branding
community-icon.svg is Fly.io's official brandmark (Simple Icons flydotio,
approved by Fly.io, CC0) on Fly navy #24175B. Fly.io® is a trademark of
Fly.io, Inc. This package is not affiliated with or endorsed by Fly.io.
Docs
Report this listing
Log in to report this listing.