Skip to main content
Glama
README.md
# insomnia-mcp v0.1.6-beta

A fully-featured MCP server for the [Insomnia](https://insomnia.rest) API client.
Exposes **83 tools** across 13 categories โ€” letting Claude read, write, execute, test,
and document your Insomnia collections without opening the UI.

---

## Quick Start

```bash
npm install
npm run build
```

Add to `~/.config/Claude/claude_desktop_config.json` (Claude Desktop on Linux/macOS):

```json
{
  "mcpServers": {
    "insomnia": {
      "command": "node",
      "args": ["/absolute/path/to/insomnia-mcp/dist/index.js"]
    }
  }
}
```

Or register with Claude Code:

```bash
claude mcp add --scope global insomnia node /absolute/path/to/insomnia-mcp/dist/index.js
```

### Database auto-detection

| Platform | Path                                      |
| -------- | ----------------------------------------- |
| Linux    | `~/.config/Insomnia/`                     |
| macOS    | `~/Library/Application Support/Insomnia/` |
| Windows  | `%APPDATA%\Insomnia\`                     |

Override with env var: `INSOMNIA_DB_PATH=/custom/path node dist/index.js`

Supports both **Insomnia v12+ multi-file** (per-type `.db` files) and **legacy single-file** (`insomnia.db`) formats automatically.

---

## All 83 Tools

### ๐Ÿ—‚ Workspaces (4)

| Tool               | Description                                 |
| ------------------ | ------------------------------------------- |
| `list_workspaces`  | List all workspaces                         |
| `get_workspace`    | Get workspace with full request/folder tree |
| `create_workspace` | Create a new workspace                      |
| `delete_workspace` | Delete workspace and all contents           |

### ๐Ÿ“จ Requests (15)

| Tool                     | Description                                              |
| ------------------------ | -------------------------------------------------------- |
| `list_requests`          | List requests, filtered by workspace                     |
| `get_request`            | Get full request details                                 |
| `search_requests`        | Fuzzy search by method, path, or name                    |
| `create_request`         | Create a new request                                     |
| `update_request`         | Partial update a request                                 |
| `delete_request`         | Delete a request                                         |
| `create_folder`          | Create a RequestGroup folder                             |
| `set_active_environment` | Persist active env for a workspace                       |
| `send_request`           | Send stored request with auto auth + variable resolution |
| `send_http_request`      | Fire a one-off ad-hoc HTTP request                       |
| `run_request_chain`      | Chain requests, extracting values between steps          |
| `get_response_history`   | View last 10 responses for a request                     |
| `export_as_curl`         | Render request as a curl command                         |
| `import_from_curl`       | Parse a curl command and save as a request               |
| `clear_token_cache`      | Force OAuth2 token re-fetch                              |

### ๐ŸŒ Environments (6)

| Tool                          | Description                                                   |
| ----------------------------- | ------------------------------------------------------------- |
| `list_environments`           | List environments for a workspace (includes sub-environments) |
| `get_environment`             | Get environment with all variable values                      |
| `create_environment`          | Create base or sub-environment                                |
| `update_environment`          | Merge or replace environment variables                        |
| `delete_environment_variable` | Remove specific variables                                     |
| `delete_environment`          | Delete an environment                                         |

**Sub-environment support:** Insomnia uses a two-level hierarchy โ€” a base environment holds
shared variables, and named sub-environments (e.g. Staging, Production) extend it. All
environment tools correctly handle this hierarchy:

```
Workspace
โ””โ”€โ”€ Base Environment          โ† shared vars (base_url, api_version, โ€ฆ)
      โ”œโ”€โ”€ Staging             โ† overrides: base_url โ†’ staging.example.com
      โ””โ”€โ”€ Production          โ† overrides: base_url โ†’ api.example.com
```

- `list_environments` with a `workspace_id` returns the base environment **and** all its
  sub-environments.
- `set_active_environment` accepts a sub-environment ID directly.
- `send_request` merges base + active sub-environment variables (sub-env values override
  base values for the same key), then resolves `{{ variable }}` placeholders in the URL,
  headers, body, and auth fields.

### ๐Ÿ“Š Status & Discovery (3)

| Tool                   | Description                                     |
| ---------------------- | ----------------------------------------------- |
| `insomnia_status`      | DB format, workspaces, token cache health check |
| `endpoint_summary`     | Compact API reference grouped by folder         |
| `compare_environments` | Diff variables between two environments         |

### ๐Ÿ”ฌ Response Intelligence (4)

| Tool                    | Description                                    |
| ----------------------- | ---------------------------------------------- |
| `infer_response_schema` | Send request and infer JSON schema of response |
| `assert_response`       | Validate response with flexible assertions     |
| `diff_responses`        | Structural JSON diff between two responses     |
| `run_with_scripts`      | Execute pre/post request scripts around a send |

### ๐Ÿ—„ Projects & Sync (4)

| Tool               | Description                                  |
| ------------------ | -------------------------------------------- |
| `list_projects`    | List Insomnia v12+ projects                  |
| `git_sync_status`  | Detect Git sync config for a workspace       |
| `check_stale_data` | Warn if DB files changed since last read     |
| `run_folder`       | Run all requests in a folder as a test suite |

### โš™๏ธ Bulk Operations (7)

| Tool                      | Description                                                |
| ------------------------- | ---------------------------------------------------------- |
| `generate_crud_requests`  | Auto-generate GET/POST/PUT/PATCH/DELETE set for a resource |
| `duplicate_workspace`     | Deep copy workspace with remapped IDs                      |
| `move_folder`             | Move a folder to a different parent                        |
| `bulk_update_header`      | Add/update/remove a header across all requests             |
| `find_duplicate_requests` | Find requests with identical method+URL                    |
| `import_openapi`          | Import OpenAPI 3.x / Swagger 2.x spec                      |
| `export_openapi`          | Export workspace as OpenAPI 3.0 JSON                       |

### ๐Ÿงช Testing (6)

| Tool              | Description                                    |
| ----------------- | ---------------------------------------------- |
| `load_test`       | Run load test โ€” p50/p90/p95/p99 latency + RPS  |
| `contract_test`   | Validate response against expected JSON schema |
| `health_check`    | Smoke test all endpoints in a workspace        |
| `run_data_driven` | Run request for each row of CSV or JSON data   |
| `response_trend`  | Analyse latency + status trends from history   |
| `export_junit`    | Run tests and export JUnit XML for CI/CD       |

### ๐Ÿ”„ Sync & Import/Export (5)

| Tool                     | Description                                 |
| ------------------------ | ------------------------------------------- |
| `import_postman`         | Import Postman Collection v2.1 JSON         |
| `export_postman`         | Export workspace as Postman Collection v2.1 |
| `import_har`             | Import browser DevTools HAR file            |
| `export_insomnia_bundle` | Export as Insomnia v4 JSON bundle           |
| `workspace_changelog`    | Diff workspace against a previous snapshot  |

### ๐Ÿค– AI-Powered (5)

| Tool                         | Description                                      |
| ---------------------------- | ------------------------------------------------ |
| `ai_document_endpoint`       | Auto-generate markdown docs for an endpoint      |
| `ai_generate_body`           | Generate a realistic request body with AI        |
| `ai_detect_breaking_changes` | Classify API changes as breaking vs non-breaking |
| `ai_suggest_tests`           | Suggest missing assertions and edge cases        |
| `ai_fix_request`             | Diagnose and suggest fixes for failing requests  |

### ๐Ÿ” Observability (7)

| Tool                | Description                                    |
| ------------------- | ---------------------------------------------- |
| `inspect_ssl`       | Inspect TLS certificate โ€” expiry, cipher, SANs |
| `follow_redirects`  | Trace the full redirect chain for a URL        |
| `lint_request`      | Lint a request for common mistakes             |
| `lint_workspace`    | Lint all requests in a workspace               |
| `start_mock_server` | Start a local HTTP mock server                 |
| `stop_mock_server`  | Stop a running mock server                     |
| `mock_server_log`   | View request log for a mock server             |

### ๐Ÿ“ก Protocols & Auth (13)

| Tool                     | Description                                        |
| ------------------------ | -------------------------------------------------- |
| `websocket_connect`      | Connect to WebSocket, send/receive messages        |
| `graphql_introspect`     | Run GraphQL introspection, get full schema         |
| `graphql_query`          | Send a GraphQL query or mutation                   |
| `graphql_format`         | Pretty-print a GraphQL query string                |
| `graphql_scan_workspace` | Find all GraphQL requests in a workspace           |
| `sign_aws_request`       | Sign a request with AWS Signature v4               |
| `generate_pkce`          | Generate PKCE pair + authorization URL             |
| `compute_digest_auth`    | Compute HTTP Digest auth header from 401 challenge |
| `list_cookie_jars`       | List cookie jars for a workspace                   |
| `get_cookie_jar`         | Get all cookies in a jar                           |
| `add_cookie`             | Add or update a cookie                             |
| `clear_cookies`          | Clear cookies (optionally by domain)               |
| `export_cookies`         | Export as Netscape cookie file or Cookie header    |

### ๐Ÿ“ Files (3)

| Tool                     | Description                                    |
| ------------------------ | ---------------------------------------------- |
| `send_multipart_request` | Send multipart/form-data with file attachments |
| `save_response_to_file`  | Download API response directly to disk         |
| `inspect_response`       | Smart binary/text detection with preview       |

---

## Example prompts

```
"List all my Insomnia workspaces"
"Search for the login request and send it"
"Set the Production environment as active for my Payments workspace"
"Switch to the Staging sub-environment and send the create-order request"
"Run the entire Auth folder as a test suite"
"Load test the GET /users endpoint with 20 concurrent users for 500 requests"
"Import this OpenAPI spec and create requests for every endpoint"
"Run the create-user request for each row of this CSV"
"Lint all requests in my workspace before the release"
"Start a mock server on port 4010 that returns 200 for GET /health"
"Introspect the GraphQL schema at https://api.example.com/graphql"
"Check the SSL certificate for api.example.com"
"Generate a full CRUD set of requests for the 'orders' resource"
"Export my workspace as a Postman collection"
"What tests am I missing for my API? Suggest some"
"This request is returning 401 โ€” what's wrong with it?"
```

---

## Architecture

```
src/
โ”œโ”€โ”€ index.ts              Entry point, registers all 83 tools
โ”œโ”€โ”€ insomnia-db.ts        NeDB reader/writer (v12+ multi-file + legacy); two-level env lookup; type sanitization
โ”œโ”€โ”€ http-client.ts        Axios sender with auth, history, secret masking
โ”œโ”€โ”€ http-transport.ts     HTTP+SSE transport: timing-safe auth, CORS, rate limiter, TLS
โ”œโ”€โ”€ auth.ts               Bearer/OAuth2/Basic/APIKey + inheritance
โ”œโ”€โ”€ auth-advanced.ts      AWS SigV4, PKCE, HTTP Digest
โ”œโ”€โ”€ template.ts           Recursive {{ var }} renderer, JSON path extractor
โ”œโ”€โ”€ matcher.ts            Fuzzy request search (method/path/name scoring)
โ”œโ”€โ”€ state.ts              Persistent state: active envs, token cache, history (chmod 0o600)
โ”œโ”€โ”€ security.ts           validateFilePath (path traversal) + isLocalUrl / assertExternalUrlConfirmed (external URL gate)
โ”œโ”€โ”€ scripting.ts          Worker thread spawner for sandboxed script execution
โ”œโ”€โ”€ script-worker.ts      vm.createContext sandbox โ€” no require/import/process/global
โ”œโ”€โ”€ openapi.ts            OpenAPI 3.x / Swagger 2.x import + export
โ”œโ”€โ”€ postman.ts            Postman Collection v2.1 import + export
โ”œโ”€โ”€ har.ts                HAR (browser DevTools) import
โ”œโ”€โ”€ loadtest.ts           Concurrent load test with percentile stats
โ”œโ”€โ”€ datadriven.ts         CSV/JSON row-based test runner
โ”œโ”€โ”€ mock-server.ts        Local HTTP mock server
โ”œโ”€โ”€ observability.ts      SSL inspector, redirect follower, request linter
โ”œโ”€โ”€ graphql.ts            GraphQL introspection, query sender, formatter
โ”œโ”€โ”€ cookies.ts            CookieJar CRUD + Netscape/header export
โ”œโ”€โ”€ __tests__/
โ”‚   โ”œโ”€โ”€ security.test.ts          validateFilePath (34 cases) + isLocalUrl / assertExternalUrlConfirmed
โ”‚   โ”œโ”€โ”€ http-transport.test.ts    real HTTP server on port 0: auth, CORS, rate limiter, 404
โ”‚   โ”œโ”€โ”€ scripting.test.ts         Worker sandbox: execution, isolation, timeout
โ”‚   โ”œโ”€โ”€ state.test.ts             chmod 0o600, read/write round-trip, token cache, history
โ”‚   โ”œโ”€โ”€ insomnia-db.test.ts       type sanitization, upsert/read, deleteDoc, generateId, sub-env resolution
โ”‚   โ””โ”€โ”€ template.test.ts          variable rendering
โ””โ”€โ”€ tools/
    โ”œโ”€โ”€ workspaces.ts     4 tools
    โ”œโ”€โ”€ requests.ts       15 tools
    โ”œโ”€โ”€ environments.ts   6 tools
    โ”œโ”€โ”€ status.ts         3 tools
    โ”œโ”€โ”€ response.ts       4 tools
    โ”œโ”€โ”€ projects.ts       4 tools
    โ”œโ”€โ”€ bulk.ts           7 tools
    โ”œโ”€โ”€ testing.ts        6 tools
    โ”œโ”€โ”€ sync.ts           5 tools
    โ”œโ”€โ”€ ai-tools.ts       5 tools
    โ”œโ”€โ”€ observability.ts  7 tools
    โ”œโ”€โ”€ protocols.ts      13 tools
    โ””โ”€โ”€ files.ts          3 tools
```

## Security

insomnia-mcp applies defence-in-depth across every attack surface. All
protections are implemented with Node.js built-in modules only โ€” no extra
dependencies.

### Script sandbox (`src/script-worker.ts`)

Pre-request and post-response scripts run inside a dedicated Worker thread
and are further isolated with `vm.createContext()` + `vm.Script.runInContext()`:

- **No `require`** โ€” not in the sandbox context
- **No `process` / `global`** โ€” not passed into the context
- **No `import()`** โ€” `importModuleDynamically` callback is intentionally
  omitted, causing any `import()` call to throw
- **Hard timeout** โ€” the Worker is terminated via `worker.terminate()` after
  2 seconds if the script does not finish
- Only a safe explicit allowlist of globals is available: `insomnia`, `console`
  (shimmed), `btoa`/`atob`, `Date`, `Math`, `JSON`, and standard constructors

### Path traversal prevention (`src/security.ts` โ€” `validateFilePath`)

All user-supplied file paths (file uploads, response downloads, JUnit export)
are validated before use:

1. Resolved to absolute form with `path.resolve()` (collapses `..` sequences)
2. Checked against a blocklist of sensitive system directories (`/etc`, `/proc`,
   `/sys`, `/dev`, `/boot`, `/run`, `/var/run`, and Windows equivalents)
3. Optionally confined to an `allowedBase` directory (used for file uploads)

### External URL confirmation gate (`src/security.ts` โ€” `assertExternalUrlConfirmed`)

Every tool that makes an outbound network call classifies the target URL as
**local** or **external** before sending:

**Local (always allowed, no confirmation needed):**

- Loopback โ€” `localhost`, `127.x.x.x`, `::1`
- RFC-1918 private ranges โ€” `10.x`, `172.16-31.x`, `192.168.x`
- Link-local / cloud metadata โ€” `169.254.x.x`, `fe80::`, `metadata.google.internal`
- Wildcard bind address โ€” `0.0.0.0`

**External (requires explicit confirmation):**
Any URL that does not match the above. When an external URL is detected and
`confirmed` is not `true`, the call is **blocked** and the AI agent is
instructed to show the full URL to the user and retry with `confirmed: true`.

All ~25 outbound call tools (`send_request`, `send_http_request`,
`websocket_connect`, `inspect_ssl`, `graphql_introspect`, `load_test`,
`health_check`, and more) accept an optional `confirmed?: boolean` parameter
for this purpose.

### HTTP transport security (`src/http-transport.ts`)

| Feature              | Details                                                                                                              |
| -------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **Timing-safe auth** | Bearer token compared with `crypto.timingSafeEqual` โ€” prevents character-by-character timing attacks                 |
| **CORS allowlist**   | When `--cors-origins` is set, only allowlisted origins are reflected. Without it, falls back to `*` (no credentials) |
| **Rate limiting**    | Sliding-window per-IP limiter (default 600 req/min, configurable). Returns `429` with `Retry-After: 60`              |
| **TLS**              | Pass `--cert` + `--key` to enable HTTPS. Warns when binding to non-loopback without TLS                              |
| **Port binding**     | Actual bound port is read via `server.address()` โ€” ephemeral port 0 works correctly                                  |

### State file permissions (`src/state.ts`)

`mcp-state.json` (which stores token cache, active environments, and response
history) is written with a `.tmp` โ†’ atomic rename pattern and immediately
`chmod`'d to `0o600` (owner read/write only) on POSIX systems.

### DB type sanitization (`src/insomnia-db.ts`)

`upsertDoc` strips any `/` or `..` from `doc.type` before constructing the
`.db` file path, preventing a malicious document type from writing outside the
Insomnia database directory.

---

## Notes

- **Write operations**: close Insomnia before writing to avoid DB conflicts
- **Sub-environments**: use `list_environments` to find sub-env IDs, then `set_active_environment` with the sub-env ID โ€” base + sub variables are merged automatically on every `send_request`
- **External URLs**: all outbound tools require `confirmed: true` for public internet URLs โ€” local/private addresses (localhost, RFC-1918, link-local) are always allowed without confirmation
- **AI tools**: require network access to `api.anthropic.com` from the MCP server process
- **Mock server**: runs in-process; ports persist until `stop_mock_server` is called
- **Token cache**: stored in `mcp-state.json` alongside your `.db` files

---

## IDE & Tool Setup

### Automatic (recommended)

```bash
npm run build
node setup.js
```

The setup script auto-detects VS Code, Cursor, Windsurf, Zed, PHPStorm, OpenCode, and Claude Desktop, then writes the correct config file for each one. It also asks about Devin (HTTP mode) and Claude Code.

---

### Manual per-tool

#### VS Code + GitHub Copilot Agent Mode

The `.vscode/mcp.json` file is already in this repo. Just open the project and Copilot will pick it up.

For global install (works in any project):

```bash
# macOS
echo '{"servers":{"insomnia":{"type":"stdio","command":"node","args":["/ABSOLUTE/PATH/dist/index.js"]}}}' \
  > "$HOME/Library/Application Support/Code/User/mcp.json"
```

#### Cursor

`.cursor/mcp.json` is already in this repo for project-level use.

Global (`~/.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "insomnia": {
      "command": "node",
      "args": ["/absolute/path/to/insomnia-mcp/dist/index.js"]
    }
  }
}
```

#### Windsurf

Add to `~/.codeium/windsurf/mcp_config.json` (same format as Cursor above).

#### Zed

`.zed/settings.json` is already in this repo.

Global (`~/.config/zed/settings.json`):

```json
{
  "context_servers": {
    "insomnia-mcp": {
      "command": {
        "path": "node",
        "args": ["/absolute/path/to/insomnia-mcp/dist/index.js"]
      }
    }
  }
}
```

#### PHPStorm / JetBrains IDEs

`.idea/mcp.xml` is already in this repo.
Or via UI: **Settings โ†’ Tools โ†’ AI Assistant โ†’ Model Context Protocol (MCP) โ†’ +**

#### OpenCode

Add to `~/.config/opencode/config.json`:

```json
{
  "mcp": {
    "insomnia": {
      "type": "local",
      "command": ["node", "/absolute/path/to/insomnia-mcp/dist/index.js"]
    }
  }
}
```

#### Devin

Devin connects via HTTP/SSE. Start the server in HTTP mode first:

```bash
node dist/index.js --transport http --host 0.0.0.0 --port 3282 --auth-token mysecret
```

Then in Devin: **Settings โ†’ MCP โ†’ Add Server โ†’ URL**: `http://YOUR_SERVER_IP:3282/mcp`
Add header: `Authorization: Bearer mysecret`

