api-spec-cli 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# api-spec-cli
|
|
2
2
|
|
|
3
|
-
CLI for AI agents to explore and call OpenAPI and
|
|
3
|
+
CLI for AI agents to explore and call OpenAPI, GraphQL, and MCP APIs. Output is JSON by default — compact, parseable, token-efficient.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ CLI for AI agents to explore and call OpenAPI and GraphQL APIs. Output is JSON b
|
|
|
8
8
|
npm install -g api-spec-cli
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Works with Node.js 18
|
|
11
|
+
Works with Node.js 18+. No other dependencies.
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
# Or run without installing
|
|
@@ -22,22 +22,34 @@ The CLI follows a progressive discovery pattern. You never dump an entire API sp
|
|
|
22
22
|
### Step 1: Load the spec
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
|
|
26
|
-
spec load
|
|
27
|
-
spec load
|
|
25
|
+
# OpenAPI
|
|
26
|
+
spec load https://petstore3.swagger.io/api/v3/openapi.json
|
|
27
|
+
spec load ./openapi.yaml
|
|
28
|
+
|
|
29
|
+
# GraphQL (auto-introspects)
|
|
30
|
+
spec load https://gql.hashnode.com
|
|
31
|
+
|
|
32
|
+
# MCP — stdio transport (spawn a local server)
|
|
33
|
+
spec load --mcp-stdio "npx -y @modelcontextprotocol/server-filesystem /tmp"
|
|
34
|
+
|
|
35
|
+
# MCP — SSE transport
|
|
36
|
+
spec load --mcp-sse http://localhost:3000/sse
|
|
37
|
+
|
|
38
|
+
# MCP — Streamable HTTP transport
|
|
39
|
+
spec load --mcp-http https://docs.agno.com/mcp
|
|
28
40
|
```
|
|
29
41
|
|
|
30
42
|
Output tells you what was loaded:
|
|
31
43
|
```json
|
|
32
|
-
{ "ok": true, "type": "
|
|
44
|
+
{ "ok": true, "type": "mcp", "transport": "streamable-http", "toolCount": 1 }
|
|
33
45
|
```
|
|
34
46
|
|
|
35
47
|
### Step 2: Find what you need
|
|
36
48
|
|
|
37
|
-
`list` is compact by default — just
|
|
49
|
+
`list` is compact by default — just IDs, no schemas. Use `--filter`, `--tag`, `--limit` to narrow down.
|
|
38
50
|
|
|
39
51
|
```bash
|
|
40
|
-
spec list # All operations (compact IDs only)
|
|
52
|
+
spec list # All operations/tools (compact IDs only)
|
|
41
53
|
spec list --filter publish # Search by keyword
|
|
42
54
|
spec list --tag pets # OpenAPI: filter by tag
|
|
43
55
|
spec list --tag mutation # GraphQL: filter by kind (query/mutation/subscription)
|
|
@@ -48,32 +60,32 @@ spec list --limit 10 --offset 10 # Next 10
|
|
|
48
60
|
Compact output (token-efficient):
|
|
49
61
|
```json
|
|
50
62
|
{
|
|
51
|
-
"type": "
|
|
52
|
-
"total":
|
|
53
|
-
"showing":
|
|
63
|
+
"type": "mcp",
|
|
64
|
+
"total": 1,
|
|
65
|
+
"showing": 1,
|
|
54
66
|
"operations": [
|
|
55
|
-
{ "id": "
|
|
56
|
-
{ "id": "publishDraft", "kind": "mutation" }
|
|
67
|
+
{ "id": "search_agno", "description": "Search across the Agno knowledge base..." }
|
|
57
68
|
]
|
|
58
69
|
}
|
|
59
70
|
```
|
|
60
71
|
|
|
61
|
-
Use `--compact false` for full details (
|
|
72
|
+
Use `--compact false` for full details (including `inputSchema` for MCP tools).
|
|
62
73
|
|
|
63
|
-
### Step 3: Inspect one operation
|
|
74
|
+
### Step 3: Inspect one operation or tool
|
|
64
75
|
|
|
65
|
-
`show` gives you everything you need to
|
|
76
|
+
`show` gives you everything you need to make a call — params, body schema, response, and related types — in one call.
|
|
66
77
|
|
|
67
78
|
```bash
|
|
68
79
|
spec show publishPost # GraphQL: by operation name
|
|
69
80
|
spec show getPetById # OpenAPI: by operationId
|
|
70
81
|
spec show /pet/{petId} # OpenAPI: by path
|
|
71
82
|
spec show "GET /pet/{petId}" # OpenAPI: by method + path
|
|
83
|
+
spec show search_agno # MCP: by tool name
|
|
72
84
|
```
|
|
73
85
|
|
|
74
|
-
|
|
86
|
+
MCP output includes the full `inputSchema` so you know exactly what arguments to pass.
|
|
75
87
|
|
|
76
|
-
### Step 4: Drill into types (
|
|
88
|
+
### Step 4: Drill into types (OpenAPI/GraphQL only)
|
|
77
89
|
|
|
78
90
|
```bash
|
|
79
91
|
spec types # List all schema/type names
|
|
@@ -81,12 +93,10 @@ spec types Pet # Inspect one schema
|
|
|
81
93
|
spec types PublishPostInput # Inspect a GraphQL input type
|
|
82
94
|
```
|
|
83
95
|
|
|
84
|
-
This is optional — `show` already includes related types inline. Use `types` only when you need a type that wasn't included in the `show` output.
|
|
85
|
-
|
|
86
96
|
### Step 5: Call the API
|
|
87
97
|
|
|
88
98
|
```bash
|
|
89
|
-
# Set base URL and auth first (persisted across calls)
|
|
99
|
+
# Set base URL and auth first (persisted across calls — OpenAPI/GraphQL)
|
|
90
100
|
spec config set baseUrl https://petstore3.swagger.io/api/v3
|
|
91
101
|
spec config set auth YOUR_TOKEN
|
|
92
102
|
|
|
@@ -98,6 +108,10 @@ spec call addPet --data '{"name":"Rex","photoUrls":[]}'
|
|
|
98
108
|
# GraphQL calls (auto-generates query from schema)
|
|
99
109
|
spec call me
|
|
100
110
|
spec call publication --var host=blog.hashnode.dev
|
|
111
|
+
|
|
112
|
+
# MCP calls — use --var for individual args or --data for the full JSON object
|
|
113
|
+
spec call search_agno --var query="how to create an agent"
|
|
114
|
+
spec call read_file --data '{"path":"/tmp/hello.txt"}'
|
|
101
115
|
```
|
|
102
116
|
|
|
103
117
|
## Config
|