ACAgentic Craft

Intermediate~45 minHazelJS

Skillgate from OpenAPI to ToolRegistry

Curate REST with Skillgate.fromOpenApi, register governed skills onto ToolRegistry, review gate.report(), and optionally export MCP.

Authors
editorial-team
Published
Last reviewed

Before you start

You will leave with

  • Build Skillgate.fromOpenApi with include tags and invoke baseUrl
  • Register skills for an agent name and interpret gate.report()
  • Connect the registry to AgentRuntime and optional MCP export
On this page

Goal

Turn a curated slice of your HTTP API into governed skills for Agent OS—not a dump of every OpenAPI operation.

Starter: hazeljs-skillgate-agent-starter when available in the monorepo; otherwise follow Skillgate.

Step 1fromOpenApi (or fromModule)

typescript
import { Skillgate } from '@hazeljs/skillgate';
import { ToolRegistry } from '@hazeljs/agent';

const gate = Skillgate.fromOpenApi(spec, {
  include: { tags: ['agent'] },
  invoke: {
    baseUrl: 'http://127.0.0.1:3000',
    headers: { Authorization: 'Bearer ${API_TOKEN}' },
  },
  // keep classify.allowDestructive / allowAdmin off unless explicitly required
});

Prefer tag opt-in. Destructive/admin operations stay denied until you deliberately enable classification flags.

Step 2Register onto ToolRegistry

typescript
const registry = new ToolRegistry();
gate.register(registry, 'api-concierge'); // agent name binding
console.log(gate.report()); // { included, denied, warnings }

Review report() in PR/CI. Skills carry metadata such as requiresApproval, readOnly, capability (skillgate.{class}.{name}), and riskLevel when emitted by Skillgate.

Step 3Wire AgentRuntime

Pass the registry into AgentRuntime / AgentModule for api-concierge (or your agent name). Execute with maxSteps and budget: { maxTokens, maxCostUsd } as usual.

Step 4Optional MCP export

typescript
const server = gate.toMcpServer({ name: 'api-concierge-skills', version: '1.0.0' });
// listen via documented MCP transport helpers

Export the same curated surface—do not maintain a second broader MCP tool list.

Step 5CLI assist

bash
hazel skillgate from-openapi # when available in your CLI version

Still review generated includes before production.

Checklist

  • Include tags documented
  • gate.report() clean of surprise writes
  • Secrets only in invoke headers/env—not DNA
  • Write skills + PolicyEngine / HITL
  • describeAgent coverage for primary skills

Sources

Continue learning