#### Claude Desktop

Add to `~/.config/Claude/claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "insomnia": {
      "command": "node",
      "args": ["/absolute/path/to/insomnia-mcp/dist/index.js"]
    }
  }
}
```

#### Claude Code

```bash
claude mcp add --scope global insomnia node /absolute/path/to/insomnia-mcp/dist/index.js
```

---

## Transports

### stdio (default)

For local editors that spawn the process directly.

```bash
node dist/index.js
```

### HTTP + SSE

For remote tools, Devin, browser-based clients, or when you want to share the server.

```bash
node dist/index.js --transport http --port 3282
# โ†’ MCP endpoint : http://127.0.0.1:3282/mcp
# โ†’ Health check : http://127.0.0.1:3282/health
# โ†’ Server info  : http://127.0.0.1:3282/info
```

### Both simultaneously

Serve stdio for local editors and HTTP for remote tools at the same time.

```bash
node dist/index.js --transport both --port 3282
```

### With authentication

```bash
node dist/index.js --transport http --auth-token mysecrettoken
# All requests must include: Authorization: Bearer mysecrettoken
```

---

## Config file (insomnia-mcp.config.json)

Place in your project root or home directory. Useful for tools that don't inherit shell env vars (Windsurf, PHPStorm).

```bash
node dist/index.js --init > insomnia-mcp.config.json
# or
npm run init-config
```

