@n24q02m/mcp-core 1.19.0 → 1.20.0-beta.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 +91 -1
- package/build/auth/credential-form.d.ts +49 -5
- package/build/auth/credential-form.d.ts.map +1 -1
- package/build/auth/credential-form.js +948 -7
- package/build/auth/credential-form.js.map +1 -1
- package/build/auth/local-oauth-app.js +1 -1
- package/build/auth/local-oauth-app.js.map +1 -1
- package/build/auth/relay-login.js +1 -1
- package/build/auth/relay-login.js.map +1 -1
- package/build/cli/build-cli.d.ts +84 -0
- package/build/cli/build-cli.d.ts.map +1 -0
- package/build/cli/build-cli.js +268 -0
- package/build/cli/build-cli.js.map +1 -0
- package/build/cli/index.d.ts +2 -0
- package/build/cli/index.d.ts.map +1 -0
- package/build/cli/index.js +2 -0
- package/build/cli/index.js.map +1 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/schema/types.d.ts +25 -0
- package/build/schema/types.d.ts.map +1 -1
- package/build/storage/credential-store.d.ts +71 -0
- package/build/storage/credential-store.d.ts.map +1 -0
- package/build/storage/credential-store.js +91 -0
- package/build/storage/credential-store.js.map +1 -0
- package/build/storage/index.d.ts +2 -1
- package/build/storage/index.d.ts.map +1 -1
- package/build/storage/index.js +5 -1
- package/build/storage/index.js.map +1 -1
- package/build/storage/per-plugin-store.d.ts +8 -0
- package/build/storage/per-plugin-store.d.ts.map +1 -1
- package/build/storage/per-plugin-store.js +10 -0
- package/build/storage/per-plugin-store.js.map +1 -1
- package/build/storage/resolver.js +3 -3
- package/build/storage/resolver.js.map +1 -1
- package/build/transport/local-server.js +2 -2
- package/build/transport/local-server.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
- [What you get](#what-you-get)
|
|
34
34
|
- [Quick start (Python)](#quick-start-python)
|
|
35
35
|
- [Quick start (TypeScript)](#quick-start-typescript)
|
|
36
|
+
- [CLI](#cli)
|
|
36
37
|
- [Documentation](#documentation)
|
|
37
38
|
- [Development](#development)
|
|
38
39
|
- [License](#license)
|
|
@@ -192,6 +193,95 @@ await http.connect()
|
|
|
192
193
|
// Then mount http.handleRequest(req, res) on your http.Server / Express / Hono.
|
|
193
194
|
```
|
|
194
195
|
|
|
196
|
+
## CLI
|
|
197
|
+
|
|
198
|
+
`mcp_core.cli.build_cli` (re-exported as `from mcp_core import build_cli`) is the
|
|
199
|
+
console-script builder every Python MCP server mounts as its entry point. It wraps
|
|
200
|
+
a server's existing `serve(argv) -> int | None` function with subcommand dispatch,
|
|
201
|
+
so every server exposes the **same** operator subcommands for free while `serve`'s
|
|
202
|
+
own behaviour stays byte-for-byte unchanged. It has no TypeScript counterpart.
|
|
203
|
+
|
|
204
|
+
A downstream server mounts it as its console script:
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
# wet_mcp/cli.py
|
|
208
|
+
from mcp_core import build_cli
|
|
209
|
+
|
|
210
|
+
def main() -> int:
|
|
211
|
+
return build_cli("wet-mcp", serve=_serve, extra=_extras(), version=_version())(None)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```toml
|
|
215
|
+
# pyproject.toml
|
|
216
|
+
[project.scripts]
|
|
217
|
+
wet-mcp = "wet_mcp.cli:main"
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Dispatch rules
|
|
221
|
+
|
|
222
|
+
`build_cli(...)` returns `run(argv=None) -> int`, which inspects `argv[0]`:
|
|
223
|
+
|
|
224
|
+
- **No args** — start the server (`serve([])`), the normal stdio launch.
|
|
225
|
+
- **A flag** (`--http`, ...) — passed byte-for-byte to `serve`; existing flag
|
|
226
|
+
semantics are untouched.
|
|
227
|
+
- **`-h` / `--help`** — print the subcommand list and exit without starting the
|
|
228
|
+
server (which would otherwise hang waiting on stdin in stdio mode).
|
|
229
|
+
- **`--version` / `-V`** — print `<server> <version>`, but only when `version=` is
|
|
230
|
+
passed; otherwise it falls through to `serve` like any other flag.
|
|
231
|
+
- **A positional name** — routed as a subcommand through argparse; an unknown name
|
|
232
|
+
exits `2`.
|
|
233
|
+
|
|
234
|
+
STDOUT is the MCP protocol channel in stdio mode, so only the subcommand path prints
|
|
235
|
+
to stdout: informational results (status, session details, `doctor`'s
|
|
236
|
+
`[ok]`/`[warn]`/`[fail]` lines) go to stdout, while failures and prompts go to stderr
|
|
237
|
+
with a non-zero exit code. Credential **values** are never printed — only names, keys,
|
|
238
|
+
and status.
|
|
239
|
+
|
|
240
|
+
### Built-in subcommands
|
|
241
|
+
|
|
242
|
+
Every server gets three reserved subcommands without writing any code:
|
|
243
|
+
|
|
244
|
+
| Subcommand | Purpose |
|
|
245
|
+
|---|---|
|
|
246
|
+
| `config status` | Report whether a config is stored: `configured`, `not configured`, or `corrupt` (undecryptable). |
|
|
247
|
+
| `config delete [--yes]` | Delete the stored config. Prompts to confirm; `--yes` skips the prompt and is required in non-interactive mode. |
|
|
248
|
+
| `relay status` | Show the active relay session (id prefix, relay URL, age) or report that none is active. |
|
|
249
|
+
| `relay open` | Open the active relay URL in a browser. |
|
|
250
|
+
| `relay reset` | Clear the relay session lock and the stored transport mode. |
|
|
251
|
+
| `doctor` | Environment diagnostics — Python 3.13, credential-backend init, store-dir writability, config state, relay session, transport mode. Exits non-zero on any `[fail]`. |
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
wet-mcp doctor
|
|
255
|
+
wet-mcp config status
|
|
256
|
+
wet-mcp relay status
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Server-specific subcommands (`extra`)
|
|
260
|
+
|
|
261
|
+
`build_cli(..., extra=...)` adds server-specific subcommands. Names in `extra` take
|
|
262
|
+
precedence over the built-ins, so a server can replace `config` / `relay` / `doctor`
|
|
263
|
+
with its own wiring. Each `extra` value is one of two shapes:
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
ExtraHandler = Callable[[argparse.Namespace], int]
|
|
267
|
+
ExtraSpec = ExtraHandler | tuple[Callable[[argparse.ArgumentParser], None], ExtraHandler]
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
- A **bare handler** — registered as an argument-less subcommand.
|
|
271
|
+
- A **`(configure, handler)` tuple** — `configure` receives that subcommand's own
|
|
272
|
+
`argparse.ArgumentParser` to add positionals/flags before argv is parsed, then
|
|
273
|
+
`handler` receives the parsed `Namespace` and returns the exit code.
|
|
274
|
+
|
|
275
|
+
wet-mcp, for example, registers one bare handler and two configured ones:
|
|
276
|
+
|
|
277
|
+
```python
|
|
278
|
+
extra = {
|
|
279
|
+
"warmup": _handle_warmup, # wet-mcp warmup
|
|
280
|
+
"auth": (_configure_auth, _handle_auth), # wet-mcp auth google [--client-id ...]
|
|
281
|
+
"docs": (_configure_docs, _handle_docs), # wet-mcp docs reindex <library>
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
195
285
|
## Documentation
|
|
196
286
|
|
|
197
287
|
Full docs at **[mcp.n24q02m.com/servers/mcp-core/architecture/](https://mcp.n24q02m.com/servers/mcp-core/architecture/)** (Foundation library section in the MCP n24q02m unified docs site):
|
|
@@ -225,4 +315,4 @@ bun run build
|
|
|
225
315
|
|
|
226
316
|
## License
|
|
227
317
|
|
|
228
|
-
MIT
|
|
318
|
+
MIT
|
|
@@ -16,6 +16,8 @@ export interface ConfigField {
|
|
|
16
16
|
helpText?: string;
|
|
17
17
|
helpUrl?: string;
|
|
18
18
|
required?: boolean;
|
|
19
|
+
/** Regex string for client-side validation; rendered as the input's `pattern` attribute. */
|
|
20
|
+
validation?: string;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Return true iff every required field in `schema` has a non-empty value in
|
|
@@ -32,12 +34,39 @@ export interface CapabilityInfo {
|
|
|
32
34
|
priority?: string;
|
|
33
35
|
description?: string;
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A credential-form tab (schema-level `tabs` capability). Each tab is a
|
|
39
|
+
* mutually-exclusive credential mode; only the active tab's fields submit.
|
|
40
|
+
*/
|
|
41
|
+
export interface TabGroup {
|
|
42
|
+
id: string;
|
|
43
|
+
label: string;
|
|
44
|
+
fields: ConfigField[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A repeatable field group (schema-level `cardGroup` capability). Renders
|
|
48
|
+
* Add/Remove cards, each cloning `fields`; submitted as a JSON array under
|
|
49
|
+
* `key` (e.g. `{ accounts: [{...}, {...}] }`).
|
|
50
|
+
*/
|
|
51
|
+
export interface CardGroup {
|
|
52
|
+
key: string;
|
|
53
|
+
fields: ConfigField[];
|
|
54
|
+
itemLabel?: string;
|
|
55
|
+
heading?: string;
|
|
56
|
+
addButtonLabel?: string;
|
|
57
|
+
minItems?: number;
|
|
58
|
+
titleField?: string;
|
|
59
|
+
}
|
|
35
60
|
export interface RelayConfigSchema {
|
|
36
61
|
server: string;
|
|
37
62
|
displayName?: string;
|
|
38
63
|
description?: string;
|
|
39
|
-
fields
|
|
64
|
+
fields?: ConfigField[];
|
|
40
65
|
capabilityInfo?: CapabilityInfo[];
|
|
66
|
+
/** Mutually-exclusive credential modes; see the tabbed render path. */
|
|
67
|
+
tabs?: TabGroup[];
|
|
68
|
+
/** One repeatable field group; see the card-group render path. */
|
|
69
|
+
cardGroup?: CardGroup;
|
|
41
70
|
}
|
|
42
71
|
export interface RenderOptions {
|
|
43
72
|
submitUrl: string;
|
|
@@ -50,14 +79,29 @@ export interface RenderOptions {
|
|
|
50
79
|
* keys are ignored.
|
|
51
80
|
*/
|
|
52
81
|
prefill?: Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* For a `tabs` schema, the id of the tab to render active on load (defaults
|
|
84
|
+
* to the first tab). Ignored for non-tabbed schemas.
|
|
85
|
+
*/
|
|
86
|
+
initialTab?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Opt-in workspace-username field (multi-user stable-sub). Honoured by the
|
|
89
|
+
* flat, `tabs`, and `cardGroup` render paths.
|
|
90
|
+
*/
|
|
91
|
+
includeUsernameField?: boolean;
|
|
53
92
|
}
|
|
54
93
|
/**
|
|
55
94
|
* Wrap `bodyHtml` in the shared dark-theme HTML shell.
|
|
56
95
|
*
|
|
57
|
-
* The shell provides `<!DOCTYPE html>`, `<head>` (charset, viewport,
|
|
58
|
-
* `<title>`, embedded `FORM_SHELL_CSS`)
|
|
59
|
-
* `bodyHtml`. `bodyHtml` is inserted
|
|
60
|
-
* untrusted values they interpolate.
|
|
96
|
+
* The shell provides `<!DOCTYPE html>`, `<head>` (charset, viewport, a
|
|
97
|
+
* Content-Security-Policy meta, escaped `<title>`, embedded `FORM_SHELL_CSS`)
|
|
98
|
+
* and a `<body>` whose only child is `bodyHtml`. `bodyHtml` is inserted
|
|
99
|
+
* verbatim, so callers MUST pre-escape any untrusted values they interpolate.
|
|
100
|
+
*
|
|
101
|
+
* The CSP (`default-src 'none'; style-src 'unsafe-inline'; script-src
|
|
102
|
+
* 'unsafe-inline'; connect-src 'self'`) permits the page's own inline
|
|
103
|
+
* `<style>`/`<script>` and same-origin `fetch` submits while blocking any
|
|
104
|
+
* external resource load.
|
|
61
105
|
*
|
|
62
106
|
* `title` is HTML-escaped before being placed in `<title>`.
|
|
63
107
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-form.d.ts","sourceRoot":"","sources":["../../src/auth/credential-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"credential-form.d.ts","sourceRoot":"","sources":["../../src/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