Mar 26, 2026

Article

openapi-cli4ai: Pull-Based API Discovery for AI Agents

openapi-cli4ai: Pull-Based API Discovery for AI Agents

openapi-cli4ai: Pull-Based API Discovery for AI Agents

Stephen Nolan | Co-Founder & COO

Demo of tool

A few weeks ago I wrote about why an OpenAPI spec beats MCP for large proprietary APIs. The short version: every MCP tool you connect injects its schema into the prompt. For large API surfaces, that kills your context window. An OpenAPI CLI takes a different approach. The agent pulls what it needs on demand. Nothing is injected upfront.

Today we are open sourcing the tool.

openapi-cli4ai

github.com/dbgorilla/openapi-cli4ai

Point it at any REST API that publishes an OpenAPI spec. Your AI agent gets pull-based API discovery and execution. Two commands:

openapi-cli4ai endpoints --search chat
openapi-cli4ai call GET /api/v0_1/chat/

The agent searches a compact endpoint index, picks what it needs, and calls it. Works the same whether the API has 19 endpoints or 1,080.

Single-file Python. Three dependencies. MIT licensed. Install with uv pip install openapi-cli4ai and point it at any spec.

The Self-Validating Loop

This is the part I could not fit into a LinkedIn post.

Your AI agent writes code. Your API server hot-reloads via watchfiles, Tilt, or whatever you use. The agent immediately calls endpoints to confirm the new endpoint exists, then call to test it. Write, reload, test, iterate. The agent closes its own loop against a live instance of your app.

No waiting for a human to verify. No waiting for someone to update an MCP server. The OpenAPI spec regenerates automatically on reload. The CLI always sees the latest API surface.

This is the same principle that DBGorilla is built on. Our agents run a continuous loop: observe, diagnose, validate, resolve, learn. The CLI enables that exact pattern for AI-assisted development. Each cycle, the agent learns what works and what does not against a running instance of the application.

If you are using something like Tilt or watchfiles in your dev environment, the CLI turns your agent into a developer that can verify its own output. That is what it was built to do.

The D&D Test

We pointed it at the D&D 5e API. 47 endpoints. Asked Claude Code to be our dungeon master. It looked up an Adult Red Dragon, pulled the full stat block … 256 HP, CR 17, fire breath, legendary actions … and ran a campaign. When the API had no dice endpoint, Claude wrote a Python script to roll for us.

If someone wants to build an AI dungeon master, the plumbing is done.

Credit

The idea originated from Tom Leavy on our team, who prototyped it against our internal API. We generalized it and are releasing it for anyone to use.

Get Started




Full documentation and examples on GitHub.