Metadata-Version: 2.4
Name: mcpcheck-cli
Version: 0.2.0
Summary: MCP server configuration probe
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: pyright; extra == "dev"
Dynamic: license-file

# mcpcheck

Diagnose and lock your MCP setup: validate configs, probe servers over stdio, and
diff tool schemas in CI so your agent does not silently gain or lose abilities.

[![CI](https://github.com/Matrinus/mcpcheck/actions/workflows/ci.yml/badge.svg)](https://github.com/Matrinus/mcpcheck/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/mcpcheck-cli.svg)](https://pypi.org/project/mcpcheck-cli/)
[![GitHub Action](https://img.shields.io/badge/GitHub%20Action-mcpcheck-blue?logo=githubactions&logoColor=white)](action.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11%2B-blue.svg)](pyproject.toml)

**Status: v0.2.0**

<!-- mcp-name: io.github.Matrinus/mcpcheck -->

## Demo

```text
# demo: two fixture servers (ok.py, evil.py) in a temporary directory

$ mcpcheck config --config mcp.json
mcp.json (claude)
  fs: stdio
  risky: stdio

$ mcpcheck probe --config mcp.json
name                 status        startup  tools
fs                   ok               11ms      2
risky                ok               11ms      1

$ mcpcheck lock --config mcp.json -o mcp.lock.json
wrote mcp.lock.json

$ mcpcheck verify --config mcp.json --lock mcp.lock.json
no changes

$ mcpcheck verify --config mcp-v2.json --lock mcp.lock.json
~ fs.echo
0 added, 0 removed, 1 changed

$ mcpcheck doctor --config mcp.json --security
info DOC006 risky.exec_shell (mcp.json): tool name looks like it executes or writes: exec_shell
  hint: Disable this tool for untrusted models or scope what it can reach. Treat this as a signal, not a verdict: heuristic, review manually.
info DOC007 risky.exec_shell (mcp.json): description contains "ignore previous": exec_shell
  hint: Inspect the description and consider pinning the server version. Treat this as a signal, not a verdict: heuristic, review manually.
0 errors, 0 warnings, 2 info

all 6 steps behaved as expected
```

The transcript above is the output of [`demo.sh`](demo.sh) on the fixture servers:
config and probe see both servers, the lock matches, a changed schema turns
`verify` red, and `doctor --security` flags the risky tool as info only.

## Install

```bash
pipx install mcpcheck-cli            # recommended: isolated environment
pip install mcpcheck-cli             # or into the current environment
pipx install git+https://github.com/Matrinus/mcpcheck   # latest from source
```

The distribution is `mcpcheck-cli`; the installed command is `mcpcheck`. Python 3.11+.

## Quickstart

```bash
mcpcheck config --config mcp.json                # validate the config and resolve ${VAR}
mcpcheck probe --config mcp.json                 # start each server and read its tools
mcpcheck lock --config mcp.json -o mcp.lock.json # record schemas in a lockfile
mcpcheck verify --config mcp.json --lock mcp.lock.json # compare live tools with the lock
mcpcheck doctor --config mcp.json --security     # aggregate findings and security hints
```

## What it does

| command  | returns                                                                 | exit code |
| -------- | ----------------------------------------------------------------------- | --------- |
| `config` | discovered/validated configs, resolved env, config errors                | 0, 1, 2   |
| `probe`  | per-server status, startup ms, tools, schema hashes, resources           | 0, 1, 2   |
| `lock`   | writes `mcp.lock.json` for servers that answered                         | 0, 2, 3   |
| `verify` | added / removed / changed tools versus the lockfile                      | 0, 1, 2, 3 |
| `doctor` | findings `DOC001`–`DOC009` with severity and an actionable hint          | 0, 1, 2   |
| `serve`  | mcpcheck as an MCP server over stdio, exposing `verify` and `doctor`     | 0, 2      |

`--json` is available on every reporting command and is byte-stable across
runs: no timestamps, sorted keys. The only exception is `startup_ms` in
`probe`, which measures real process startup; `serve` speaks JSON-RPC instead of
`--json`.

## How it works

`mcpcheck` speaks JSON-RPC over stdio itself: one JSON message per line,
`initialize` + `notifications/initialized`, a deadline on every read, and a
process-group kill on timeout or close. It then sends `tools/list` (following
`nextCursor`) and `resources/list`. Each tool is hashed as the SHA-256 of its
canonical JSON schema with sorted keys, so a new parameter changes the hash while
reformatting the config does not. Environment values are expanded and handed to
the child process, but never serialized: `--json` carries only `env_keys`, so
secrets stay out of logs and CI output.

## What it does not do

- HTTP/SSE transports — remote servers are reported as `unsupported` (v0.2).
- OAuth or any interactive auth; a server that needs a browser cannot be probed.
- Tools are never called, so it cannot tell you whether a tool *works*.
- The `--security` checks are heuristics on names and descriptions, not an audit.
- Linux and macOS only in v0.1.

## Exit codes

| code | meaning                                                                   |
| ---- | ------------------------------------------------------------------------- |
| 0    | success; changes outside the `--fail-on` policy are still printed          |
| 1    | config errors, unreachable servers, findings (with `--strict` also warns), or changes inside the policy |
| 2    | usage error, unreadable or invalid config/lockfile                       |
| 3    | a server did not respond during `lock`/`verify`, so nothing was compared  |

## Use as a GitHub Action

The composite action installs its own Python 3.12 and runs `mcpcheck verify`,
failing the job on changes inside `fail-on` (`any` by default):

```yaml
- uses: actions/checkout@v4
- uses: Matrinus/mcpcheck@v0.1.0
  with:
    config: .mcp.json
    lock: mcp.lock.json
    fail-on: any
```

Inputs: `config` (default `.mcp.json`), `lock` (default `mcp.lock.json`),
`fail-on` (`any`, `added`, `removed` or `changed`) and `timeout` in seconds
(default `5`). Pin the tag to the version of `mcpcheck` that wrote the lockfile;
see [`action.yml`](action.yml) for the full definition.

## Use it as an MCP server

`mcpcheck serve` makes mcpcheck itself an MCP server over stdio, so an agent can
check its own environment. It exposes exactly two read-only tools, `verify` and
`doctor`. Add it to a client config:

```json
{"mcpServers":{"mcpcheck":{"command":"mcpcheck","args":["serve"]}}}
```

Arguments are limited to `config` paths (`.json`/`.toml`), `lock`, `fail_on`,
`security` and `timeout`; no `command`, `args` or `env` is accepted, so nothing
from the client is executed, and each response is capped at 8192 bytes. See
[`docs/mcp-server.md`](docs/mcp-server.md) for the protocol, tools and limits.

## Roadmap

- **v0.2** — own MCP server (`serve`) with `verify` and `doctor` as tools;
  HTTP/SSE transports, `--watch`, pre-commit hook.
- **v0.3** — per-project policy (`policy.yaml`), SARIF export for code scanning.
- **v0.4** — compare two machines: what one has that the other does not.

See [`docs/design.md`](docs/design.md) for the decisions behind v0.1.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md). New config formats and new doctor rules
are designed to be small, self-contained contributions; `make check` must pass
and `bash demo.sh` must stay green.

## License

MIT — see [LICENSE](LICENSE).
