mcp-toolkit
# mcp-toolkit
[](https://github.com/isumitjha/mcp-toolkit/actions/workflows/ci.yml)
[](LICENSE)
Coding agents often guess about the machine they work on: which process holds port 3000, whether the `node` on `PATH` is the one the project expects, which keys a `.env` is missing. `mcp-toolkit` lets them ask instead. It is an [MCP](https://modelcontextprotocol.io) server; MCP (Model Context Protocol) is an open protocol through which AI applications call tools that separate programs provide. Every tool is read-only, and the agent gets answers without getting a shell.
## Install
Requires Python 3.13+ on macOS or Linux, and `lsof` for the port tool (preinstalled on macOS; `apt install lsof` on Debian/Ubuntu).
Most MCP clients start servers from a JSON configuration like this one. Where the file lives, and whether the key is `mcpServers`, depends on the client:
```json
{
"mcpServers": {
"mcp-toolkit": {
"command": "uvx",
"args": [
"--from", "git+https://github.com/isumitjha/mcp-toolkit@v0.1.0",
"mcp-toolkit", "--root", "/path/to/your/project"
]
}
}
}
```
Clients that take a command line instead can use:
```sh
uvx --from git+https://github.com/isumitjha/mcp-toolkit@v0.1.0 mcp-toolkit --root .
```
`@v0.1.0` pins a release, so the code the client runs changes only when you change the tag; without it, every start would run whatever is on `main`. `.` is the directory the client starts the server in, which differs between clients, so an absolute path is clearer. `--root` can be given more than once. Without it, the file tool refuses every path (see [Security](#security)). To install once instead of through `uvx`, run `uv tool install git+https://github.com/isumitjha/mcp-toolkit@v0.1.0` and use `"command": "mcp-toolkit"`.
## Tools
The server speaks MCP over stdio. Each tool returns structured content, described by an output schema, and the same data as JSON text.
### `check_tools`
Where `git`, `python3`, `pip3`, `node`, `npm`, `uv` and `docker` resolve on `PATH`, the first line of each one's `--version`, copies further down `PATH` that the first one hides, and problems with `PATH` itself: duplicate, missing, empty or relative entries.
```json
{
"tools": [
{"name": "python3", "path": "/opt/homebrew/bin/python3", "version": "Python 3.13.5", "shadowed": ["/usr/bin/python3"]},
{"name": "node", "path": "/Users/me/.nvm/versions/node/v22.16.0/bin/node", "version": "v22.16.0", "shadowed": []},
{"name": "docker", "path": null, "version": null, "shadowed": []}
],
"path_problems": ["PATH lists /opt/homebrew/bin more than once"]
}
```
This is the server's own `PATH`, which the client sets when it starts the server. Desktop apps often get a shorter `PATH` than a login shell, a common reason for a tool to be missing here but present in a terminal.
### `find_port_listeners`
Processes listening on a TCP `port` (1-65535), or on every TCP port when it is omitted.
```json
{
"listeners": [
{"command": "node", "pid": 4410, "user": "me", "protocol": "TCP", "address": "*:3000"}
]
}
```
The operating system shows other users' processes only to root, so an empty list means that nothing visible to the server's user is listening.
### `compare_env_keys`
Compares the key names in a `reference` file (usually `.env.example`) with those in a `target` file (usually `.env`).
```json
{
"missing": ["STRIPE_WEBHOOK_SECRET"],
"extra": ["LEGACY_API_TOKEN"],
"shared": 14,
"problems": [{"file": "target", "line": 9, "problem": "duplicate key DATABASE_URL"}],
"problem_count": 1
}
```
Values are never returned. Both paths must be inside a `--root`; a relative path starts at the first root. Only dotenv files are read: the file name, after symlinks are resolved, must be `.env`, `.env.*` (such as `.env.example`) or `*.env`, and a file in which most lines are not `KEY=value` is refused. It understands `export KEY=value`, comments, and quoted values that span several lines, and it refuses files that are larger than 1 MiB or not UTF-8. `problems` lists the first 20 of each file and `problem_count` gives the total.
A value that spans lines must be quoted. Without quotes, base64 data such as a PEM key can end in a line that looks like `NAME=` (the `=` is padding). Such a line is reported as a problem instead of a key when it comes right after a long line of base64, or when the name is in mixed case with no underscore and no value, so an empty key written that way, such as `apiKey=`, is reported too.
## Security
The agent decides which tools to call and with which arguments, and it may be acting on text it read somewhere untrusted. So the server treats every argument as hostile and returns only what each tool describes.
- **Read-only.** No tool runs a shell, writes a file, stops or signals a process, or opens a network connection.
- **Fixed programs.** The server runs two kinds of program: `<tool> --version` for the seven tools above, and `lsof -nP -iTCP[:port] -sTCP:LISTEN -FpcLPn`. Both are taken only from absolute `PATH` directories, never from `.` or another relative entry, and run with an argument list instead of a shell command line, a timeout (5 and 15 seconds), stdin connected to `/dev/null` and a `PATH` without relative entries. At most 8 KiB of `--version` output and 1 MiB of `lsof` output is read; a program that prints more is stopped and counts as failed. Output is decoded with invalid bytes replaced. The port is checked to be an integer from 1 to 65535 before `lsof` runs, and `-n` and `-P` keep `lsof` from making DNS lookups.
- **Files only under `--root`.** A path is resolved first, including `..` and every symlink, and refused unless the result is inside one of the roots. That stops `../`, absolute paths and symlinks that point elsewhere. The resolved path is then opened from the root one directory at a time without following symlinks, so a directory or file swapped for a symlink after the check makes the read fail instead of leaving the root. Only regular files are read: FIFOs and devices, which could block or have side effects, are refused before they are opened, and at most 1 MiB is read. Error messages repeat the path the agent gave, not where a symlink led.
- **`--root` is about files only.** It limits which files the file tool reads, nothing else: `check_tools` reports where tools are installed and which `PATH` entries have problems, wherever they are on the machine.
- **No root by default.** Without `--root`, the file tool refuses every path. The working directory would be a convenient default, but clients start servers in different places, often the home directory or `/`, so that default could quietly mean everything. Roots come only from the command line, not from the client's MCP roots, so whoever configures the server sets the boundary.
- **No secrets.** Dotenv values are skipped while parsing and are never stored, returned or logged; problems are reported by line number. Only files named like dotenv files are read, and files that are mostly not `KEY=value` are refused: lines of other files, such as private keys, can look like `NAME=` and would return part of a secret as a key name. Process command lines, which often contain tokens, are never read.
- **Clean text.** Control and format characters in anything that came from the system (paths, versions, process names, `lsof` errors) are replaced with U+FFFD, so the output cannot carry terminal escape sequences or hidden bidirectional text.
Limits: the root check is about paths, not about what a file is. A hard link inside a root is a file in the root, and a directory moved out of a root while a read walks through it is still read. So do not use a root that other users can write to: where the system allows hard links to files the linking user cannot read, another user could link one of the server user's files into the root for the agent to read. And the server cannot stop an agent from reading files through other tools its client gives it.
## Development
```sh
uv sync
uv run ruff check . && uv run ruff format --check . && uv run ty check
uv run pytest
```
Tests call every tool through the MCP SDK's in-memory client, and one test runs the installed `mcp-toolkit` command over stdio. A stand-in `lsof` records the arguments it was given, so the tests run anywhere. To try the server by hand, the [MCP Inspector](https://github.com/modelcontextprotocol/inspector) can start it: `npx @modelcontextprotocol/inspector uv run mcp-toolkit --root .`
See [CONTRIBUTING.md](CONTRIBUTING.md) and [CHANGELOG.md](CHANGELOG.md).
## Roadmap
- `check_binary_architecture`: the CPU architectures in a Mach-O or ELF binary, such as an x86_64-only tool on Apple Silicon
- `--tool NAME` to check more tools than the default seven
- The working directory of each listening process, to tell which project a dev server belongs to
## License
[MIT](LICENSE)
TDQS
Scored across 3 tools
Each tool targets a completely separate resource: toolchain/PATH resolution (check_tools), TCP port ownership (find_port_listeners), and dotenv key comparison (compare_env_keys). There is no plausible scenario where an agent would confuse one for another, and the descriptions reinforce the distinct scopes.
All three names follow the same snake_case verb_noun convention: check_tools, find_port_listeners, compare_env_keys. The verbs are accurate and differentiated (check/find/compare), giving a predictable pattern.
Three tools is on the lean side for something called a 'toolkit', but each one is a self-contained, non-trivial diagnostic with a clear purpose. Nothing feels like filler, though a broader toolkit label invites more coverage.
The set covers three useful local-diagnostics cases but has visible gaps: no general process listing, no environment-variable inspection of the server process itself (only file-to-file key comparison), and no disk/network/environment checks. Each individual tool is self-contained with no dead ends, but the overall diagnostic surface is only partially covered.