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
- OpenAPI spec or HazelJS module to expose
- Skillgate guide
- 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)
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
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
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
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