Skip to content

nkmc-ai/sdk

Repository files navigation

English | 中文 | 日本語

nkmc SDK

Open agent API gateway SDK. Let AI agents discover and call any API on the internet with 6 Unix-like commands, and let developers register their APIs for agent discovery. — nkmc.ai

Package Description npm
@nkmc/cli CLI for agents and developers npm
@nkmc/core Server SDK — JWT verification, middleware, skill generation npm

For Agents

Install the CLI and start browsing APIs:

npm install -g @nkmc/cli

# Authenticate (token valid 24h)
nkmc auth

# Discover services
nkmc ls /

# Search for APIs
nkmc grep "weather" /

# Explore a service
nkmc ls /api.weather.gov/
nkmc grep "forecast" /api.weather.gov/

# Read the API spec
nkmc cat /api.weather.gov/skill.md

Commands

Command Description HTTP Equivalent
nkmc ls <path> List services or directory contents GET /fs/<path>/
nkmc cat <path> Read a file or call a GET endpoint GET /fs/<path>
nkmc grep <pattern> <path> Search services or endpoints GET /fs/<path>?q=<pattern>
nkmc write <path> [data] Send data to a POST endpoint POST /fs/<path>
nkmc rm <path> Delete a resource DELETE /fs/<path>
nkmc pipe <expr> Chain commands with Unix pipes GET then POST

Available Services

40+ APIs are available on the gateway (explore all):

Category Services
Developer Tools GitHub, GitLab, Vercel, Sentry, PagerDuty, CircleCI, Postman
Cloud & Deployment Cloudflare, DigitalOcean, Fly.io, Render
AI & ML OpenAI, OpenRouter, HuggingFace
Communication Slack, Discord, Twilio, Resend
Productivity Notion, Asana, Jira, Spotify
Database Supabase, Neon, Turso
Commerce Stripe
Data Wikipedia, Weather.gov, Datadog
Blockchain Ethereum RPC (Ankr, Alchemy, Infura, Arbitrum, Optimism, Base, Polygon)
# Example: find and explore APIs
nkmc grep "deploy" /
# api.github.com — GitHub v3 REST API
# api.cloudflare.com — Cloudflare API
# fly.io — Machines API

nkmc grep "email" /
# api.resend.com — Resend · 70 endpoints

nkmc grep "blockchain" /
# rpc.ankr.com — JSON-RPC · 13 endpoints
# arb1.arbitrum.io — JSON-RPC · 13 endpoints

nkmc ls /rpc.ankr.com/
# blocks/  balances/  transactions/  receipts/  logs/  ...

nkmc cat /rpc.ankr.com/balances/0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045.json

For Developers

Register your API so agents can discover and use it.

1. Install

npm install @nkmc/core
npm install -g @nkmc/cli

2. Initialize & Generate

# Detect framework, create nkmc.config.ts
nkmc init

# Scan routes and generate .well-known/skill.md
nkmc generate

3. Claim Your Domain

# Request a DNS challenge
nkmc claim api.example.com

# Add the TXT record to your DNS, then verify
nkmc claim api.example.com --verify

4. Register

nkmc register --domain api.example.com

5. Protect Your Routes

import { Nkmc } from "@nkmc/core";

const nkmc = Nkmc.init({
  siteId: "api.example.com", // the domain you claimed in step 3
});

// Verify all agent requests
app.use(nkmc.guard());

// Or restrict by role
app.use("/admin", nkmc.guard({ roles: ["premium"] }));

The gateway public key is automatically fetched from https://api.nkmc.ai/.well-known/jwks.json and cached. You can also pass gatewayPublicKey explicitly if needed.

Verify Requests Directly

import { verifyRequest } from "@nkmc/core";

const result = await verifyRequest(
  req.headers.authorization,
  { siteId: "api.example.com" }
);

if (result.ok) {
  console.log(result.agent.id);    // agent ID
  console.log(result.agent.roles); // ["agent"]
}

Generate skill.md Programmatically

import { generateSkillMd } from "@nkmc/core";

const markdown = generateSkillMd({
  frontmatter: {
    name: "My API",
    gateway: "nkmc",
    version: "1.0",
    roles: ["agent"],
  },
  description: "My API — powered by nkmc.",
  schema: [
    {
      name: "Products",
      description: "Product catalog",
      read: "agent",
      write: "agent",
      fields: [
        { name: "id", type: "string", description: "Product ID" },
        { name: "name", type: "string", description: "Product name" },
      ],
    },
  ],
  api: [
    { method: "GET", path: "/api/products", role: "agent", description: "List all products" },
  ],
});

Configuration

// nkmc.config.ts
import { defineConfig } from "@nkmc/core";

export default defineConfig({
  name: "my-api",
  version: "1.0",
  roles: ["agent", "premium"],
  framework: "hono",
  pricing: {
    "POST /api/orders": { cost: 0.05, token: "USDC" },
  },
});

Environment Variables

Variable Description
NKMC_GATEWAY_URL Gateway URL (default: https://api.nkmc.ai)
NKMC_TOKEN Agent JWT token (prefer nkmc auth instead)
NKMC_PUBLISH_TOKEN Publish token for registration
NKMC_DOMAIN Default domain for the service
NKMC_HOME Config directory (default: ~/.nkmc)

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

Links

License

MIT

Packages

 
 
 

Contributors