OpenAPI to CLI (ocli)
Turns any OpenAPI or Swagger API into CLI commands at runtime, with BM25 endpoint search and no codegen
Install
npm install -g openapi-to-cliGlobal CLI install
This is third-party code. Review the repository files before installing.
What it does
ocli reads an OpenAPI or Swagger spec and turns endpoints into CLI commands at runtime. An agent finds the right command with a natural-language or regex query, checks parameters with --help and calls the API. Profiles store the base URL, Bearer or Basic auth and custom headers, and the spec is cached locally. The author positions it as a lightweight MCP alternative: the README benchmark shows about 158 tokens of overhead per turn.
Who it is for. Developers who want to give an agent REST API access without writing an MCP server.
Good fit when
- An internal or cloud API has an OpenAPI spec but no MCP server
- The API is large, with hundreds of endpoints, and MCP tool definitions eat context
- You need to call the API from shell scripts and command chains
- You work with several APIs through different profiles
Not a fit when
- You need OAuth2: ocli does not support it
- You need centralized auth or shared state: MCP is a better fit
- The API is GraphQL rather than OpenAPI
Example request
Connect our API from https://api.example.com/openapi.json via ocli and find the command for creating an orderLimitations
No OAuth2, no jq response filtering, no structured JSON output, no MCP or GraphQL support. Unknown flags are rejected, except for request bodies the spec does not describe.
How to disable. Remove the package with npm uninstall -g openapi-to-cli, the .ocli profile folder and the skill file from .claude/skills.
Security check
- Makes real HTTP requests to APIs, including POST, PUT and DELETE
- Stores tokens and credentials in profiles
README in short
openapi-to-cli is a TypeScript CLI that turns an API from an OpenAPI or Swagger spec into commands without code generation. The README explains where a CLI fits better than MCP or skills and includes a token usage benchmark. It covers profiles, auth, strict flag validation, external $ref support and complex parameter serialization. Ready-made skills for OpenClaw and Claude Code and a comparison with similar tools are included.
SKILL.md
---
name: ocli-api
description: Turn any OpenAPI/Swagger API into CLI commands and call them. Search endpoints with BM25, check parameters, execute — no MCP server needed.
version: 1.0.0
user-invocable: true
disable-model-invocation: false
metadata: {"openclaw":{"emoji":"🔌","requires":{"bins":["ocli"],"env":[]}}}
homepage: https://github.com/EvilFreelancer/openapi-to-cli
---
# ocli — OpenAPI to CLI
Call any HTTP API described by an OpenAPI/Swagger spec as CLI commands.
No MCP server, no code generation, no JSON schemas in context.
## When to use
- You need to call a REST API (internal, cloud, SaaS)
- You have an OpenAPI or Swagger spec (URL or local file)
- You want minimal token overhead (1 tool, ~158 tokens/turn)
## Setup (one-time)
```bash
npm install -g openapi-to-cli
ocli profiles add <name> \
--api-base-url <BASE_URL> \
--openapi-spec <SPEC_URL_OR_PATH> \
--api-bearer-token "$TOKEN"
ocli use <name>
```
## Workflow
1. **Search** for the right command:
```bash
ocli commands --query "your task description" --limit 5
```
2. **Check parameters** of the chosen command:
```bash
ocli <command> --help
```
3. **Execute** the command:
```bash
ocli <command> --param1 value1 --param2 value2
```
4. **Parse** the JSON response and act on the result.FAQ
How do I connect ocli to Claude Code?
Copy the example skill with cp examples/skill-ocli-api.md .claude/skills/api.md.
Is the spec downloaded on every call?
No, it is cached in .ocli/specs/<profile>.json. Re-run ocli profiles add with the same profile name to refresh it.
Related
A self-improving agent from Nous Research with a TUI, messaging gateway, cron jobs and skills it writes itself
Anthropic's coding agent for the terminal, IDE and GitHub: understands your codebase, runs tasks and handles git
OpenAI's coding agent that runs locally in your terminal, with IDE and desktop versions
Google's open-source terminal agent on Gemini models: code work, shell, web search and MCP