caplets 0.2.1 → 0.4.0
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 +139 -20
- package/dist/index.js +21457 -3608
- package/package.json +4 -1
- package/schemas/caplet.schema.json +286 -0
- package/schemas/caplets-config.schema.json +130 -2
package/README.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# Caplets
|
|
2
2
|
|
|
3
|
-
Caplets is a progressive-disclosure gateway for Model Context Protocol (MCP) servers
|
|
3
|
+
Caplets is a progressive-disclosure gateway for Model Context Protocol (MCP) servers and
|
|
4
|
+
native OpenAPI endpoints.
|
|
4
5
|
|
|
5
|
-
Instead of connecting an MCP client to many downstream servers
|
|
6
|
-
front, Caplets exposes one top-level tool per configured
|
|
7
|
-
capability domain, then asks Caplets to list, search, inspect,
|
|
8
|
-
underlying tools.
|
|
6
|
+
Instead of connecting an MCP client to many downstream servers or HTTP APIs and exposing
|
|
7
|
+
every operation up front, Caplets exposes one top-level tool per configured capability.
|
|
8
|
+
An agent first chooses a capability domain, then asks Caplets to list, search, inspect,
|
|
9
|
+
or call that backend's underlying tools or operations.
|
|
9
10
|
|
|
10
11
|
This keeps the initial MCP tool list small, makes tool selection easier, and avoids
|
|
11
12
|
flattened tool-name collisions across servers.
|
|
@@ -27,13 +28,14 @@ the agent chooses that server and asks to search, list, inspect, or call them.
|
|
|
27
28
|
|
|
28
29
|
## What It Does
|
|
29
30
|
|
|
30
|
-
- Reads downstream MCP server definitions from `~/.caplets/config.json`.
|
|
31
|
-
- Registers one generated MCP tool for each enabled server.
|
|
31
|
+
- Reads downstream MCP server definitions and native OpenAPI endpoint definitions from `~/.caplets/config.json`.
|
|
32
|
+
- Registers one generated MCP tool for each enabled MCP server or OpenAPI endpoint.
|
|
32
33
|
- Uses the configured server ID as the generated tool name.
|
|
33
34
|
- Uses the configured `name` and `description` as the capability card shown to agents.
|
|
34
|
-
- Starts downstream servers lazily when an operation needs them.
|
|
35
|
+
- Starts downstream MCP servers and loads OpenAPI specs lazily when an operation needs them.
|
|
35
36
|
- Supports stdio, Streamable HTTP, and legacy HTTP+SSE downstream servers.
|
|
36
|
-
- Lets agents `list_tools`, `search_tools`, `get_tool`, and `call_tool` within one selected
|
|
37
|
+
- Lets agents `list_tools`, `search_tools`, `get_tool`, and `call_tool` within one selected Caplet namespace.
|
|
38
|
+
- Converts OpenAPI operations into MCP-style tool metadata and executes HTTP calls directly.
|
|
37
39
|
- Preserves downstream tool results instead of rewriting them into a custom format.
|
|
38
40
|
- Redacts secrets from structured errors.
|
|
39
41
|
- Supports static remote auth and OAuth token storage for remote servers.
|
|
@@ -91,6 +93,18 @@ you want Caplets to expose:
|
|
|
91
93
|
"token": "$env:DOCS_MCP_TOKEN"
|
|
92
94
|
}
|
|
93
95
|
}
|
|
96
|
+
},
|
|
97
|
+
"openapiEndpoints": {
|
|
98
|
+
"users": {
|
|
99
|
+
"name": "Users API",
|
|
100
|
+
"description": "Manage users through the internal HTTP API.",
|
|
101
|
+
"specPath": "./openapi.json",
|
|
102
|
+
"baseUrl": "https://api.example.com",
|
|
103
|
+
"auth": {
|
|
104
|
+
"type": "bearer",
|
|
105
|
+
"token": "$env:USERS_API_TOKEN"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
```
|
|
@@ -109,16 +123,74 @@ The optional `$schema` field points editors at the generated JSON Schema in
|
|
|
109
123
|
[`schemas/caplets-config.schema.json`](schemas/caplets-config.schema.json). CI verifies that
|
|
110
124
|
the committed schema stays in sync with the Zod config validator.
|
|
111
125
|
|
|
126
|
+
### Caplet Files
|
|
127
|
+
|
|
128
|
+
For richer skill-like cards, add Markdown Caplet files beside `config.json`. Every Caplet
|
|
129
|
+
file must include exactly one executable backend: `mcpServer` or `openapiEndpoint`;
|
|
130
|
+
serverless Caplets are intentionally out of scope.
|
|
131
|
+
|
|
132
|
+
Top-level files derive the Caplet ID from the filename:
|
|
133
|
+
|
|
134
|
+
```md
|
|
135
|
+
---
|
|
136
|
+
$schema: https://raw.githubusercontent.com/spiritledsoftware/caplets/main/schemas/caplet.schema.json
|
|
137
|
+
name: GitHub
|
|
138
|
+
description: Interact with GitHub repositories, issues, and pull requests.
|
|
139
|
+
tags:
|
|
140
|
+
- code
|
|
141
|
+
- review
|
|
142
|
+
mcpServer:
|
|
143
|
+
command: npx
|
|
144
|
+
args: ["-y", "github-mcp-server"]
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
# GitHub
|
|
148
|
+
|
|
149
|
+
Use this Caplet for repository, issue, pull request, and code review workflows.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
OpenAPI-backed Caplet files use `openapiEndpoint`:
|
|
153
|
+
|
|
154
|
+
```md
|
|
155
|
+
---
|
|
156
|
+
name: Users API
|
|
157
|
+
description: Manage users through the internal HTTP API.
|
|
158
|
+
openapiEndpoint:
|
|
159
|
+
specPath: ./openapi.json
|
|
160
|
+
baseUrl: https://api.example.com
|
|
161
|
+
auth:
|
|
162
|
+
type: bearer
|
|
163
|
+
token: $env:USERS_API_TOKEN
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
# Users API
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
That file is exposed as the `github` Caplet. Directory-style Caplets use
|
|
170
|
+
`linear/CAPLET.md`, which is exposed as `linear`; sibling files can be referenced with
|
|
171
|
+
normal Markdown links from `CAPLET.md`.
|
|
172
|
+
|
|
173
|
+
Caplets always loads user Caplet files from `~/.caplets`. Project `./.caplets/config.json`
|
|
174
|
+
is still loaded as project config, but project Markdown Caplet files are executable
|
|
175
|
+
configuration and are ignored unless explicitly trusted:
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
CAPLETS_TRUST_PROJECT_CAPLETS=1 caplets serve
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Later sources override earlier ones in this order: user `config.json`, user Caplet files,
|
|
182
|
+
project `config.json`, and, only when trusted, project Caplet files.
|
|
183
|
+
|
|
112
184
|
`caplets init` refuses to overwrite an existing config. To intentionally replace the file:
|
|
113
185
|
|
|
114
186
|
```sh
|
|
115
187
|
caplets init --force
|
|
116
188
|
```
|
|
117
189
|
|
|
118
|
-
###
|
|
190
|
+
### Caplet IDs
|
|
119
191
|
|
|
120
|
-
Each key under `mcpServers` is the stable
|
|
121
|
-
name exactly, so keep it short and specific:
|
|
192
|
+
Each key under `mcpServers` or `openapiEndpoints` is the stable Caplet ID. It becomes the
|
|
193
|
+
generated MCP tool name exactly, so keep it short and specific:
|
|
122
194
|
|
|
123
195
|
```json
|
|
124
196
|
{
|
|
@@ -133,8 +205,8 @@ name exactly, so keep it short and specific:
|
|
|
133
205
|
}
|
|
134
206
|
```
|
|
135
207
|
|
|
136
|
-
|
|
137
|
-
Unicode IDs are rejected.
|
|
208
|
+
Caplet IDs must match `^[a-zA-Z0-9_-]{1,64}$` and must be unique across `mcpServers` and
|
|
209
|
+
`openapiEndpoints`. Spaces, dots, slashes, colons, and Unicode IDs are rejected.
|
|
138
210
|
|
|
139
211
|
### Stdio Servers
|
|
140
212
|
|
|
@@ -175,6 +247,51 @@ Use `transport` and `url` for remote MCP servers.
|
|
|
175
247
|
`transport` can be `http` for MCP Streamable HTTP or `sse` for legacy HTTP+SSE. Remote
|
|
176
248
|
URLs must use `https://`, except loopback development URLs such as `http://localhost`.
|
|
177
249
|
|
|
250
|
+
### OpenAPI Endpoints
|
|
251
|
+
|
|
252
|
+
Use `openapiEndpoints` for native HTTP APIs described by OpenAPI 3 specs. Each entry
|
|
253
|
+
points at one spec through either `specPath` or `specUrl`, and may override the request
|
|
254
|
+
base URL with `baseUrl`.
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"name": "Users API",
|
|
259
|
+
"description": "Manage users through the internal HTTP API.",
|
|
260
|
+
"specPath": "./openapi.json",
|
|
261
|
+
"baseUrl": "https://api.example.com",
|
|
262
|
+
"auth": { "type": "none" }
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
OpenAPI auth is explicit and supports:
|
|
267
|
+
|
|
268
|
+
- `{"type": "none"}`
|
|
269
|
+
- `{"type": "bearer", "token": "$env:TOKEN"}`
|
|
270
|
+
- `{"type": "headers", "headers": {"x-api-key": "$env:API_KEY"}}`
|
|
271
|
+
|
|
272
|
+
OpenAPI OAuth is not part of the first native OpenAPI backend. OAuth remains available
|
|
273
|
+
for remote MCP servers through `caplets auth`.
|
|
274
|
+
|
|
275
|
+
OpenAPI `call_tool.arguments` uses grouped HTTP inputs:
|
|
276
|
+
|
|
277
|
+
```json
|
|
278
|
+
{
|
|
279
|
+
"operation": "call_tool",
|
|
280
|
+
"tool": "GET /users/{id}",
|
|
281
|
+
"arguments": {
|
|
282
|
+
"path": { "id": "42" },
|
|
283
|
+
"query": { "active": true },
|
|
284
|
+
"body": { "name": "Ada" }
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Every OpenAPI endpoint can set:
|
|
290
|
+
|
|
291
|
+
- `requestTimeoutMs`: timeout for HTTP calls. Defaults to `60000`.
|
|
292
|
+
- `operationCacheTtlMs`: how long OpenAPI operation metadata stays fresh. Defaults to `30000`; `0` refreshes every time.
|
|
293
|
+
- `disabled`: omit the endpoint from Caplets discovery. Defaults to `false`.
|
|
294
|
+
|
|
178
295
|
### Authentication
|
|
179
296
|
|
|
180
297
|
Remote servers can use:
|
|
@@ -236,10 +353,11 @@ starts the MCP server. `serve` is explicit and recommended for clarity.
|
|
|
236
353
|
|
|
237
354
|
## How Agents Use It
|
|
238
355
|
|
|
239
|
-
Caplets initially exposes one MCP tool per enabled
|
|
240
|
-
and `
|
|
356
|
+
Caplets initially exposes one MCP tool per enabled Caplet. If the config has `filesystem`,
|
|
357
|
+
`docs`, and `users`, the client sees three top-level tools: `filesystem`, `docs`, and
|
|
358
|
+
`users`.
|
|
241
359
|
|
|
242
|
-
Each generated
|
|
360
|
+
Each generated Caplet tool accepts an `operation`:
|
|
243
361
|
|
|
244
362
|
```json
|
|
245
363
|
{
|
|
@@ -280,10 +398,11 @@ Call one exact downstream tool:
|
|
|
280
398
|
|
|
281
399
|
Available operations:
|
|
282
400
|
|
|
283
|
-
- `
|
|
284
|
-
- `
|
|
401
|
+
- `get_caplet`: return the configured capability card without starting the downstream server.
|
|
402
|
+
- `check_backend`: verify the selected backend, whether MCP or OpenAPI.
|
|
403
|
+
- `check_mcp_server`: start or connect to an MCP server and verify its tool list.
|
|
285
404
|
- `list_tools`: return compact downstream tool metadata.
|
|
286
|
-
- `search_tools`: search downstream tool names and descriptions within this
|
|
405
|
+
- `search_tools`: search downstream tool names and descriptions within this Caplet.
|
|
287
406
|
- `get_tool`: return full metadata for one exact downstream tool.
|
|
288
407
|
- `call_tool`: invoke one exact downstream tool with JSON object arguments.
|
|
289
408
|
|