Agent Reference
Copy this URL to your AI agent for a complete API reference
https://nkmc.ai/skill.mdQuick Start
Use 5 commands to discover and call any API through the nkmc gateway.
1. Install
$ npm install -g @nkmc/cli2. Authenticate
Get a token from the gateway (valid 24h):
$ nkmc auth3. Discover
Browse services and read API specs:
$ nkmc ls /api.github.com/ api.cloudflare.com/ discord.com/ api.weather.gov/ ...$ nkmc cat /api.github.com/skill.md4. Call APIs
Read data, send requests, manage resources:
$ nkmc grep "alerts" /api.weather.gov/GET /alerts/active — alerts_activeGET /alerts/active/count — alerts_active_countGET /alerts/{id} — alerts_single$ nkmc grep "deploy" /api.github.com — GitHub v3 REST APIapi.cloudflare.com — Cloudflare APIapi.vercel.com — Vercel APIAgent Commands
5 Unix-like commands to navigate and interact with any API through the nkmc gateway.
$ npm install -g @nkmc/clinkmc auth
Authenticate with the gateway. Fetches a JWT token (valid 24h) and saves it to ~/.nkmc/credentials.json. After authenticating, all commands work without setting any environment variables.
$ nkmc authAuthenticated with gateway Token saved to ~/.nkmc/credentials.json Gateway: https://api.nkmc.aiUse --gateway-url to authenticate with a different gateway.
nkmc ls <path>
List available services at the root, or browse resources within a service.
$ nkmc ls /api.github.com/ api.cloudflare.com/ discord.com/ api.weather.gov/ ...$ nkmc ls /api.github.com/repos/ users/ orgs/ issues/ pulls/ actions/ _api/nkmc cat <path>
Read data from any API endpoint.
$ nkmc cat /api.github.com/skill.md# GitHub v3 REST API## Schema### repos (public)### issues (public)...$ nkmc cat /api.weather.gov/skill.md# weather.gov API## API### alerts_activeGET /alerts/active...nkmc grep <pattern> <path>
Search across all services or within a specific service by keyword.
Root search — returns matching services with matched endpoints:
$ nkmc grep "weather" /api.weather.gov — weather.gov API · 60 endpointsDomain search — search within a specific service's endpoints:
$ nkmc grep "issues" /api.github.com/GET /repos/{owner}/{repo}/issues — List repository issuesPOST /repos/{owner}/{repo}/issues — Create an issuenkmc write <path> <data>
Send data to an API endpoint (POST/PUT).
$ nkmc write /discord.com/channels/123/messages '{"content":"Hello!"}'{"id": "msg_xyz", "content": "Hello!", "channel_id": "123"}nkmc rm <path>
Delete a resource via API endpoint.
$ nkmc rm /api.github.com/repos/owner/repo/issues/1/comments/42204 No Contentnkmc pipe <expression>
Chain commands with Unix-style pipes. Read data from one API and write it to another in a single step. Currently supports cat | write.
$ nkmc pipe 'cat /api.weather.gov/alerts/active | write /discord.com/channels/123/messages'{"id": "msg_xyz", "channel_id": "123"}The pipe reads from the source (cat), then writes the result to the target (write). If either step fails, the error indicates which step failed.
Developer CLI
@nkmc/cli — scan, generate, and register your API for agent discovery.
nkmc init [dir]
Initialize nkmc in the current project. Detects your framework and ORM, then creates nkmc.config.ts with sensible defaults.
$ npx nkmc init✓ Detected framework: express✓ Detected ORM: prisma✓ Created nkmc.config.tsnkmc claim <domain>
Claim domain ownership via DNS TXT verification. Proves you own the domain and grants a publish token.
Options
| --verify | Verify the DNS record and obtain a publish token |
| --gateway-url <url> | Gateway URL (or NKMC_GATEWAY_URL env) |
Workflow
Step 1: Request a challenge
The gateway returns a DNS TXT record to add to your domain:
$ nkmc claim api.example.comDomain claim challenge for api.example.com: TXT Record: _nkmc.api.example.com TXT Value: nkmc-verify=abc123def456Add this DNS TXT record, then run: nkmc claim api.example.com --verifyStep 2: Add DNS TXT record
Add a TXT record at _nkmc.<domain> with the value from step 1.
Step 3: Verify
$ nkmc claim api.example.com --verify✓ DNS record verified for api.example.com✓ Publish token saved to ~/.nkmc/credentials.jsonYou can now register services under api.example.com.The publish token is saved to ~/.nkmc/credentials.json. You can now register services under this domain.
nkmc generate [dir]
Scan your project routes and schemas, then generate .well-known/skill.md.
Options
| --register | Register with the gateway after generating |
| --domain <domain> | Domain name for the service |
| --token <token> | Auth token for auto-registration |
| --gateway-url <url> | Gateway URL for auto-registration |
$ npx nkmc generate --register --domain my-api.example.comnkmc register
Register an existing .well-known/skill.md with the gateway. Useful when you've already generated the skill file and want to (re)register.
Options
| --domain <domain> | Domain name for the service |
| --dir <dir> | Project directory (default: ".") |
| --token <token> | Auth token (publish token or admin token) |
| --gateway-url <url> | Gateway URL |
Token Resolution
The CLI resolves auth tokens in this order:
--token flagNKMC_PUBLISH_TOKEN env var~/.nkmc/credentials.json (from nkmc claim)--admin-token flag (deprecated)NKMC_ADMIN_TOKEN env var (deprecated)
Environment Variables
All CLI flags can be set via environment variables. Flags take precedence.
| NKMC_GATEWAY_URL | Default gateway URL |
| NKMC_DOMAIN | Default domain for the service |
| NKMC_PUBLISH_TOKEN | Publish token for register |
| NKMC_ADMIN_TOKEN | (Deprecated) Use nkmc claim instead |
| NKMC_HOME | Config directory (default: ~/.nkmc) |
| NKMC_TOKEN | Agent JWT token (prefer nkmc auth instead) |
SDK: @nkmc/core
Server-side SDK for authenticating agent requests via the nkmc gateway.
$ npm install @nkmc/coredefineConfig()
Type-safe helper for creating your nkmc.config.ts. Used by the CLI to read project metadata.
import { defineConfig } from "@nkmc/core";export default defineConfig({ name: "my-api", version: "1.0.0", roles: ["public", "agent", "premium"], framework: "express", orm: "prisma", schemaPath: "./prisma/schema.prisma", pricing: { "POST /api/generate": { cost: 0.05, token: "USD" }, }, gatewayUrl: "https://api.nkmc.ai", domain: "my-api.example.com",});Nkmc.init() & nkmc.guard()
Initialize the SDK and create authentication middleware for your routes. The guard verifies JWT tokens issued by the nkmc gateway.
Express
import { Nkmc } from "@nkmc/core";const nkmc = Nkmc.init({ siteId: "my-api.example.com", gatewayPublicKey: process.env.NKMC_PUBLIC_KEY,});// Protect all routesapp.use("/api", nkmc.guard());// Require specific rolesapp.use("/api/admin", nkmc.guard({ roles: ["premium"] }));app.get("/api/data", (req, res) => { const agent = req.nkmc; // AgentContext res.json({ agentId: agent.id, roles: agent.roles });});Hono
import { Hono } from "hono";import { Nkmc } from "@nkmc/core";const app = new Hono();const nkmc = Nkmc.init({ siteId: "my-api.example.com", gatewayPublicKey: process.env.NKMC_PUBLIC_KEY,});// Use as middlewareapp.use("/api/*", nkmc.guard());app.get("/api/data", (c) => { const agent = c.req.nkmc; return c.json({ agentId: agent.id });});AgentContext
After a successful guard check, the authenticated agent's context is available on req.nkmc.
interface AgentContext { id: string; // Unique agent identifier (JWT sub) roles: string[]; // Roles granted by the gateway}JWT Verification
The gateway issues short-lived JWTs for each agent → service request. The SDK verifies these automatically via nkmc.guard().
sub, svc, roles, expAuthorization: Bearer <jwt>guard() verifies signature, expiry, service, and rolesError Codes
| NO_TOKEN | 401 | Missing Authorization header |
| INVALID_TOKEN | 401 | Signature verification failed |
| TOKEN_EXPIRED | 401 | Token has expired |
| WRONG_SERVICE | 403 | Token was issued for a different service |
| INSUFFICIENT_ROLE | 403 | Agent lacks required role |
Configuration
The nkmc.config.ts file defines your project metadata for the CLI and gateway.
nkmc.config.ts
import { defineConfig } from "@nkmc/core";export default defineConfig({ name: "my-api", version: "1.0.0", roles: ["public", "agent"], framework: "express", orm: "prisma", schemaPath: "./prisma/schema.prisma", pricing: { "POST /api/generate": { cost: 0.05, token: "USD" }, }, gatewayUrl: "https://api.nkmc.ai", domain: "my-api.example.com",});NkmcConfig Fields
| Field | Type | Description |
|---|---|---|
| name | string | Service name for the skill manifest |
| version | string | Semantic version of your API |
| roles | string[] | Access roles (e.g. "public", "agent", "premium") |
| framework | string | Detected framework ("express", "hono", "fastify"…) |
| orm? | string | ORM in use ("prisma", "drizzle"…) |
| schemaPath? | string | Path to the ORM schema file |
| pricing? | Record<string, { cost, token }> | Per-endpoint pricing rules |
| gatewayUrl? | string | Gateway URL for registration |
| domain? | string | Domain name for the service |