PlugIt: Turning Any REST API Into an MCP Server Without Handing the Model the Keys

November 17, 2026  6 min read  go · mcp · security · ai

Why I built a single Go binary that turns OpenAPI specs into curated, read-only-by-default MCP servers, and the security problems that shaped it.

Most REST APIs already describe themselves. An OpenAPI spec lists every endpoint, every parameter and every response shape, so on paper you can generate an MCP server from it and let Claude, Cursor or a local model call the API directly. Plenty of tools do exactly that.

I wrote one of them before, a TypeScript tool called api2mcp. It worked, and using it showed me what’s wrong with the whole approach. Converting a spec into tools is the easy 10%. The other 90% is deciding which tools the model should see, what they should be called, and what happens when the model, the spec or the API does something you didn’t expect.

PlugIt is my second attempt, rebuilt from scratch in Go around that 90%.

The problem with “just convert the spec”

Too many tools. GitHub’s REST API has over a thousand operations. Dump them all into an MCP server and you’ve spent a large part of the model’s context window on tool definitions before the conversation starts, and the model gets worse at picking the right tool from a list that long. You almost never want the whole API. You want the eight endpoints that matter for what you’re doing.

Bad names and descriptions. Spec authors write for human developers. You get operation IDs like repos/list-for-authenticated-user and descriptions that are either empty or three paragraphs of Markdown. Models choose tools by name and description, so those matter a lot.

The model can do anything the API can. If the API has a DELETE /repos/{owner}/{repo} endpoint and you exposed it, one confused or prompt-injected model call is enough to delete a repository.

The spec itself is untrusted. You’re often pointing the tool at a spec from somewhere on the internet. That spec controls the base URL your API key gets sent to, the descriptions the model reads (a great place to hide “ignore previous instructions”), and the structure your parser has to survive.

What PlugIt does instead

PlugIt is one binary. You point it at an OpenAPI 3.0/3.1, Swagger 2.0 or Postman v2 spec and it opens a terminal UI where you pick the tools you want, rename them and rewrite their descriptions. A live token counter shows what your selection will cost in context. When you save, you get a small, hand-editable plugit.yaml, and plugit install adds a plugit serve <name> entry to Claude Desktop, Claude Code, Cursor, VS Code, Codex, Windsurf, Gemini CLI or LM Studio.

If you just want to try it, there’s a zero-setup mode:

{
  "mcpServers": {
    "petstore": {
      "command": "/full/path/to/plugit",
      "args": ["run", "https://petstore.swagger.io/v2/swagger.json"]
    }
  }
}

plugit run saves nothing, is read-only, and refuses to start if the selection is bigger than 40 tools.

There are no accounts, no hosted backend, no LLM calls and no telemetry. Everything runs on your machine.

Security decisions that shaped it

I designed PlugIt by writing the threat model first, and most of the interesting code came out of it.

Read-only by default

Every tool is classified by HTTP method. In the default read-only mode, the model never even sees POST, PUT, PATCH or DELETE tools. They aren’t in the tool list at all. confirm-writes offers them but makes the MCP client ask you before each call, and refuses to run them if the client can’t ask. full mode exists, but switching to it takes a deliberate second keypress, and per-tool overrides can only make a tool stricter, never looser.

The host never comes from the model or the spec

When you add an API, you confirm and pin its base_url. Credentials are attached per request, and only when the request’s origin matches that pinned origin exactly. Redirects have to stay on the same origin. There’s no “call this raw URL” tool, and headers like Authorization, Cookie, Host and X-Forwarded-* can never become tool parameters.

An SSRF guard on the dialed IP, not the hostname

Checking a hostname before the request doesn’t stop DNS rebinding. PlugIt checks the resolved IP at the moment the connection is made, inside net.Dialer.Control. Loopback and private ranges are blocked unless you set allow_private: true, and cloud metadata addresses like 169.254.169.254 are always blocked.

Secrets live in the keyring, and get redacted everywhere

Config files and command lines can’t hold secrets. Other users on the machine can read process arguments, and config files end up in dotfile repos. PlugIt only accepts references: keyring:service/key or env:VAR. The MCP client config it writes never contains a secret.

Every resolved secret is also masked in logs, errors and tool results, and not only in its raw form: its percent-encoded and base64 forms are masked too. That last part matters more than you’d expect. APIs love echoing your request back in error bodies, sometimes with the token Basic-auth encoded.

Linting for prompt injection in specs

plugit lint runs about twenty rules over your curated tools. Some are about quality, like missing descriptions, too many parameters or a tool budget that’s too big. Others are about safety: descriptions that read like instructions to the model, hidden or zero-width text, a GET endpoint whose name suggests it changes something, or a parameter that looks like a credential the model would have to make up.

Parsing hostile specs in a child process

This one came from a real bug. PlugIt uses libopenapi to parse specs, and libopenapi does some of its work on goroutines it starts itself. A panic on one of those goroutines can’t be recovered by the caller, so one crafted spec could crash the whole process (pb33f/libopenapi#705).

The fix was to stop parsing untrusted specs in-process at all. PlugIt re-executes its own binary with a hidden argument, sends the spec over stdin and reads the parsed result from stdout. The child gets an almost empty environment, so secrets in the parent’s env vars never reach the code handling untrusted input. A crash, a timeout or oversized output in the child becomes an ordinary error in the parent. Size, $ref depth and YAML alias limits apply on top of that, and external $refs are never fetched.

Seeing what the model actually does

Giving a model tools and then never looking at what it does with them is how surprises happen. plugit logs is a live inspector of every call your MCP clients make, plugit stats shows call counts, error rates and p50/p95 latency per tool, and plugit try makes one test call from the terminal with the request printed and secrets masked. When an API changes, plugit sync re-fetches the spec and shows you the diff before adopting it. Your overrides survive, and the pinned base URL never changes.

Try it

go install github.com/swayam5342/plugit/cmd/plugit@latest

Or grab a prebuilt binary for Windows, macOS or Linux from the releases page. Releases are signed with cosign and ship with SBOMs and build provenance.

PlugIt is at v0.2 and Apache-2.0 licensed. The website has a live demo. If you point it at an API and something breaks, or the TUI does something confusing, please open an issue. If it’s a security problem, report it privately through SECURITY.md.


← all posts