Project · Nov 29, 2026
DevTools MCP: one registry behind an MCP server and a CLI
A Model Context Protocol server that gives an AI assistant and my terminal the same 68 developer tools, with the write policy and config discovery designed before the tools.
Most of my days are split between an editor, a terminal, and an AI assistant. Every one of them needed the same small utilities: a ULID, a decoded JWT, a parsed cron expression, a look at the real schema of a database, a pull request diff. None of those belong in an editor plugin, and asking an assistant to guess a column name is worse than looking it up.
So I built a Model Context Protocol server that answers those questions, and made the same tools available as CLI commands. It is published on npm as @muhfaris/devtools, the source is at github.com/muhfaris/devtools-mcp, and it runs on Node 20.19 or newer.
The problem was not the individual tools
Each utility already existed somewhere on the internet. The problem was that using one meant leaving the context I was in. An assistant could not see my database schema, so it invented one. A terminal needed a different package for every format conversion. And the tools that touched credentials were usually all or nothing: either everything is writable, or the tool refuses to exist.
The constraints I set for myself were the design:
- One implementation per operation, reachable from both an agent and a shell.
- Reads work with no configuration at all.
- Writes are opt in, and production names stay blocked even after opting in.
- Credentials never enter the transcript or the logs.
What it is, concretely
The package registers 68 tools in groups: identifiers and encoding, JSON, dummy data for several locales, GitLab and GitHub, database introspection and queries, Redis, config utilities, and small helpers like cron parsing, timezone conversion, semver bumps, slugify, diff, and env diff.
npx @muhfaris/devtools generate_ulid --count 3
npx @muhfaris/devtools slugify --text "Hello World!"
For an assistant, the same package runs over stdio:
claude mcp add devtools --project -- npx -y @muhfaris/devtools
CLI command names are identical to tool names. That is deliberate: a name like generate_ulid is valid as a shell command and as an MCP tool, so there is only one vocabulary to remember and one place to change it.
How the pieces fit
There are two entry points and exactly one execution path. src/index.ts loads config, registers every tool in a registry, and then chooses a surface: argparse-style Commander commands when arguments are present, a stdio MCP server when the process was started without any.
Each tool is a small module with a name, a description, a parameter schema, and an execute function. The MCP server turns that parameter schema into JSON Schema for tools/list, and the CLI turns it into flags. Neither knows what the tool does. That is the whole point of the registry: adding a tool touches one module and one registration line, and both surfaces get it.
Anything that talks to an external system sits behind a provider interface. PostgreSQL and MySQL are separate classes that implement the same introspection and query contract. GitLab and GitHub are separate clients. A tool asks the provider for a schema, not for a database.
Configuration is one YAML file, .devtools/config.yaml, discovered by walking up from the working directory. Every value can be a ${ENV_VAR} placeholder. The committed example.config.yaml is the reference, and it is never loaded because the loader reads that exact filename only.
The write policy came before the tools
A developer tool that an AI can call is also a tool an AI can misuse. The policy is the part I designed first, and it has four rules that stack rather than replace each other.
allow_writeis a grant, not a flag with a default of true. Missing means deny, so a misspelled key fails closed.blocked_envmatches the connection name or the GitLab project path as a case-insensitive substring, and defaults toproductionandprod.- A connection marked
readonly: trueis a hard deny that outranks the grant. - The readonly connection also opens its session read-only, so the database refuses writes that the tool's own statement classifier did not recognise.
That last rule caught my own SQL classifier. The first version asked whether a statement started with SELECT. A statement that begins with WITH x AS (...) DELETE FROM ... starts with WITH, so it was read as a query and skipped the gate entirely. The replacement strips comments and string literals, then looks at the first verb outside parentheses, and treats anything not on a read list as a write. It is still a classifier, which is why rule four exists: when the classifier is wrong, PostgreSQL is not.
The result reads like this when a write is attempted on a readonly connection:
{
"code": "DATABASE_CONNECTION_READONLY",
"message": "Database connection \"local\" is readonly: true, so writes are refused here regardless of any allow_write grant. Also refused by: no_grant.",
"action": "Run this statement on a writable connection, or ask the user to remove `readonly: true` if it was not meant to be a guard."
}
Errors carry a code, an action, and the config key involved, because the primary consumer is an assistant that can act on them. A missing GitLab token is not a dead end: the error names gitlab_set_config, the assistant asks for a token, retries, and the session continues.
One more grant is deliberate: config values may be cmd: prefixed, which runs a command such as pass show gitlab/token and uses its stdout. That is code execution from a config file, so it is unlocked by an environment variable, DEVTOOLS_ALLOW_CMD, never by a config key. A cloned repository can supply a config file. It cannot supply the environment of the process that launches the server.
Two bugs the happy path never showed
The first was the SQL gate above. It worked for every query I typed by hand, because I type SELECT. It failed for the shape an agent is likely to generate.
The second came from testing against a real PostgreSQL database instead of mocks. Schema introspection failed on a healthy connection. The constraint query read referenced_table_name and referenced_column_name from information_schema.key_column_usage. Those columns exist in MySQL. In PostgreSQL they do not exist at all, and the query failed before returning a single row. The fix reads the catalog directly: pg_constraint joined to pg_attribute with WITH ORDINALITY, so the referenced column of each member of a composite key lines up by position with the key itself. The MySQL query is untouched, because the thing that broke it is a PostgreSQL difference.
Both bugs share a lesson I keep relearning: a test double proves my mapping code, not my SQL. The introspection query now has unit tests for how rows become tables, columns, keys, and relationships. The validity of the SQL is proved by running it against a real database, and that is not something CI can do without one.
Two smaller pieces of debt were worth closing while I was there. The repository had no committed lockfile, so every CI run and every publish resolved fresh semver ranges; package-lock.json is now committed and both workflows use npm ci. And a documented security guarantee had drifted from the code: the architecture doc still described the SELECT prefix check that had been replaced. The doc now describes the classifier that exists.
What I test, and where it stops
The suite is 609 tests across 65 files, run with vitest, no database required. Most of it covers pure transforms, error mapping, and the write policy resolution, because those are the places where a wrong answer is silent.
The test I care about most does not test a tool. It reads docs/Tools.md and the README, builds the real registry, and fails in both directions: a registered tool missing from the docs, or a documented tool the registry no longer exposes. It also checks that the README's tool count matches the registry. Adding a tool is one registration plus one documentation edit, and now the build tells me when I forget the second half.
The server does not cache credentials to disk. Runtime configuration supplied by an assistant lives in memory and disappears with the process.
Source discovery is the weak point in editor integrations. An MCP client chooses the server's working directory, and some clients choose their own. That is why DEVTOOLS_CONFIG exists: it names the file outright, relative paths resolve from the working directory, and a path that does not exist is an error rather than a silent fallback to whichever config discovery happened to find. config_init scaffolds at the same path, and the live-reload watcher follows it.
The GitHub and GitLab tools are read first and write only behind the same grant. Review output marks files whose patch the platform withheld, and those files are never counted as reviewed, because a review that quietly skips a file is worse than one that reports the gap.
If you want to use it, the package is on npm and can be run without installing anything:
npx @muhfaris/devtools --help
The source, the full tool reference, and the client setup guides are on GitHub. The tool count and the test count above come from the registry and the suite as they stand today.
Under the hood
Key technical highlights
- One registry and one execute path serve both the MCP server and the CLI
- 68 tools, each declared once and exposed twice
- Write tools are grants: denied by default, blocked by readonly or blocked_env, and refused again by the database session itself
- 609 unit tests across 65 files, one of which fails when the docs and the registry disagree