Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 2 additions & 68 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Options:

Commands:
init [directory] Create a new MCPB extension manifest
validate [manifest] Validate a MCPB manifest file
validate <manifest> Validate a MCPB manifest file
pack <directory> [output] Pack a directory into a MCPB extension
sign [options] <mcpb-file> Sign a MCPB extension file
verify <mcpb-file> Verify the signature of a MCPB extension file
Expand Down Expand Up @@ -58,7 +58,7 @@ The command will prompt you for:

After creating the manifest, it provides helpful next steps based on your server type.

### `mcpb validate [path]`
### `mcpb validate <path>`

Validates a MCPB manifest file against the schema. You can provide either a direct path to a manifest.json file or a directory containing one.

Expand All @@ -69,28 +69,8 @@ mcpb validate manifest.json
# Validate manifest in directory
mcpb validate ./my-extension
mcpb validate .

# Validate using --dirname without specifying manifest.json explicitly
mcpb validate --dirname ./my-extension
```

#### Additional validation with `--dirname`

Passing `--dirname <directory>` performs deeper checks that require access to the extension's source files:

- Verifies referenced assets exist relative to the directory (`icon`, each `screenshots` entry, `server.entry_point`, and path-like `server.mcp_config.command`).
- Launches the server (honoring `${__dirname}` tokens) and discovers tools & prompts using the same logic as `mcpb pack`.
- Compares discovered capability names against the manifest and fails if they differ.

When `--dirname` is supplied without an explicit manifest argument, the CLI automatically resolves `<directory>/manifest.json`. Use `--update` alongside `--dirname` to rewrite the manifest in-place with the discovered tool/prompt lists (including `tools_generated` / `prompts_generated` flags). When rewriting, the CLI also copies over tool descriptions and prompt metadata (descriptions, declared arguments, and prompt text) returned by the server. Without `--update`, any mismatch causes the command to fail.

The discovery step respects the same environment overrides as `mcpb pack`:

- `MCPB_TOOL_DISCOVERY_JSON`
- `MCPB_PROMPT_DISCOVERY_JSON`

These allow deterministic testing without launching the server.

### `mcpb pack <directory> [output]`

Packs a directory into a MCPB extension file.
Expand All @@ -109,52 +89,6 @@ The command automatically:
- Excludes common development files (.git, node_modules/.cache, .DS_Store, etc.)
- Creates a compressed .mcpb file (ZIP with maximum compression)

#### Capability Discovery (Tools & Prompts)

During packing, the CLI launches your server (based on `server.mcp_config.command` + `args`) and uses the official C# MCP client to request both tool and prompt listings. It compares the discovered tool names (`tools` array) and prompt names (`prompts` array) with those declared in `manifest.json`.

If they differ:

- Default: packing fails with an error explaining the mismatch.
- `--force`: continue packing despite any mismatch (does not modify the manifest).
- `--update`: overwrite the `tools` and/or `prompts` list in `manifest.json` with the discovered sets (also sets `tools_generated: true` and/or `prompts_generated: true`) and persists the discovered descriptions plus prompt arguments/text when available.
- `--no-discover`: skip dynamic discovery entirely (useful offline or when the server cannot be executed locally).

Environment overrides for tests/CI:

- `MCPB_TOOL_DISCOVERY_JSON` JSON array of tool names.
- `MCPB_PROMPT_DISCOVERY_JSON` JSON array of prompt names.
If either is set, the server process is not launched for that capability.

#### Referenced File Validation

Before launching the server or writing the archive, `mcpb pack` now validates that certain files referenced in `manifest.json` actually exist relative to the extension directory:

- `icon` (if specified)
- `server.entry_point`
- Path-like `server.mcp_config.command` values (those containing `/`, `\\`, `${__dirname}`, starting with `./` or `..`, or ending in common script/binary extensions such as `.js`, `.py`, `.exe`)
- Each file in `screenshots` (if specified)

If any of these files are missing, packing fails immediately with an error like `Missing icon file: icon.png`. This happens before dynamic capability discovery so you get fast feedback on manifest inaccuracies.

Commands (e.g. `node`, `python`) that are not path-like are not validated—they are treated as executables resolved by the environment.

Examples:

```bash
## Fail if mismatch
mcpb pack .

# Force success even if mismatch
mcpb pack . --force

## Update manifest.json to discovered tools/prompts
mcpb pack . --update

# Skip discovery (behaves like legacy pack)
mcpb pack . --no-discover
```

### `mcpb sign <mcpb-file>`

Signs a MCPB extension file with a certificate.
Expand Down
Loading