@yawlabs/ctxlint 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pre-commit-hooks.yaml +10 -10
- package/MCP_CONFIG_LINT_SPEC.md +411 -411
- package/README.md +564 -564
- package/dist/index.js +298 -224
- package/package.json +1 -1
package/MCP_CONFIG_LINT_SPEC.md
CHANGED
|
@@ -1,411 +1,411 @@
|
|
|
1
|
-
# MCP Server Configuration Linting Specification
|
|
2
|
-
|
|
3
|
-
**Version:** 1.0.0-draft
|
|
4
|
-
**Date:** 2026-04-07
|
|
5
|
-
**MCP Spec Compatibility:** 2025-11-25 (Streamable HTTP)
|
|
6
|
-
**Maintained by:** [Yaw Labs](https://yaw.sh) / [ctxlint](https://github.com/YawLabs/ctxlint)
|
|
7
|
-
**License:** CC BY 4.0
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## What is this?
|
|
12
|
-
|
|
13
|
-
MCP server configuration files (`.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, etc.) define which tools an AI agent can access. They are a context interface — alongside instruction files like `CLAUDE.md` and `.cursorrules`, they shape what an agent knows and can do.
|
|
14
|
-
|
|
15
|
-
This specification defines a standard set of lint rules for validating MCP server configurations across all major AI coding clients. It is tool-agnostic: any linter, IDE extension, CI check, or AI agent can implement these rules.
|
|
16
|
-
|
|
17
|
-
The specification includes:
|
|
18
|
-
- A complete reference of MCP config file locations, formats, and client-specific behaviors
|
|
19
|
-
- 43 lint rules organized into 8 categories with defined severities
|
|
20
|
-
- A machine-readable rule catalog ([`mcp-config-lint-rules.json`](./mcp-config-lint-rules.json))
|
|
21
|
-
- Auto-fix definitions for rules that support automated correction
|
|
22
|
-
|
|
23
|
-
**Reference implementation:** [ctxlint](https://github.com/YawLabs/ctxlint) (v0.4.0+)
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## Related specifications
|
|
28
|
-
|
|
29
|
-
This spec is part of a family of open specifications maintained by Yaw Labs for MCP tooling:
|
|
30
|
-
|
|
31
|
-
| Spec | Scope | Input |
|
|
32
|
-
|---|---|---|
|
|
33
|
-
| **mcp-config-lint** (this spec) | Static analysis of MCP client config files | `.cursor/mcp.json`, `.vscode/mcp.json`, `.mcp.json`, etc. |
|
|
34
|
-
| [**mcp-compliance**](https://github.com/YawLabs/mcp-compliance/blob/master/MCP_COMPLIANCE_SPEC.md) | Runtime testing of live MCP servers | A live server URL + transport |
|
|
35
|
-
|
|
36
|
-
The two are **complementary, not overlapping**. `mcp-config-lint` catches problems before deploy by reading JSON on disk; `mcp-compliance` catches problems after deploy by speaking the protocol to a running server. A production setup typically runs both.
|
|
37
|
-
|
|
38
|
-
Both specs target MCP spec version `2025-11-25` and ship machine-readable rule catalogs with stable rule IDs.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Table of contents
|
|
43
|
-
|
|
44
|
-
- [1. MCP Config Landscape Reference](#1-mcp-config-landscape-reference)
|
|
45
|
-
- [1.1 Config format](#11-config-format)
|
|
46
|
-
- [1.2 Server entry fields](#12-server-entry-fields)
|
|
47
|
-
- [1.3 File locations by client](#13-file-locations-by-client)
|
|
48
|
-
- [1.4 Environment variable syntax](#14-environment-variable-syntax)
|
|
49
|
-
- [1.5 Override precedence](#15-override-precedence)
|
|
50
|
-
- [1.6 Platform-specific behaviors](#16-platform-specific-behaviors)
|
|
51
|
-
- [2. Lint Rules](#2-lint-rules)
|
|
52
|
-
- [2.1 mcp-schema — structural validation](#21-mcp-schema--structural-validation)
|
|
53
|
-
- [2.2 mcp-security — hardcoded secrets](#22-mcp-security--hardcoded-secrets)
|
|
54
|
-
- [2.3 mcp-commands — stdio command validation](#23-mcp-commands--stdio-command-validation)
|
|
55
|
-
- [2.4 mcp-deprecated — deprecated patterns](#24-mcp-deprecated--deprecated-patterns)
|
|
56
|
-
- [2.5 mcp-env — environment variable validation](#25-mcp-env--environment-variable-validation)
|
|
57
|
-
- [2.6 mcp-urls — URL validation](#26-mcp-urls--url-validation)
|
|
58
|
-
- [2.7 mcp-consistency — cross-file consistency](#27-mcp-consistency--cross-file-consistency)
|
|
59
|
-
- [2.8 mcp-redundancy — unnecessary configs](#28-mcp-redundancy--unnecessary-configs)
|
|
60
|
-
- [3. Rule Catalog (machine-readable)](#3-rule-catalog-machine-readable)
|
|
61
|
-
- [4. Implementing This Specification](#4-implementing-this-specification)
|
|
62
|
-
- [5. Contributing](#5-contributing)
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## 1. MCP Config Landscape Reference
|
|
67
|
-
|
|
68
|
-
This section documents the full MCP server configuration landscape as of April 2026. Implementors should treat this as the authoritative cross-client reference for file locations, formats, and behaviors.
|
|
69
|
-
|
|
70
|
-
### 1.1 Config format
|
|
71
|
-
|
|
72
|
-
Every MCP config file is a JSON object with a root key containing named server entries. Each server entry describes how the client connects to one MCP server.
|
|
73
|
-
|
|
74
|
-
There are two active transport types:
|
|
75
|
-
|
|
76
|
-
**stdio** — the client launches a local subprocess and communicates over stdin/stdout using JSON-RPC:
|
|
77
|
-
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"mcpServers": {
|
|
81
|
-
"my-server": {
|
|
82
|
-
"command": "npx",
|
|
83
|
-
"args": ["-y", "@example/mcp-server"],
|
|
84
|
-
"env": { "DEBUG": "true" }
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**Streamable HTTP** — the client connects to a remote URL over HTTP:
|
|
91
|
-
|
|
92
|
-
```json
|
|
93
|
-
{
|
|
94
|
-
"mcpServers": {
|
|
95
|
-
"my-server": {
|
|
96
|
-
"type": "http",
|
|
97
|
-
"url": "https://my-server.example.com/mcp",
|
|
98
|
-
"headers": {
|
|
99
|
-
"Authorization": "Bearer ${API_KEY}"
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**SSE (Server-Sent Events)** — deprecated as of the March 2025 MCP spec update. Uses `"type": "sse"`. Still supported by most clients but should be migrated to Streamable HTTP.
|
|
107
|
-
|
|
108
|
-
### 1.2 Server entry fields
|
|
109
|
-
|
|
110
|
-
| Field | Type | Transport | Required | Description |
|
|
111
|
-
|---|---|---|---|---|
|
|
112
|
-
| `type` | `"stdio"` \| `"http"` \| `"sse"` | All | No | Transport protocol. Defaults to `stdio` if `command` is present. |
|
|
113
|
-
| `command` | string | stdio | Yes | Executable to launch as a subprocess. |
|
|
114
|
-
| `args` | string[] | stdio | No | Arguments passed to the command. |
|
|
115
|
-
| `env` | Record<string, string> | stdio | No | Environment variables for the subprocess. |
|
|
116
|
-
| `url` | string | http, sse | Yes | Remote endpoint URL. |
|
|
117
|
-
| `headers` | Record<string, string> | http, sse | No | HTTP headers sent with every request. |
|
|
118
|
-
| `disabled` | boolean | All | No | Whether the server is disabled. (Cline-specific) |
|
|
119
|
-
| `autoApprove` | string[] | All | No | Tool names to auto-approve without user confirmation. (Cline-specific) |
|
|
120
|
-
| `timeout` | number (ms) | All | No | Max response wait time. Default: 60000. (Amazon Q-specific) |
|
|
121
|
-
| `oauth` | object | http | No | OAuth 2.0 configuration. (Claude Code-specific) |
|
|
122
|
-
| `headersHelper` | string | http | No | Shell command that outputs JSON headers to stdout. (Claude Code-specific) |
|
|
123
|
-
|
|
124
|
-
### 1.3 File locations by client
|
|
125
|
-
|
|
126
|
-
#### Project-level configs
|
|
127
|
-
|
|
128
|
-
These live relative to the project root and are typically committed to version control.
|
|
129
|
-
|
|
130
|
-
| File path | Client | Root key | Notes |
|
|
131
|
-
|---|---|---|---|
|
|
132
|
-
| `.mcp.json` | Claude Code | `mcpServers` | The universal project-level convention. |
|
|
133
|
-
| `.cursor/mcp.json` | Cursor | `mcpServers` | |
|
|
134
|
-
| `.vscode/mcp.json` | VS Code / GitHub Copilot | **`servers`** | Only client that uses `servers` instead of `mcpServers`. |
|
|
135
|
-
| `.amazonq/mcp.json` | Amazon Q Developer | `mcpServers` | Server names must be unique across project + global. |
|
|
136
|
-
| `.continue/mcpServers/*.json` | Continue.dev | varies | Accepts config files from any client format. |
|
|
137
|
-
|
|
138
|
-
#### User/global-level configs
|
|
139
|
-
|
|
140
|
-
These are user-specific and not committed to version control.
|
|
141
|
-
|
|
142
|
-
| File path | Client | Root key | Platform |
|
|
143
|
-
|---|---|---|---|
|
|
144
|
-
| `~/.claude.json` | Claude Code | `mcpServers` | All |
|
|
145
|
-
| `~/.claude/settings.json` | Claude Code | `mcpServers` | All |
|
|
146
|
-
| `~/.cursor/mcp.json` | Cursor | `mcpServers` | All |
|
|
147
|
-
| `~/Library/Application Support/Claude/claude_desktop_config.json` | Claude Desktop | `mcpServers` | macOS |
|
|
148
|
-
| `%APPDATA%\Claude\claude_desktop_config.json` | Claude Desktop | `mcpServers` | Windows |
|
|
149
|
-
| `~/.codeium/windsurf/mcp_config.json` | Windsurf | `mcpServers` | All |
|
|
150
|
-
| `~/.aws/amazonq/mcp.json` | Amazon Q | `mcpServers` | All |
|
|
151
|
-
| VS Code globalStorage `saoudrizwan.claude-dev/settings/cline_mcp_settings.json` | Cline | `mcpServers` | All |
|
|
152
|
-
|
|
153
|
-
### 1.4 Environment variable syntax
|
|
154
|
-
|
|
155
|
-
Different clients use different syntax for referencing environment variables in config values.
|
|
156
|
-
|
|
157
|
-
| Client | Syntax | Default value support | Example |
|
|
158
|
-
|---|---|---|---|
|
|
159
|
-
| Claude Code | `${VAR}` | `${VAR:-default}` | `${API_KEY}` |
|
|
160
|
-
| Cursor | `${env:VAR}` | No | `${env:API_KEY}` |
|
|
161
|
-
| Continue.dev | `${{ secrets.VAR }}` | No | `${{ secrets.API_KEY }}` |
|
|
162
|
-
| Windsurf | `${env:VAR}` | No | `${env:API_KEY}` |
|
|
163
|
-
| Claude Desktop | Not supported | N/A | Literal values only |
|
|
164
|
-
| Amazon Q | Not supported | N/A | Literal values only |
|
|
165
|
-
|
|
166
|
-
Env var expansion applies to `command`, `args`, `env`, `url`, and `headers` fields (where supported).
|
|
167
|
-
|
|
168
|
-
### 1.5 Override precedence
|
|
169
|
-
|
|
170
|
-
When the same server name exists at multiple scopes, the most specific scope wins.
|
|
171
|
-
|
|
172
|
-
**Claude Code** (three-tier):
|
|
173
|
-
1. **Local** (highest) — per-user, per-project overrides in `~/.claude.json` under a project path key
|
|
174
|
-
2. **Project** — `.mcp.json` at the repo root
|
|
175
|
-
3. **User** (lowest) — `~/.claude.json` top-level `mcpServers`
|
|
176
|
-
|
|
177
|
-
**Cursor:** project `.cursor/mcp.json` overrides global `~/.cursor/mcp.json`.
|
|
178
|
-
|
|
179
|
-
**Amazon Q:** workspace `.amazonq/mcp.json` overrides global `~/.aws/amazonq/mcp.json`. Server names must be unique across both.
|
|
180
|
-
|
|
181
|
-
**VS Code:** workspace `.vscode/mcp.json` overrides user-level configuration.
|
|
182
|
-
|
|
183
|
-
**Windsurf, Cline:** Single global config. No override behavior.
|
|
184
|
-
|
|
185
|
-
### 1.6 Platform-specific behaviors
|
|
186
|
-
|
|
187
|
-
**Windows + npx (stdio):** On native Windows (not WSL), `npx` commands must be wrapped with `cmd /c`:
|
|
188
|
-
```json
|
|
189
|
-
{
|
|
190
|
-
"command": "cmd",
|
|
191
|
-
"args": ["/c", "npx", "-y", "@example/mcp-server"]
|
|
192
|
-
}
|
|
193
|
-
```
|
|
194
|
-
Without this wrapper, the subprocess fails to spawn. This is the most common Windows MCP config issue.
|
|
195
|
-
|
|
196
|
-
**Claude.ai custom connectors:** Only support remote MCP servers over Streamable HTTP. No stdio support — browsers cannot launch local subprocesses. stdio-only servers must be hosted remotely to be used with Claude.ai.
|
|
197
|
-
|
|
198
|
-
---
|
|
199
|
-
|
|
200
|
-
## 2. Lint Rules
|
|
201
|
-
|
|
202
|
-
27 rules organized into 8 categories. Each rule has a unique ID, severity level, trigger condition, and message template.
|
|
203
|
-
|
|
204
|
-
Severity levels:
|
|
205
|
-
- **error** — the config is broken or has a security issue. Should fail CI.
|
|
206
|
-
- **warning** — the config has a likely problem. May or may not fail CI depending on strictness.
|
|
207
|
-
- **info** — the config has a potential improvement. Never fails CI.
|
|
208
|
-
|
|
209
|
-
### 2.1 mcp-schema — structural validation
|
|
210
|
-
|
|
211
|
-
Validates that the config file is well-formed JSON with the correct structure for its target client.
|
|
212
|
-
|
|
213
|
-
| Rule ID | Severity | Trigger | Message |
|
|
214
|
-
|---|---|---|---|
|
|
215
|
-
| `mcp-schema/invalid-json` | error | File is not valid JSON | `MCP config is not valid JSON: {parseError}` |
|
|
216
|
-
| `mcp-schema/wrong-root-key` | error | Root key doesn't match expected key for the client | `{file} must use "{expected}" as root key, not "{actual}"` |
|
|
217
|
-
| `mcp-schema/missing-root-key` | error | No recognized root key (`mcpServers` or `servers`) | `MCP config has no "{expected}" key` |
|
|
218
|
-
| `mcp-schema/missing-command` | error | stdio server has no `command` field | `Server "{name}": missing "command" field` |
|
|
219
|
-
| `mcp-schema/missing-url` | error | http/sse server has no `url` field | `Server "{name}": missing "url" field` |
|
|
220
|
-
| `mcp-schema/unknown-transport` | warning | `type` field is not `stdio`, `http`, or `sse` | `Server "{name}": unknown transport type "{type}"` |
|
|
221
|
-
| `mcp-schema/ambiguous-transport` | warning | Server has both `command` and `url` fields | `Server "{name}": has both "command" and "url" — transport is ambiguous` |
|
|
222
|
-
| `mcp-schema/empty-servers` | info | Root key exists but contains no server entries | `MCP config has no server entries` |
|
|
223
|
-
|
|
224
|
-
**Auto-fixable:** `wrong-root-key` — rename the root key to match the expected key.
|
|
225
|
-
|
|
226
|
-
### 2.2 mcp-security — hardcoded secrets
|
|
227
|
-
|
|
228
|
-
Detects secrets committed to version control in MCP config files. Only flags issues in git-tracked files.
|
|
229
|
-
|
|
230
|
-
| Rule ID | Severity | Trigger | Message |
|
|
231
|
-
|---|---|---|---|
|
|
232
|
-
| `mcp-security/hardcoded-bearer` | error | `Authorization` header contains a literal Bearer token (not an env var reference) in a git-tracked file | `Server "{name}": hardcoded Bearer token in a git-tracked file` |
|
|
233
|
-
| `mcp-security/hardcoded-api-key` | error | Header or env value matches known API key patterns in a git-tracked file | `Server "{name}": possible API key in a git-tracked file` |
|
|
234
|
-
| `mcp-security/secret-in-url` | error | URL contains query params that look like secrets (`?key=`, `?token=`, `?api_key=`) in a git-tracked file | `Server "{name}": possible secret in URL query string` |
|
|
235
|
-
| `mcp-security/http-no-tls` | warning | URL uses `http://` for non-localhost target | `Server "{name}": URL uses HTTP without TLS` |
|
|
236
|
-
|
|
237
|
-
**Known API key patterns:**
|
|
238
|
-
```
|
|
239
|
-
sk-[a-zA-Z0-9]{20,} # OpenAI / generic
|
|
240
|
-
ghp_[a-zA-Z0-9]{36} # GitHub personal access token
|
|
241
|
-
ghu_[a-zA-Z0-9]{36} # GitHub user token
|
|
242
|
-
github_pat_[a-zA-Z0-9_]{80,} # GitHub fine-grained PAT
|
|
243
|
-
xoxb-[0-9]{10,} # Slack bot token
|
|
244
|
-
xoxp-[0-9]{10,} # Slack user token
|
|
245
|
-
AKIA[0-9A-Z]{16} # AWS access key ID
|
|
246
|
-
glpat-[a-zA-Z0-9_\-]{20} # GitLab personal access token
|
|
247
|
-
sq0atp-[a-zA-Z0-9_\-]{22} # Square access token
|
|
248
|
-
shpat_[a-fA-F0-9]{32} # Shopify admin API token
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
Also flag any string value > 20 characters that is entirely alphanumeric or base64 characters AND is not an env var reference (`${...}`, `${{ ... }}`).
|
|
252
|
-
|
|
253
|
-
**Auto-fixable:** `hardcoded-bearer`, `hardcoded-api-key` — replace literal value with an env var reference derived from the server name (e.g., `MY_SERVER_API_KEY`).
|
|
254
|
-
|
|
255
|
-
### 2.3 mcp-commands — stdio command validation
|
|
256
|
-
|
|
257
|
-
Validates that stdio server commands and file-path arguments are viable.
|
|
258
|
-
|
|
259
|
-
| Rule ID | Severity | Trigger | Message |
|
|
260
|
-
|---|---|---|---|
|
|
261
|
-
| `mcp-commands/windows-npx-no-wrapper` | error | Platform is Windows and `command` is `npx` without `cmd /c` wrapper | `Server "{name}": npx requires "cmd /c" wrapper on Windows` |
|
|
262
|
-
| `mcp-commands/command-not-found` | warning | `command` is a relative path (`./`, `../`) that doesn't exist | `Server "{name}": command "{command}" not found` |
|
|
263
|
-
| `mcp-commands/args-path-missing` | warning | An arg matches a file path pattern and the file doesn't exist | `Server "{name}": arg "{arg}" references a missing file` |
|
|
264
|
-
|
|
265
|
-
**Notes:**
|
|
266
|
-
- `windows-npx-no-wrapper` should only flag project-level configs, not global configs (the user may be developing cross-platform).
|
|
267
|
-
- `args-path-missing` should only check args that look like file paths (contain `/` with a file extension, or start with `./` / `../`). Skip npm package names and flags.
|
|
268
|
-
- Do not validate that system commands (`npx`, `node`, `python`) exist on PATH — that is a runtime concern, not a config concern.
|
|
269
|
-
|
|
270
|
-
**Auto-fixable:** `windows-npx-no-wrapper` — rewrite `{"command": "npx", "args": [...]}` to `{"command": "cmd", "args": ["/c", "npx", ...]}`.
|
|
271
|
-
|
|
272
|
-
### 2.4 mcp-deprecated — deprecated patterns
|
|
273
|
-
|
|
274
|
-
Flags usage of deprecated MCP transport protocols and patterns.
|
|
275
|
-
|
|
276
|
-
| Rule ID | Severity | Trigger | Message |
|
|
277
|
-
|---|---|---|---|
|
|
278
|
-
| `mcp-deprecated/sse-transport` | warning | Server uses `"type": "sse"` | `Server "{name}": SSE transport is deprecated — use "http" (Streamable HTTP)` |
|
|
279
|
-
|
|
280
|
-
**Auto-fixable:** `sse-transport` — replace `"sse"` with `"http"`.
|
|
281
|
-
|
|
282
|
-
### 2.5 mcp-env — environment variable validation
|
|
283
|
-
|
|
284
|
-
Validates environment variable references for correctness and client compatibility.
|
|
285
|
-
|
|
286
|
-
| Rule ID | Severity | Trigger | Message |
|
|
287
|
-
|---|---|---|---|
|
|
288
|
-
| `mcp-env/wrong-syntax` | error | Env var reference uses wrong syntax for the target client | `Server "{name}": {client} uses {expected}, not {actual}` |
|
|
289
|
-
| `mcp-env/unset-variable` | info | Referenced env var is not set in the current environment | `Server "{name}": environment variable "{var}" is not set` |
|
|
290
|
-
| `mcp-env/empty-env-block` | info | `env` object is present but empty | `Server "{name}": empty "env" block can be removed` |
|
|
291
|
-
|
|
292
|
-
**Syntax validation matrix:**
|
|
293
|
-
|
|
294
|
-
| Config file | Expected syntax | Flag if found |
|
|
295
|
-
|---|---|---|
|
|
296
|
-
| `.mcp.json` | `${VAR}` | `${env:VAR}` |
|
|
297
|
-
| `.cursor/mcp.json` | `${env:VAR}` | `${VAR}` (bare, without `env:`) |
|
|
298
|
-
| `.continue/mcpServers/*.json` | `${{ secrets.VAR }}` | `${VAR}` or `${env:VAR}` |
|
|
299
|
-
| All others | `${VAR}` | — |
|
|
300
|
-
|
|
301
|
-
**Notes:**
|
|
302
|
-
- `unset-variable` is intentionally `info` severity. Many env vars are set only in CI, `.env` files, or shell profiles that aren't available during linting.
|
|
303
|
-
- Scan all string values in `command`, `args`, `url`, `headers`, and `env` for env var references.
|
|
304
|
-
|
|
305
|
-
**Auto-fixable:** `wrong-syntax` — rewrite to the correct syntax for the target client.
|
|
306
|
-
|
|
307
|
-
### 2.6 mcp-urls — URL validation
|
|
308
|
-
|
|
309
|
-
Validates remote server URLs for correctness and team usability.
|
|
310
|
-
|
|
311
|
-
| Rule ID | Severity | Trigger | Message |
|
|
312
|
-
|---|---|---|---|
|
|
313
|
-
| `mcp-urls/malformed` | error | URL is not parseable (after skipping env var placeholders) | `Server "{name}": invalid URL` |
|
|
314
|
-
| `mcp-urls/localhost-in-project-config` | warning | `localhost` or `127.0.0.1` URL in a git-tracked project config | `Server "{name}": localhost URL in project config won't work for teammates` |
|
|
315
|
-
| `mcp-urls/missing-path` | info | URL has no path or just `/` | `Server "{name}": URL has no path — most MCP servers expect /mcp` |
|
|
316
|
-
|
|
317
|
-
**Notes:**
|
|
318
|
-
- If the URL contains env var references (`${...}`), skip `malformed` — it cannot be validated statically.
|
|
319
|
-
- `localhost-in-project-config` should only flag project-scoped files, not global configs where localhost is expected.
|
|
320
|
-
|
|
321
|
-
### 2.7 mcp-consistency — cross-file consistency
|
|
322
|
-
|
|
323
|
-
Compares MCP configs across multiple files in the same project. This is a cross-file check that runs after all individual configs are parsed.
|
|
324
|
-
|
|
325
|
-
| Rule ID | Severity | Trigger | Message |
|
|
326
|
-
|---|---|---|---|
|
|
327
|
-
| `mcp-consistency/same-server-different-config` | warning | Server with the same name exists in 2+ config files with different URLs or commands | `Server "{name}" is configured differently in {file1} and {file2}` |
|
|
328
|
-
| `mcp-consistency/duplicate-server-name` | warning | Same server name appears more than once in a single file | `Duplicate server name "{name}" in {file} — only the last definition is used` |
|
|
329
|
-
| `mcp-consistency/missing-from-client` | info | Server exists in `.mcp.json` but is absent from another client's project config that also exists | `Server "{name}" is in .mcp.json but missing from {file}` |
|
|
330
|
-
|
|
331
|
-
**Notes:**
|
|
332
|
-
- For `same-server-different-config`, compare `url`/`command`/`args`. Ignore `headers` differences (auth tokens intentionally differ per user).
|
|
333
|
-
- `missing-from-client` is informational only. Teams may intentionally have different server sets per client.
|
|
334
|
-
|
|
335
|
-
### 2.8 mcp-redundancy — unnecessary configs
|
|
336
|
-
|
|
337
|
-
Flags configs that may be unnecessary or stale.
|
|
338
|
-
|
|
339
|
-
| Rule ID | Severity | Trigger | Message |
|
|
340
|
-
|---|---|---|---|
|
|
341
|
-
| `mcp-redundancy/disabled-server` | info | Server has `"disabled": true` | `Server "{name}" is disabled — consider removing if no longer needed` |
|
|
342
|
-
| `mcp-redundancy/identical-across-scopes` | info | Same server with identical config at both project and global scope | `Server "{name}" is identically configured in {projectFile} and {globalFile}` |
|
|
343
|
-
|
|
344
|
-
---
|
|
345
|
-
|
|
346
|
-
## 3. Rule Catalog (machine-readable)
|
|
347
|
-
|
|
348
|
-
A machine-readable JSON catalog of all rules is available at [`mcp-config-lint-rules.json`](./mcp-config-lint-rules.json).
|
|
349
|
-
|
|
350
|
-
The catalog enables:
|
|
351
|
-
- AI agents to understand what rules exist and when they apply
|
|
352
|
-
- Tool authors to import rule definitions programmatically
|
|
353
|
-
- CI systems to configure which rules to enable/disable
|
|
354
|
-
- Documentation generators to stay in sync with the rule set
|
|
355
|
-
|
|
356
|
-
See the JSON file for the full schema.
|
|
357
|
-
|
|
358
|
-
---
|
|
359
|
-
|
|
360
|
-
## 4. Implementing This Specification
|
|
361
|
-
|
|
362
|
-
This specification is designed to be implementable by any tool. Here is how the pieces map to a typical linter architecture:
|
|
363
|
-
|
|
364
|
-
### Discovery
|
|
365
|
-
|
|
366
|
-
Scan for the project-level config files listed in [Section 1.3](#13-file-locations-by-client). Optionally scan global/user-level configs when the user opts in (these contain personal data and should not be scanned by default).
|
|
367
|
-
|
|
368
|
-
### Parsing
|
|
369
|
-
|
|
370
|
-
Parse JSON and normalize into a common structure regardless of which client's format the file uses. Key normalization steps:
|
|
371
|
-
1. Detect the client from the file path
|
|
372
|
-
2. Determine the expected root key (`servers` for VS Code, `mcpServers` for all others)
|
|
373
|
-
3. Infer transport type from fields: `command` present = stdio, `url` present = http/sse, explicit `type` field takes precedence
|
|
374
|
-
4. Extract server entries into a uniform shape
|
|
375
|
-
|
|
376
|
-
### Checking
|
|
377
|
-
|
|
378
|
-
Run per-file checks (schema, security, commands, deprecated, env, urls, redundancy) independently per config file. Run cross-file checks (consistency) after all files are parsed.
|
|
379
|
-
|
|
380
|
-
### Reporting
|
|
381
|
-
|
|
382
|
-
Rules use the `category/rule-id` naming convention (e.g., `mcp-security/hardcoded-bearer`). This maps cleanly to SARIF rule IDs for GitHub Code Scanning integration.
|
|
383
|
-
|
|
384
|
-
### Fixing
|
|
385
|
-
|
|
386
|
-
Rules marked as auto-fixable should apply surgical string replacements to the JSON file without reformatting the user's style (indentation, trailing commas, key ordering). Validate that the result is still valid JSON after applying fixes.
|
|
387
|
-
|
|
388
|
-
---
|
|
389
|
-
|
|
390
|
-
## 5. Contributing
|
|
391
|
-
|
|
392
|
-
This specification is maintained at [github.com/YawLabs/ctxlint](https://github.com/YawLabs/ctxlint).
|
|
393
|
-
|
|
394
|
-
To propose changes:
|
|
395
|
-
- **New rules:** Open an issue describing the rule, its severity, trigger condition, and which clients it applies to.
|
|
396
|
-
- **Client additions:** As new MCP clients emerge, submit a PR adding their config file location, root key, and any client-specific behaviors to Section 1.
|
|
397
|
-
- **Corrections:** If any client behavior documented here is inaccurate, open an issue with evidence (link to client docs, source code, or reproduction steps).
|
|
398
|
-
|
|
399
|
-
### Versioning
|
|
400
|
-
|
|
401
|
-
This specification follows semver:
|
|
402
|
-
- **Patch** (1.0.x): Typo fixes, clarifications, no rule changes
|
|
403
|
-
- **Minor** (1.x.0): New rules added, new clients documented
|
|
404
|
-
- **Major** (x.0.0): Rules removed or semantics changed in breaking ways
|
|
405
|
-
|
|
406
|
-
### Related specifications and tools
|
|
407
|
-
|
|
408
|
-
- [Model Context Protocol Specification](https://spec.modelcontextprotocol.io/) — the underlying protocol this config format serves
|
|
409
|
-
- [ctxlint](https://github.com/YawLabs/ctxlint) — reference implementation of this specification
|
|
410
|
-
- [mcp-compliance](https://github.com/YawLabs/mcp-compliance) — tests MCP server *behavior* against the protocol spec (complementary to config linting)
|
|
411
|
-
- [mcp.hosting](https://mcp.hosting) — managed MCP server hosting (eliminates many config issues by providing remote endpoints)
|
|
1
|
+
# MCP Server Configuration Linting Specification
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0.0-draft
|
|
4
|
+
**Date:** 2026-04-07
|
|
5
|
+
**MCP Spec Compatibility:** 2025-11-25 (Streamable HTTP)
|
|
6
|
+
**Maintained by:** [Yaw Labs](https://yaw.sh) / [ctxlint](https://github.com/YawLabs/ctxlint)
|
|
7
|
+
**License:** CC BY 4.0
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## What is this?
|
|
12
|
+
|
|
13
|
+
MCP server configuration files (`.mcp.json`, `.cursor/mcp.json`, `.vscode/mcp.json`, etc.) define which tools an AI agent can access. They are a context interface — alongside instruction files like `CLAUDE.md` and `.cursorrules`, they shape what an agent knows and can do.
|
|
14
|
+
|
|
15
|
+
This specification defines a standard set of lint rules for validating MCP server configurations across all major AI coding clients. It is tool-agnostic: any linter, IDE extension, CI check, or AI agent can implement these rules.
|
|
16
|
+
|
|
17
|
+
The specification includes:
|
|
18
|
+
- A complete reference of MCP config file locations, formats, and client-specific behaviors
|
|
19
|
+
- 43 lint rules organized into 8 categories with defined severities
|
|
20
|
+
- A machine-readable rule catalog ([`mcp-config-lint-rules.json`](./mcp-config-lint-rules.json))
|
|
21
|
+
- Auto-fix definitions for rules that support automated correction
|
|
22
|
+
|
|
23
|
+
**Reference implementation:** [ctxlint](https://github.com/YawLabs/ctxlint) (v0.4.0+)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Related specifications
|
|
28
|
+
|
|
29
|
+
This spec is part of a family of open specifications maintained by Yaw Labs for MCP tooling:
|
|
30
|
+
|
|
31
|
+
| Spec | Scope | Input |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| **mcp-config-lint** (this spec) | Static analysis of MCP client config files | `.cursor/mcp.json`, `.vscode/mcp.json`, `.mcp.json`, etc. |
|
|
34
|
+
| [**mcp-compliance**](https://github.com/YawLabs/mcp-compliance/blob/master/MCP_COMPLIANCE_SPEC.md) | Runtime testing of live MCP servers | A live server URL + transport |
|
|
35
|
+
|
|
36
|
+
The two are **complementary, not overlapping**. `mcp-config-lint` catches problems before deploy by reading JSON on disk; `mcp-compliance` catches problems after deploy by speaking the protocol to a running server. A production setup typically runs both.
|
|
37
|
+
|
|
38
|
+
Both specs target MCP spec version `2025-11-25` and ship machine-readable rule catalogs with stable rule IDs.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Table of contents
|
|
43
|
+
|
|
44
|
+
- [1. MCP Config Landscape Reference](#1-mcp-config-landscape-reference)
|
|
45
|
+
- [1.1 Config format](#11-config-format)
|
|
46
|
+
- [1.2 Server entry fields](#12-server-entry-fields)
|
|
47
|
+
- [1.3 File locations by client](#13-file-locations-by-client)
|
|
48
|
+
- [1.4 Environment variable syntax](#14-environment-variable-syntax)
|
|
49
|
+
- [1.5 Override precedence](#15-override-precedence)
|
|
50
|
+
- [1.6 Platform-specific behaviors](#16-platform-specific-behaviors)
|
|
51
|
+
- [2. Lint Rules](#2-lint-rules)
|
|
52
|
+
- [2.1 mcp-schema — structural validation](#21-mcp-schema--structural-validation)
|
|
53
|
+
- [2.2 mcp-security — hardcoded secrets](#22-mcp-security--hardcoded-secrets)
|
|
54
|
+
- [2.3 mcp-commands — stdio command validation](#23-mcp-commands--stdio-command-validation)
|
|
55
|
+
- [2.4 mcp-deprecated — deprecated patterns](#24-mcp-deprecated--deprecated-patterns)
|
|
56
|
+
- [2.5 mcp-env — environment variable validation](#25-mcp-env--environment-variable-validation)
|
|
57
|
+
- [2.6 mcp-urls — URL validation](#26-mcp-urls--url-validation)
|
|
58
|
+
- [2.7 mcp-consistency — cross-file consistency](#27-mcp-consistency--cross-file-consistency)
|
|
59
|
+
- [2.8 mcp-redundancy — unnecessary configs](#28-mcp-redundancy--unnecessary-configs)
|
|
60
|
+
- [3. Rule Catalog (machine-readable)](#3-rule-catalog-machine-readable)
|
|
61
|
+
- [4. Implementing This Specification](#4-implementing-this-specification)
|
|
62
|
+
- [5. Contributing](#5-contributing)
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 1. MCP Config Landscape Reference
|
|
67
|
+
|
|
68
|
+
This section documents the full MCP server configuration landscape as of April 2026. Implementors should treat this as the authoritative cross-client reference for file locations, formats, and behaviors.
|
|
69
|
+
|
|
70
|
+
### 1.1 Config format
|
|
71
|
+
|
|
72
|
+
Every MCP config file is a JSON object with a root key containing named server entries. Each server entry describes how the client connects to one MCP server.
|
|
73
|
+
|
|
74
|
+
There are two active transport types:
|
|
75
|
+
|
|
76
|
+
**stdio** — the client launches a local subprocess and communicates over stdin/stdout using JSON-RPC:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"my-server": {
|
|
82
|
+
"command": "npx",
|
|
83
|
+
"args": ["-y", "@example/mcp-server"],
|
|
84
|
+
"env": { "DEBUG": "true" }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Streamable HTTP** — the client connects to a remote URL over HTTP:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"my-server": {
|
|
96
|
+
"type": "http",
|
|
97
|
+
"url": "https://my-server.example.com/mcp",
|
|
98
|
+
"headers": {
|
|
99
|
+
"Authorization": "Bearer ${API_KEY}"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**SSE (Server-Sent Events)** — deprecated as of the March 2025 MCP spec update. Uses `"type": "sse"`. Still supported by most clients but should be migrated to Streamable HTTP.
|
|
107
|
+
|
|
108
|
+
### 1.2 Server entry fields
|
|
109
|
+
|
|
110
|
+
| Field | Type | Transport | Required | Description |
|
|
111
|
+
|---|---|---|---|---|
|
|
112
|
+
| `type` | `"stdio"` \| `"http"` \| `"sse"` | All | No | Transport protocol. Defaults to `stdio` if `command` is present. |
|
|
113
|
+
| `command` | string | stdio | Yes | Executable to launch as a subprocess. |
|
|
114
|
+
| `args` | string[] | stdio | No | Arguments passed to the command. |
|
|
115
|
+
| `env` | Record<string, string> | stdio | No | Environment variables for the subprocess. |
|
|
116
|
+
| `url` | string | http, sse | Yes | Remote endpoint URL. |
|
|
117
|
+
| `headers` | Record<string, string> | http, sse | No | HTTP headers sent with every request. |
|
|
118
|
+
| `disabled` | boolean | All | No | Whether the server is disabled. (Cline-specific) |
|
|
119
|
+
| `autoApprove` | string[] | All | No | Tool names to auto-approve without user confirmation. (Cline-specific) |
|
|
120
|
+
| `timeout` | number (ms) | All | No | Max response wait time. Default: 60000. (Amazon Q-specific) |
|
|
121
|
+
| `oauth` | object | http | No | OAuth 2.0 configuration. (Claude Code-specific) |
|
|
122
|
+
| `headersHelper` | string | http | No | Shell command that outputs JSON headers to stdout. (Claude Code-specific) |
|
|
123
|
+
|
|
124
|
+
### 1.3 File locations by client
|
|
125
|
+
|
|
126
|
+
#### Project-level configs
|
|
127
|
+
|
|
128
|
+
These live relative to the project root and are typically committed to version control.
|
|
129
|
+
|
|
130
|
+
| File path | Client | Root key | Notes |
|
|
131
|
+
|---|---|---|---|
|
|
132
|
+
| `.mcp.json` | Claude Code | `mcpServers` | The universal project-level convention. |
|
|
133
|
+
| `.cursor/mcp.json` | Cursor | `mcpServers` | |
|
|
134
|
+
| `.vscode/mcp.json` | VS Code / GitHub Copilot | **`servers`** | Only client that uses `servers` instead of `mcpServers`. |
|
|
135
|
+
| `.amazonq/mcp.json` | Amazon Q Developer | `mcpServers` | Server names must be unique across project + global. |
|
|
136
|
+
| `.continue/mcpServers/*.json` | Continue.dev | varies | Accepts config files from any client format. |
|
|
137
|
+
|
|
138
|
+
#### User/global-level configs
|
|
139
|
+
|
|
140
|
+
These are user-specific and not committed to version control.
|
|
141
|
+
|
|
142
|
+
| File path | Client | Root key | Platform |
|
|
143
|
+
|---|---|---|---|
|
|
144
|
+
| `~/.claude.json` | Claude Code | `mcpServers` | All |
|
|
145
|
+
| `~/.claude/settings.json` | Claude Code | `mcpServers` | All |
|
|
146
|
+
| `~/.cursor/mcp.json` | Cursor | `mcpServers` | All |
|
|
147
|
+
| `~/Library/Application Support/Claude/claude_desktop_config.json` | Claude Desktop | `mcpServers` | macOS |
|
|
148
|
+
| `%APPDATA%\Claude\claude_desktop_config.json` | Claude Desktop | `mcpServers` | Windows |
|
|
149
|
+
| `~/.codeium/windsurf/mcp_config.json` | Windsurf | `mcpServers` | All |
|
|
150
|
+
| `~/.aws/amazonq/mcp.json` | Amazon Q | `mcpServers` | All |
|
|
151
|
+
| VS Code globalStorage `saoudrizwan.claude-dev/settings/cline_mcp_settings.json` | Cline | `mcpServers` | All |
|
|
152
|
+
|
|
153
|
+
### 1.4 Environment variable syntax
|
|
154
|
+
|
|
155
|
+
Different clients use different syntax for referencing environment variables in config values.
|
|
156
|
+
|
|
157
|
+
| Client | Syntax | Default value support | Example |
|
|
158
|
+
|---|---|---|---|
|
|
159
|
+
| Claude Code | `${VAR}` | `${VAR:-default}` | `${API_KEY}` |
|
|
160
|
+
| Cursor | `${env:VAR}` | No | `${env:API_KEY}` |
|
|
161
|
+
| Continue.dev | `${{ secrets.VAR }}` | No | `${{ secrets.API_KEY }}` |
|
|
162
|
+
| Windsurf | `${env:VAR}` | No | `${env:API_KEY}` |
|
|
163
|
+
| Claude Desktop | Not supported | N/A | Literal values only |
|
|
164
|
+
| Amazon Q | Not supported | N/A | Literal values only |
|
|
165
|
+
|
|
166
|
+
Env var expansion applies to `command`, `args`, `env`, `url`, and `headers` fields (where supported).
|
|
167
|
+
|
|
168
|
+
### 1.5 Override precedence
|
|
169
|
+
|
|
170
|
+
When the same server name exists at multiple scopes, the most specific scope wins.
|
|
171
|
+
|
|
172
|
+
**Claude Code** (three-tier):
|
|
173
|
+
1. **Local** (highest) — per-user, per-project overrides in `~/.claude.json` under a project path key
|
|
174
|
+
2. **Project** — `.mcp.json` at the repo root
|
|
175
|
+
3. **User** (lowest) — `~/.claude.json` top-level `mcpServers`
|
|
176
|
+
|
|
177
|
+
**Cursor:** project `.cursor/mcp.json` overrides global `~/.cursor/mcp.json`.
|
|
178
|
+
|
|
179
|
+
**Amazon Q:** workspace `.amazonq/mcp.json` overrides global `~/.aws/amazonq/mcp.json`. Server names must be unique across both.
|
|
180
|
+
|
|
181
|
+
**VS Code:** workspace `.vscode/mcp.json` overrides user-level configuration.
|
|
182
|
+
|
|
183
|
+
**Windsurf, Cline:** Single global config. No override behavior.
|
|
184
|
+
|
|
185
|
+
### 1.6 Platform-specific behaviors
|
|
186
|
+
|
|
187
|
+
**Windows + npx (stdio):** On native Windows (not WSL), `npx` commands must be wrapped with `cmd /c`:
|
|
188
|
+
```json
|
|
189
|
+
{
|
|
190
|
+
"command": "cmd",
|
|
191
|
+
"args": ["/c", "npx", "-y", "@example/mcp-server"]
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
Without this wrapper, the subprocess fails to spawn. This is the most common Windows MCP config issue.
|
|
195
|
+
|
|
196
|
+
**Claude.ai custom connectors:** Only support remote MCP servers over Streamable HTTP. No stdio support — browsers cannot launch local subprocesses. stdio-only servers must be hosted remotely to be used with Claude.ai.
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 2. Lint Rules
|
|
201
|
+
|
|
202
|
+
27 rules organized into 8 categories. Each rule has a unique ID, severity level, trigger condition, and message template.
|
|
203
|
+
|
|
204
|
+
Severity levels:
|
|
205
|
+
- **error** — the config is broken or has a security issue. Should fail CI.
|
|
206
|
+
- **warning** — the config has a likely problem. May or may not fail CI depending on strictness.
|
|
207
|
+
- **info** — the config has a potential improvement. Never fails CI.
|
|
208
|
+
|
|
209
|
+
### 2.1 mcp-schema — structural validation
|
|
210
|
+
|
|
211
|
+
Validates that the config file is well-formed JSON with the correct structure for its target client.
|
|
212
|
+
|
|
213
|
+
| Rule ID | Severity | Trigger | Message |
|
|
214
|
+
|---|---|---|---|
|
|
215
|
+
| `mcp-schema/invalid-json` | error | File is not valid JSON | `MCP config is not valid JSON: {parseError}` |
|
|
216
|
+
| `mcp-schema/wrong-root-key` | error | Root key doesn't match expected key for the client | `{file} must use "{expected}" as root key, not "{actual}"` |
|
|
217
|
+
| `mcp-schema/missing-root-key` | error | No recognized root key (`mcpServers` or `servers`) | `MCP config has no "{expected}" key` |
|
|
218
|
+
| `mcp-schema/missing-command` | error | stdio server has no `command` field | `Server "{name}": missing "command" field` |
|
|
219
|
+
| `mcp-schema/missing-url` | error | http/sse server has no `url` field | `Server "{name}": missing "url" field` |
|
|
220
|
+
| `mcp-schema/unknown-transport` | warning | `type` field is not `stdio`, `http`, or `sse` | `Server "{name}": unknown transport type "{type}"` |
|
|
221
|
+
| `mcp-schema/ambiguous-transport` | warning | Server has both `command` and `url` fields | `Server "{name}": has both "command" and "url" — transport is ambiguous` |
|
|
222
|
+
| `mcp-schema/empty-servers` | info | Root key exists but contains no server entries | `MCP config has no server entries` |
|
|
223
|
+
|
|
224
|
+
**Auto-fixable:** `wrong-root-key` — rename the root key to match the expected key.
|
|
225
|
+
|
|
226
|
+
### 2.2 mcp-security — hardcoded secrets
|
|
227
|
+
|
|
228
|
+
Detects secrets committed to version control in MCP config files. Only flags issues in git-tracked files.
|
|
229
|
+
|
|
230
|
+
| Rule ID | Severity | Trigger | Message |
|
|
231
|
+
|---|---|---|---|
|
|
232
|
+
| `mcp-security/hardcoded-bearer` | error | `Authorization` header contains a literal Bearer token (not an env var reference) in a git-tracked file | `Server "{name}": hardcoded Bearer token in a git-tracked file` |
|
|
233
|
+
| `mcp-security/hardcoded-api-key` | error | Header or env value matches known API key patterns in a git-tracked file | `Server "{name}": possible API key in a git-tracked file` |
|
|
234
|
+
| `mcp-security/secret-in-url` | error | URL contains query params that look like secrets (`?key=`, `?token=`, `?api_key=`) in a git-tracked file | `Server "{name}": possible secret in URL query string` |
|
|
235
|
+
| `mcp-security/http-no-tls` | warning | URL uses `http://` for non-localhost target | `Server "{name}": URL uses HTTP without TLS` |
|
|
236
|
+
|
|
237
|
+
**Known API key patterns:**
|
|
238
|
+
```
|
|
239
|
+
sk-[a-zA-Z0-9]{20,} # OpenAI / generic
|
|
240
|
+
ghp_[a-zA-Z0-9]{36} # GitHub personal access token
|
|
241
|
+
ghu_[a-zA-Z0-9]{36} # GitHub user token
|
|
242
|
+
github_pat_[a-zA-Z0-9_]{80,} # GitHub fine-grained PAT
|
|
243
|
+
xoxb-[0-9]{10,} # Slack bot token
|
|
244
|
+
xoxp-[0-9]{10,} # Slack user token
|
|
245
|
+
AKIA[0-9A-Z]{16} # AWS access key ID
|
|
246
|
+
glpat-[a-zA-Z0-9_\-]{20} # GitLab personal access token
|
|
247
|
+
sq0atp-[a-zA-Z0-9_\-]{22} # Square access token
|
|
248
|
+
shpat_[a-fA-F0-9]{32} # Shopify admin API token
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Also flag any string value > 20 characters that is entirely alphanumeric or base64 characters AND is not an env var reference (`${...}`, `${{ ... }}`).
|
|
252
|
+
|
|
253
|
+
**Auto-fixable:** `hardcoded-bearer`, `hardcoded-api-key` — replace literal value with an env var reference derived from the server name (e.g., `MY_SERVER_API_KEY`).
|
|
254
|
+
|
|
255
|
+
### 2.3 mcp-commands — stdio command validation
|
|
256
|
+
|
|
257
|
+
Validates that stdio server commands and file-path arguments are viable.
|
|
258
|
+
|
|
259
|
+
| Rule ID | Severity | Trigger | Message |
|
|
260
|
+
|---|---|---|---|
|
|
261
|
+
| `mcp-commands/windows-npx-no-wrapper` | error | Platform is Windows and `command` is `npx` without `cmd /c` wrapper | `Server "{name}": npx requires "cmd /c" wrapper on Windows` |
|
|
262
|
+
| `mcp-commands/command-not-found` | warning | `command` is a relative path (`./`, `../`) that doesn't exist | `Server "{name}": command "{command}" not found` |
|
|
263
|
+
| `mcp-commands/args-path-missing` | warning | An arg matches a file path pattern and the file doesn't exist | `Server "{name}": arg "{arg}" references a missing file` |
|
|
264
|
+
|
|
265
|
+
**Notes:**
|
|
266
|
+
- `windows-npx-no-wrapper` should only flag project-level configs, not global configs (the user may be developing cross-platform).
|
|
267
|
+
- `args-path-missing` should only check args that look like file paths (contain `/` with a file extension, or start with `./` / `../`). Skip npm package names and flags.
|
|
268
|
+
- Do not validate that system commands (`npx`, `node`, `python`) exist on PATH — that is a runtime concern, not a config concern.
|
|
269
|
+
|
|
270
|
+
**Auto-fixable:** `windows-npx-no-wrapper` — rewrite `{"command": "npx", "args": [...]}` to `{"command": "cmd", "args": ["/c", "npx", ...]}`.
|
|
271
|
+
|
|
272
|
+
### 2.4 mcp-deprecated — deprecated patterns
|
|
273
|
+
|
|
274
|
+
Flags usage of deprecated MCP transport protocols and patterns.
|
|
275
|
+
|
|
276
|
+
| Rule ID | Severity | Trigger | Message |
|
|
277
|
+
|---|---|---|---|
|
|
278
|
+
| `mcp-deprecated/sse-transport` | warning | Server uses `"type": "sse"` | `Server "{name}": SSE transport is deprecated — use "http" (Streamable HTTP)` |
|
|
279
|
+
|
|
280
|
+
**Auto-fixable:** `sse-transport` — replace `"sse"` with `"http"`.
|
|
281
|
+
|
|
282
|
+
### 2.5 mcp-env — environment variable validation
|
|
283
|
+
|
|
284
|
+
Validates environment variable references for correctness and client compatibility.
|
|
285
|
+
|
|
286
|
+
| Rule ID | Severity | Trigger | Message |
|
|
287
|
+
|---|---|---|---|
|
|
288
|
+
| `mcp-env/wrong-syntax` | error | Env var reference uses wrong syntax for the target client | `Server "{name}": {client} uses {expected}, not {actual}` |
|
|
289
|
+
| `mcp-env/unset-variable` | info | Referenced env var is not set in the current environment | `Server "{name}": environment variable "{var}" is not set` |
|
|
290
|
+
| `mcp-env/empty-env-block` | info | `env` object is present but empty | `Server "{name}": empty "env" block can be removed` |
|
|
291
|
+
|
|
292
|
+
**Syntax validation matrix:**
|
|
293
|
+
|
|
294
|
+
| Config file | Expected syntax | Flag if found |
|
|
295
|
+
|---|---|---|
|
|
296
|
+
| `.mcp.json` | `${VAR}` | `${env:VAR}` |
|
|
297
|
+
| `.cursor/mcp.json` | `${env:VAR}` | `${VAR}` (bare, without `env:`) |
|
|
298
|
+
| `.continue/mcpServers/*.json` | `${{ secrets.VAR }}` | `${VAR}` or `${env:VAR}` |
|
|
299
|
+
| All others | `${VAR}` | — |
|
|
300
|
+
|
|
301
|
+
**Notes:**
|
|
302
|
+
- `unset-variable` is intentionally `info` severity. Many env vars are set only in CI, `.env` files, or shell profiles that aren't available during linting.
|
|
303
|
+
- Scan all string values in `command`, `args`, `url`, `headers`, and `env` for env var references.
|
|
304
|
+
|
|
305
|
+
**Auto-fixable:** `wrong-syntax` — rewrite to the correct syntax for the target client.
|
|
306
|
+
|
|
307
|
+
### 2.6 mcp-urls — URL validation
|
|
308
|
+
|
|
309
|
+
Validates remote server URLs for correctness and team usability.
|
|
310
|
+
|
|
311
|
+
| Rule ID | Severity | Trigger | Message |
|
|
312
|
+
|---|---|---|---|
|
|
313
|
+
| `mcp-urls/malformed` | error | URL is not parseable (after skipping env var placeholders) | `Server "{name}": invalid URL` |
|
|
314
|
+
| `mcp-urls/localhost-in-project-config` | warning | `localhost` or `127.0.0.1` URL in a git-tracked project config | `Server "{name}": localhost URL in project config won't work for teammates` |
|
|
315
|
+
| `mcp-urls/missing-path` | info | URL has no path or just `/` | `Server "{name}": URL has no path — most MCP servers expect /mcp` |
|
|
316
|
+
|
|
317
|
+
**Notes:**
|
|
318
|
+
- If the URL contains env var references (`${...}`), skip `malformed` — it cannot be validated statically.
|
|
319
|
+
- `localhost-in-project-config` should only flag project-scoped files, not global configs where localhost is expected.
|
|
320
|
+
|
|
321
|
+
### 2.7 mcp-consistency — cross-file consistency
|
|
322
|
+
|
|
323
|
+
Compares MCP configs across multiple files in the same project. This is a cross-file check that runs after all individual configs are parsed.
|
|
324
|
+
|
|
325
|
+
| Rule ID | Severity | Trigger | Message |
|
|
326
|
+
|---|---|---|---|
|
|
327
|
+
| `mcp-consistency/same-server-different-config` | warning | Server with the same name exists in 2+ config files with different URLs or commands | `Server "{name}" is configured differently in {file1} and {file2}` |
|
|
328
|
+
| `mcp-consistency/duplicate-server-name` | warning | Same server name appears more than once in a single file | `Duplicate server name "{name}" in {file} — only the last definition is used` |
|
|
329
|
+
| `mcp-consistency/missing-from-client` | info | Server exists in `.mcp.json` but is absent from another client's project config that also exists | `Server "{name}" is in .mcp.json but missing from {file}` |
|
|
330
|
+
|
|
331
|
+
**Notes:**
|
|
332
|
+
- For `same-server-different-config`, compare `url`/`command`/`args`. Ignore `headers` differences (auth tokens intentionally differ per user).
|
|
333
|
+
- `missing-from-client` is informational only. Teams may intentionally have different server sets per client.
|
|
334
|
+
|
|
335
|
+
### 2.8 mcp-redundancy — unnecessary configs
|
|
336
|
+
|
|
337
|
+
Flags configs that may be unnecessary or stale.
|
|
338
|
+
|
|
339
|
+
| Rule ID | Severity | Trigger | Message |
|
|
340
|
+
|---|---|---|---|
|
|
341
|
+
| `mcp-redundancy/disabled-server` | info | Server has `"disabled": true` | `Server "{name}" is disabled — consider removing if no longer needed` |
|
|
342
|
+
| `mcp-redundancy/identical-across-scopes` | info | Same server with identical config at both project and global scope | `Server "{name}" is identically configured in {projectFile} and {globalFile}` |
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## 3. Rule Catalog (machine-readable)
|
|
347
|
+
|
|
348
|
+
A machine-readable JSON catalog of all rules is available at [`mcp-config-lint-rules.json`](./mcp-config-lint-rules.json).
|
|
349
|
+
|
|
350
|
+
The catalog enables:
|
|
351
|
+
- AI agents to understand what rules exist and when they apply
|
|
352
|
+
- Tool authors to import rule definitions programmatically
|
|
353
|
+
- CI systems to configure which rules to enable/disable
|
|
354
|
+
- Documentation generators to stay in sync with the rule set
|
|
355
|
+
|
|
356
|
+
See the JSON file for the full schema.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## 4. Implementing This Specification
|
|
361
|
+
|
|
362
|
+
This specification is designed to be implementable by any tool. Here is how the pieces map to a typical linter architecture:
|
|
363
|
+
|
|
364
|
+
### Discovery
|
|
365
|
+
|
|
366
|
+
Scan for the project-level config files listed in [Section 1.3](#13-file-locations-by-client). Optionally scan global/user-level configs when the user opts in (these contain personal data and should not be scanned by default).
|
|
367
|
+
|
|
368
|
+
### Parsing
|
|
369
|
+
|
|
370
|
+
Parse JSON and normalize into a common structure regardless of which client's format the file uses. Key normalization steps:
|
|
371
|
+
1. Detect the client from the file path
|
|
372
|
+
2. Determine the expected root key (`servers` for VS Code, `mcpServers` for all others)
|
|
373
|
+
3. Infer transport type from fields: `command` present = stdio, `url` present = http/sse, explicit `type` field takes precedence
|
|
374
|
+
4. Extract server entries into a uniform shape
|
|
375
|
+
|
|
376
|
+
### Checking
|
|
377
|
+
|
|
378
|
+
Run per-file checks (schema, security, commands, deprecated, env, urls, redundancy) independently per config file. Run cross-file checks (consistency) after all files are parsed.
|
|
379
|
+
|
|
380
|
+
### Reporting
|
|
381
|
+
|
|
382
|
+
Rules use the `category/rule-id` naming convention (e.g., `mcp-security/hardcoded-bearer`). This maps cleanly to SARIF rule IDs for GitHub Code Scanning integration.
|
|
383
|
+
|
|
384
|
+
### Fixing
|
|
385
|
+
|
|
386
|
+
Rules marked as auto-fixable should apply surgical string replacements to the JSON file without reformatting the user's style (indentation, trailing commas, key ordering). Validate that the result is still valid JSON after applying fixes.
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 5. Contributing
|
|
391
|
+
|
|
392
|
+
This specification is maintained at [github.com/YawLabs/ctxlint](https://github.com/YawLabs/ctxlint).
|
|
393
|
+
|
|
394
|
+
To propose changes:
|
|
395
|
+
- **New rules:** Open an issue describing the rule, its severity, trigger condition, and which clients it applies to.
|
|
396
|
+
- **Client additions:** As new MCP clients emerge, submit a PR adding their config file location, root key, and any client-specific behaviors to Section 1.
|
|
397
|
+
- **Corrections:** If any client behavior documented here is inaccurate, open an issue with evidence (link to client docs, source code, or reproduction steps).
|
|
398
|
+
|
|
399
|
+
### Versioning
|
|
400
|
+
|
|
401
|
+
This specification follows semver:
|
|
402
|
+
- **Patch** (1.0.x): Typo fixes, clarifications, no rule changes
|
|
403
|
+
- **Minor** (1.x.0): New rules added, new clients documented
|
|
404
|
+
- **Major** (x.0.0): Rules removed or semantics changed in breaking ways
|
|
405
|
+
|
|
406
|
+
### Related specifications and tools
|
|
407
|
+
|
|
408
|
+
- [Model Context Protocol Specification](https://spec.modelcontextprotocol.io/) — the underlying protocol this config format serves
|
|
409
|
+
- [ctxlint](https://github.com/YawLabs/ctxlint) — reference implementation of this specification
|
|
410
|
+
- [mcp-compliance](https://github.com/YawLabs/mcp-compliance) — tests MCP server *behavior* against the protocol spec (complementary to config linting)
|
|
411
|
+
- [mcp.hosting](https://mcp.hosting) — managed MCP server hosting (eliminates many config issues by providing remote endpoints)
|