Generated file:

```json
{
  "dbPath": "/home/you/.config/Insomnia",
  "transport": "stdio",
  "port": 3282,
  "host": "127.0.0.1",
  "basePath": "",
  "cors": false,
  "authToken": "",
  "verbose": false
}
```

Config resolution order (highest priority first):

1. CLI flags (`--db-path`, `--port`, `--transport`, `--auth-token`, `--cors`, `--verbose`)
2. Environment variables (`INSOMNIA_DB_PATH`, `MCP_PORT`, `MCP_TRANSPORT`, `MCP_AUTH_TOKEN`)
3. `insomnia-mcp.config.json` (cwd โ†’ home dir)
4. Built-in defaults

TDQS

C2.9/5.0

Scored across 82 tools

Disambiguation2/5

Many tools send requests and then inspect/assert/analyse responses (send_request, send_http_request, assert_response, infer_response_schema, contract_test, inspect_response, ai_document_endpoint, ai_fix_request), creating overlapping boundaries and likely misselection. Descriptions help, but several tools have unclear practical distinctions.

Naming Consistency4/5

All names use snake_case and are generally descriptive, with mostly verb_noun patterns. A few noun-phrase or status-style names (insomnia_status, endpoint_summary, response_trend, mock_server_log) are minor deviations.

Tool Count1/5

82 tools is far beyond a well-scoped MCP server and includes many near-duplicate execution, inspection, testing, import/export, and helper variants. This is an extreme count mismatch for the apparent scope.

Completeness4/5

The surface covers workspaces, requests, environments, sending, testing, GraphQL, WebSocket, mock servers, imports/exports, auth helpers, and cookies. Some lifecycle gaps remain, such as no update_workspace, no delete_folder/get_folder, limited project management, and incomplete cookie-jar lifecycle operations.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues