Agent Reference

Copy this URL to your AI agent for a complete API reference

https://nkmc.ai/skill.md

Quick Start

Use 5 commands to discover and call any API through the nkmc gateway.

1. Install

bash
$ npm install -g @nkmc/cli

2. Authenticate

Get a token from the gateway (valid 24h):

bash
$ nkmc auth

3. Discover

Browse services and read API specs:

bash
$ nkmc ls /api.github.com/  api.cloudflare.com/  discord.com/  api.weather.gov/  ...$ nkmc cat /api.github.com/skill.md

4. Call APIs

Read data, send requests, manage resources:

bash
$ 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 API

Agent Commands

5 Unix-like commands to navigate and interact with any API through the nkmc gateway.

bash
$ npm install -g @nkmc/cli

nkmc 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.

bash
$ nkmc authAuthenticated with gateway  Token saved to ~/.nkmc/credentials.json  Gateway: https://api.nkmc.ai

Use --gateway-url to authenticate with a different gateway.

nkmc ls <path>

List available services at the root, or browse resources within a service.

bash
$ 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.

bash
$ 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:

bash
$ nkmc grep "weather" /api.weather.gov — weather.gov API · 60 endpoints

Domain search — search within a specific service's endpoints:

bash
$ nkmc grep "issues" /api.github.com/GET  /repos/{owner}/{repo}/issues — List repository issuesPOST /repos/{owner}/{repo}/issues — Create an issue

nkmc write <path> <data>

Send data to an API endpoint (POST/PUT).

bash
$ 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.

bash
$ nkmc rm /api.github.com/repos/owner/repo/issues/1/comments/42204 No Content

nkmc 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.

bash
$ 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.

bash
$ npx nkmc init✓ Detected framework: express✓ Detected ORM: prisma✓ Created nkmc.config.ts

nkmc claim <domain>

Claim domain ownership via DNS TXT verification. Proves you own the domain and grants a publish token.

Options

--verifyVerify 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:

bash
$ 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 --verify
Step 2: Add DNS TXT record

Add a TXT record at _nkmc.<domain> with the value from step 1.

Step 3: Verify
bash
$ 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

--registerRegister 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
bash
$ npx nkmc generate --register --domain my-api.example.com

nkmc 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:

  1. --token flag
  2. NKMC_PUBLISH_TOKEN env var
  3. ~/.nkmc/credentials.json (from nkmc claim)
  4. --admin-token flag (deprecated)
  5. NKMC_ADMIN_TOKEN env var (deprecated)

Environment Variables

All CLI flags can be set via environment variables. Flags take precedence.

NKMC_GATEWAY_URLDefault gateway URL
NKMC_DOMAINDefault domain for the service
NKMC_PUBLISH_TOKENPublish token for register
NKMC_ADMIN_TOKEN(Deprecated) Use nkmc claim instead
NKMC_HOMEConfig directory (default: ~/.nkmc)
NKMC_TOKENAgent JWT token (prefer nkmc auth instead)

SDK: @nkmc/core

Server-side SDK for authenticating agent requests via the nkmc gateway.

bash
$ npm install @nkmc/core

defineConfig()

Type-safe helper for creating your nkmc.config.ts. Used by the CLI to read project metadata.

nkmc.config.ts
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

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

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.

typescript
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().

1.Agent requests access via gateway
2.Gateway issues JWT with sub, svc, roles, exp
3.Agent calls your API with Authorization: Bearer <jwt>
4.guard() verifies signature, expiry, service, and roles

Error Codes

NO_TOKEN401Missing Authorization header
INVALID_TOKEN401Signature verification failed
TOKEN_EXPIRED401Token has expired
WRONG_SERVICE403Token was issued for a different service
INSUFFICIENT_ROLE403Agent lacks required role

Configuration

The nkmc.config.ts file defines your project metadata for the CLI and gateway.

nkmc.config.ts

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

FieldTypeDescription
namestringService name for the skill manifest
versionstringSemantic version of your API
rolesstring[]Access roles (e.g. "public", "agent", "premium")
frameworkstringDetected framework ("express", "hono", "fastify"…)
orm?stringORM in use ("prisma", "drizzle"…)
schemaPath?stringPath to the ORM schema file
pricing?Record<string, { cost, token }>Per-endpoint pricing rules
gatewayUrl?stringGateway URL for registration
domain?stringDomain name for the service
nkmcthe middle path, the right path.