@cyanheads/browser-compat-mcp-server 0.2.1 → 0.3.1
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/AGENTS.md +22 -9
- package/CLAUDE.md +22 -9
- package/Dockerfile +7 -3
- package/README.md +34 -43
- package/THIRD_PARTY_NOTICES.md +5 -6
- package/changelog/0.3.x/0.3.0.md +39 -0
- package/changelog/0.3.x/0.3.1.md +36 -0
- package/changelog/template.md +10 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts +2 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js +35 -11
- package/dist/mcp-server/tools/definitions/browsercompat-check-baseline.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.d.ts +2 -2
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.js +61 -48
- package/dist/mcp-server/tools/definitions/browsercompat-compare-support.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-list-reference.tool.js +3 -3
- package/dist/mcp-server/tools/definitions/browsercompat-list-reference.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js +6 -14
- package/dist/mcp-server/tools/definitions/browsercompat-search-features.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.js +1 -1
- package/dist/mcp-server/tools/definitions/compat-shapes.js.map +1 -1
- package/dist/services/bcd/bcd-service.d.ts +9 -4
- package/dist/services/bcd/bcd-service.d.ts.map +1 -1
- package/dist/services/bcd/bcd-service.js +23 -7
- package/dist/services/bcd/bcd-service.js.map +1 -1
- package/dist/services/targets/targets-service.d.ts +27 -13
- package/dist/services/targets/targets-service.d.ts.map +1 -1
- package/dist/services/targets/targets-service.js +66 -21
- package/dist/services/targets/targets-service.js.map +1 -1
- package/dist/services/targets/types.d.ts +23 -6
- package/dist/services/targets/types.d.ts.map +1 -1
- package/package.json +15 -14
- package/server.json +3 -3
- package/skills/browser-compat-guide/SKILL.md +48 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Targets service — resolves browserslist queries to tokens, maps
|
|
3
3
|
* caniuse agents onto BCD browsers, and supplies the caniuse-derived usage
|
|
4
|
-
* figures: per-agent totals, query coverage, and the
|
|
4
|
+
* figures: per-agent totals, query coverage, and the global traffic share a
|
|
5
5
|
* feature would exclude.
|
|
6
6
|
* @module services/targets/targets-service
|
|
7
7
|
*/
|
|
8
8
|
import { validationError } from '@cyanheads/mcp-ts-core/errors';
|
|
9
|
+
import { agents as bundledAgents } from 'caniuse-lite';
|
|
9
10
|
import { bcdBrowserForAgent } from '../../data/browserslist-bcd-map.js';
|
|
10
11
|
import { getBcdService } from '../bcd/bcd-service.js';
|
|
11
12
|
/**
|
|
12
13
|
* Share of global traffic caniuse tracks: `usage_global` summed across every
|
|
13
|
-
* agent of the bundled caniuse-lite, to one decimal
|
|
14
|
-
* bundled data, so a caniuse-lite bump that moves the figure fails until this
|
|
15
|
-
* is updated.
|
|
14
|
+
* agent of the bundled caniuse-lite, to one decimal, derived on dataset load.
|
|
16
15
|
*/
|
|
17
|
-
export const CANIUSE_TRACKED_PERCENT =
|
|
16
|
+
export const CANIUSE_TRACKED_PERCENT = Number(Object.values(bundledAgents)
|
|
17
|
+
.reduce((sum, agent) => sum + Object.values(agent?.usage_global ?? {}).reduce((total, usage) => total + usage, 0), 0)
|
|
18
|
+
.toFixed(1));
|
|
18
19
|
/**
|
|
19
20
|
* CC BY 4.0 attribution carried on every response that quotes a usage figure,
|
|
20
|
-
* used verbatim.
|
|
21
|
-
* rather than of all traffic.
|
|
21
|
+
* used verbatim. Raw usage_global values are percentage points of global traffic.
|
|
22
22
|
*/
|
|
23
|
-
export const CANIUSE_ATTRIBUTION = `Usage data from caniuse.com, © Can I Use contributors, CC BY 4.0. Figures are
|
|
23
|
+
export const CANIUSE_ATTRIBUTION = `Usage data from caniuse.com, © Can I Use contributors, CC BY 4.0. Figures are percentage points of global traffic. The bundled data tracks ~${CANIUSE_TRACKED_PERCENT}% of global traffic; the remainder is untracked and unknown.`;
|
|
24
24
|
/** Round a percentage to a stable precision so repeated calls agree byte for byte. */
|
|
25
25
|
function percent(value) {
|
|
26
26
|
return Number(value.toFixed(4));
|
|
@@ -29,6 +29,19 @@ function percent(value) {
|
|
|
29
29
|
function isBrowserslistError(error) {
|
|
30
30
|
return (error instanceof Error && error.browserslist === true);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* How one caniuse stat answers "does it work by default?". Stats lead with the
|
|
34
|
+
* support letter, then flags (`x` prefix required, `d` disabled by default),
|
|
35
|
+
* then `#n` note markers, which do not affect support.
|
|
36
|
+
*/
|
|
37
|
+
function statSupport(stat) {
|
|
38
|
+
if (stat === undefined)
|
|
39
|
+
return 'none';
|
|
40
|
+
const [letter, ...flags] = stat.split(' ');
|
|
41
|
+
if (letter !== 'y' || flags.includes('d'))
|
|
42
|
+
return 'none';
|
|
43
|
+
return flags.includes('x') ? 'prefixed' : 'default';
|
|
44
|
+
}
|
|
32
45
|
/** Query resolution and usage weighting over browserslist plus caniuse-lite. */
|
|
33
46
|
export class TargetsService {
|
|
34
47
|
agents;
|
|
@@ -47,7 +60,7 @@ export class TargetsService {
|
|
|
47
60
|
agentIds() {
|
|
48
61
|
return Object.keys(this.agents);
|
|
49
62
|
}
|
|
50
|
-
/**
|
|
63
|
+
/** Percentage points of global traffic attributed to one agent across all its versions. */
|
|
51
64
|
agentUsageTotal(agentId) {
|
|
52
65
|
const cached = this.usageTotals.get(agentId);
|
|
53
66
|
if (cached !== undefined)
|
|
@@ -79,6 +92,14 @@ export class TargetsService {
|
|
|
79
92
|
*/
|
|
80
93
|
queryTokens(query) {
|
|
81
94
|
try {
|
|
95
|
+
for (const node of this.browserslist.parse(query, { path: false })) {
|
|
96
|
+
if (node.type === 'extends' ||
|
|
97
|
+
node.type === 'popularity_in_config_stats' ||
|
|
98
|
+
node.type === 'cover_config' ||
|
|
99
|
+
node.type === 'browserslist_config') {
|
|
100
|
+
throw validationError('Config packages and custom configuration are unsupported. Use a self-contained browserslist query.', { reason: 'invalid_target_query' });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
82
103
|
return this.browserslist(query, { path: false });
|
|
83
104
|
}
|
|
84
105
|
catch (error) {
|
|
@@ -95,7 +116,10 @@ export class TargetsService {
|
|
|
95
116
|
}
|
|
96
117
|
/**
|
|
97
118
|
* Split browserslist tokens into targets that map onto a concrete BCD release
|
|
98
|
-
* and targets the server declines to evaluate, with the reason for each.
|
|
119
|
+
* and targets the server declines to evaluate, with the reason for each. A
|
|
120
|
+
* grouped token such as `ios_saf 15.0-15.1` maps each endpoint as a single
|
|
121
|
+
* token would, and spans every BCD release from the lower one's through the
|
|
122
|
+
* upper one's.
|
|
99
123
|
*/
|
|
100
124
|
async resolveTargets(tokens) {
|
|
101
125
|
const bcd = await getBcdService();
|
|
@@ -116,7 +140,9 @@ export class TargetsService {
|
|
|
116
140
|
continue;
|
|
117
141
|
}
|
|
118
142
|
const version = bcd.resolveTargetVersion(bcdBrowser, versionToken);
|
|
119
|
-
|
|
143
|
+
const dash = versionToken.indexOf('-');
|
|
144
|
+
const upper = dash > 0 ? bcd.resolveTargetVersion(bcdBrowser, versionToken.slice(dash + 1)) : version;
|
|
145
|
+
if (!version.resolved || !upper.resolved) {
|
|
120
146
|
unchecked.push({
|
|
121
147
|
agent,
|
|
122
148
|
version_token: versionToken,
|
|
@@ -125,43 +151,62 @@ export class TargetsService {
|
|
|
125
151
|
});
|
|
126
152
|
continue;
|
|
127
153
|
}
|
|
154
|
+
const later = bcd
|
|
155
|
+
.releasesBetween(bcdBrowser, version.index, upper.index)
|
|
156
|
+
.map((release) => ({ index: release.index, version: release.version }));
|
|
128
157
|
resolved.push({
|
|
129
158
|
agent,
|
|
130
159
|
version_token: versionToken,
|
|
131
160
|
bcd_browser: bcdBrowser,
|
|
132
161
|
bcd_version: version.version,
|
|
133
162
|
bcd_release_index: version.index,
|
|
163
|
+
span: [{ index: version.index, version: version.version }, ...later],
|
|
134
164
|
});
|
|
135
165
|
}
|
|
136
166
|
return { resolved, unchecked };
|
|
137
167
|
}
|
|
138
168
|
/**
|
|
139
|
-
*
|
|
140
|
-
* every agent/version pair
|
|
169
|
+
* Percentage points of global traffic that requiring a feature would exclude:
|
|
170
|
+
* every agent/version pair where some mapped caniuse stat is not `y`, or
|
|
171
|
+
* carries `x` (prefix required) or `d` (disabled by default). Partial,
|
|
172
|
+
* polyfilled, unknown, and missing stats all exclude. `prefixedPercent` is
|
|
173
|
+
* the excluded share where every stat is `y` without `d` and at least one
|
|
174
|
+
* needs the prefix. `spelledWithPrefix` marks a feature whose own name carries
|
|
175
|
+
* the prefix, so `x` describes it as written and counts as supported. Returns
|
|
141
176
|
* `undefined` when the feature reaches no caniuse id — never zero.
|
|
142
177
|
*/
|
|
143
|
-
excludedUsage(caniuseIds) {
|
|
178
|
+
excludedUsage(caniuseIds, { spelledWithPrefix = false } = {}) {
|
|
144
179
|
const features = caniuseIds
|
|
145
180
|
.map((id) => this.caniuseFeature(id))
|
|
146
181
|
.filter((feature) => feature !== undefined);
|
|
147
182
|
if (features.length === 0)
|
|
148
183
|
return undefined;
|
|
149
184
|
let excluded = 0;
|
|
185
|
+
let prefixed = 0;
|
|
150
186
|
for (const [agentId, agent] of Object.entries(this.agents)) {
|
|
151
187
|
if (!agent)
|
|
152
188
|
continue;
|
|
153
189
|
for (const [version, usage] of Object.entries(agent.usage_global)) {
|
|
154
190
|
if (usage === 0)
|
|
155
191
|
continue;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
192
|
+
let cell = 'default';
|
|
193
|
+
for (const feature of features) {
|
|
194
|
+
const support = statSupport(feature.stats[agentId]?.[version]);
|
|
195
|
+
if (support === 'none') {
|
|
196
|
+
cell = 'none';
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
if (support === 'prefixed' && !spelledWithPrefix)
|
|
200
|
+
cell = 'prefixed';
|
|
201
|
+
}
|
|
202
|
+
if (cell === 'default')
|
|
203
|
+
continue;
|
|
204
|
+
excluded += usage;
|
|
205
|
+
if (cell === 'prefixed')
|
|
206
|
+
prefixed += usage;
|
|
162
207
|
}
|
|
163
208
|
}
|
|
164
|
-
return percent(excluded);
|
|
209
|
+
return { excludedPercent: percent(excluded), prefixedPercent: percent(prefixed) };
|
|
165
210
|
}
|
|
166
211
|
}
|
|
167
212
|
let servicePromise;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"targets-service.js","sourceRoot":"","sources":["../../../src/services/targets/targets-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D
|
|
1
|
+
{"version":3,"file":"targets-service.js","sourceRoot":"","sources":["../../../src/services/targets/targets-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAC3C,MAAM,CAAC,MAAM,CAAC,aAAa,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,QAAQ,CAAC,EAAE,CAAC;IACpF,CAAC;CACF;AAED,IAAI,cAAmD,CAAC;AAExD,mEAAmE;AACnE,KAAK,UAAU,kBAAkB;IAC/B,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACtD,MAAM,CAAC,cAAc,CAAC;QACtB,MAAM,CAAC,cAAc,CAAC;KACvB,CAAC,CAAC;IACH,OAAO,IAAI,cAAc,CACvB,kBAAkB,CAAC,OAAO,EAC1B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,OAAO,CAChB,CAAC;AACJ,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,iBAAiB;IAC/B,cAAc,KAAK,kBAAkB,EAAE,CAAC;IACxC,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -5,19 +5,36 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Why a query target was not evaluated. The first two come from mapping the
|
|
8
|
-
* token onto a release; `no_bcd_data` means a compared key
|
|
9
|
-
* the
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
8
|
+
* token onto a release; `no_bcd_data` means a compared key's data does not
|
|
9
|
+
* establish support either way for the target (the key records nothing for the
|
|
10
|
+
* browser, or the target sits before a `≤` bound), `no_feature_level_data` means
|
|
11
|
+
* a feature judged on web-features' feature-level support has no answer for it
|
|
12
|
+
* (a non-core browser, or a release before a `≤` bound), and
|
|
13
|
+
* `no_comparable_feature` means the call held no feature that could be compared
|
|
14
|
+
* at all.
|
|
13
15
|
*/
|
|
14
16
|
export type UncheckedReason = 'no_bcd_browser' | 'unknown_version' | 'no_bcd_data' | 'no_feature_level_data' | 'no_comparable_feature';
|
|
15
|
-
/**
|
|
17
|
+
/** One BCD release a target covers: its ordinal, and its version or `null` before every release. */
|
|
18
|
+
export interface SpannedRelease {
|
|
19
|
+
index: number;
|
|
20
|
+
version: string | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A browserslist token that mapped onto a concrete BCD release. `bcd_version`
|
|
24
|
+
* and `bcd_release_index` name the release the token maps to — for a grouped
|
|
25
|
+
* token such as `15.0-15.1`, its lower endpoint's.
|
|
26
|
+
*/
|
|
16
27
|
export interface ResolvedTarget {
|
|
17
28
|
agent: string;
|
|
18
29
|
bcd_browser: string;
|
|
19
30
|
bcd_release_index: number;
|
|
20
31
|
bcd_version: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Every BCD release the token covers, oldest first: the release it maps to,
|
|
34
|
+
* then for a grouped token each listed release through the one its upper
|
|
35
|
+
* endpoint maps to. Judged release by release; never an output field.
|
|
36
|
+
*/
|
|
37
|
+
span: readonly SpannedRelease[];
|
|
21
38
|
version_token: string;
|
|
22
39
|
}
|
|
23
40
|
/** A browserslist token the server declined to claim a verdict for. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/targets/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/services/targets/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GACvB,gBAAgB,GAChB,iBAAiB,GACjB,aAAa,GACb,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B,oGAAoG;AACpG,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,IAAI,EAAE,SAAS,cAAc,EAAE,CAAC;IAChC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,uEAAuE;AACvE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyanheads/browser-compat-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"mcpName": "io.github.cyanheads/browser-compat-mcp-server",
|
|
5
5
|
"description": "Browser compatibility and Baseline status for any web feature — offline, from MDN's browser-compat-data, web-features, and caniuse. STDIO or Streamable HTTP.",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"changelog/",
|
|
14
14
|
"dist/",
|
|
15
|
+
"skills/",
|
|
15
16
|
"!dist/*.mcpb",
|
|
16
17
|
"README.md",
|
|
17
18
|
"LICENSE",
|
|
@@ -72,34 +73,34 @@
|
|
|
72
73
|
"url": "git+https://github.com/cyanheads/browser-compat-mcp-server.git"
|
|
73
74
|
},
|
|
74
75
|
"license": "Apache-2.0",
|
|
75
|
-
"packageManager": "bun@1.4.
|
|
76
|
+
"packageManager": "bun@1.4.4",
|
|
76
77
|
"engines": {
|
|
77
|
-
"bun": ">=1.4.
|
|
78
|
+
"bun": ">=1.4.4",
|
|
78
79
|
"node": ">=24.0.0"
|
|
79
80
|
},
|
|
80
81
|
"publishConfig": {
|
|
81
82
|
"access": "public"
|
|
82
83
|
},
|
|
83
84
|
"dependencies": {
|
|
84
|
-
"@cyanheads/mcp-ts-core": "^0.13.
|
|
85
|
-
"@mdn/browser-compat-data": "^8.1.
|
|
86
|
-
"browserslist": "^4.29.
|
|
87
|
-
"caniuse-lite": "^1.0.
|
|
85
|
+
"@cyanheads/mcp-ts-core": "^0.13.22",
|
|
86
|
+
"@mdn/browser-compat-data": "^8.1.8",
|
|
87
|
+
"browserslist": "^4.29.5",
|
|
88
|
+
"caniuse-lite": "^1.0.30001823",
|
|
88
89
|
"pino-pretty": "^13.2.0",
|
|
89
|
-
"web-features": "^3.
|
|
90
|
+
"web-features": "^3.45.0",
|
|
90
91
|
"zod": "^4.6.7"
|
|
91
92
|
},
|
|
92
93
|
"devDependencies": {
|
|
93
|
-
"@biomejs/biome": "2.
|
|
94
|
+
"@biomejs/biome": "2.6.6",
|
|
94
95
|
"@socketsecurity/bun-security-scanner": "^1.1.3",
|
|
95
|
-
"@types/node": "26.6.
|
|
96
|
-
"@vitest/coverage-istanbul": "5.0
|
|
96
|
+
"@types/node": "26.6.6",
|
|
97
|
+
"@vitest/coverage-istanbul": "5.1.0",
|
|
97
98
|
"depcheck": "^1.4.7",
|
|
98
99
|
"fast-check": "^4.10.2",
|
|
99
|
-
"ignore": "^7.0.
|
|
100
|
-
"tsc-alias": "^1.9.
|
|
100
|
+
"ignore": "^7.0.14",
|
|
101
|
+
"tsc-alias": "^1.9.10",
|
|
101
102
|
"typescript": "^7.0.2",
|
|
102
|
-
"vitest": "^5.0
|
|
103
|
+
"vitest": "^5.1.0"
|
|
103
104
|
},
|
|
104
105
|
"author": "Casey Hand <casey@caseyjhand.com> (https://caseyjhand.com)",
|
|
105
106
|
"funding": [
|
package/server.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/cyanheads/browser-compat-mcp-server.git",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.3.1",
|
|
10
10
|
"remotes": [
|
|
11
11
|
{
|
|
12
12
|
"type": "streamable-http",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
20
20
|
"identifier": "@cyanheads/browser-compat-mcp-server",
|
|
21
21
|
"runtimeHint": "npx",
|
|
22
|
-
"version": "0.
|
|
22
|
+
"version": "0.3.1",
|
|
23
23
|
"environmentVariables": [
|
|
24
24
|
{
|
|
25
25
|
"name": "MCP_LOG_LEVEL",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
39
39
|
"identifier": "@cyanheads/browser-compat-mcp-server",
|
|
40
40
|
"runtimeHint": "npx",
|
|
41
|
-
"version": "0.
|
|
41
|
+
"version": "0.3.1",
|
|
42
42
|
"environmentVariables": [
|
|
43
43
|
{
|
|
44
44
|
"name": "MCP_TRANSPORT_TYPE",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: browser-compat-guide
|
|
3
|
+
description: Assess concrete web code against a project's browser target policy with browsercompat_* tools. Use for shipping decisions, choosing between feature-level and subfeature evidence, or diagnosing historical browser failures and support qualifiers.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: "cyanheads"
|
|
7
|
+
version: "1.0"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Scope
|
|
11
|
+
|
|
12
|
+
Use this guide when reviewing the browser requirements of code being written or changed. The server supplies bundled compatibility evidence; it does not run the application, test a polyfill, or fetch the prose behind an MDN or specification link. Use the returned links when the decision depends on behavior beyond the compatibility record.
|
|
13
|
+
|
|
14
|
+
## Identifiers
|
|
15
|
+
|
|
16
|
+
`browsercompat_search_features` yields BCD keys for individual APIs, attributes, values, and other subfeatures, and web-features ids for broader capabilities. Keep BCD key casing exactly as returned: `api.Crypto` and `api.crypto` are different entries.
|
|
17
|
+
|
|
18
|
+
Choose the identifier that matches the code's dependency. A feature id such as `grid` answers for the capability as a whole; it does not establish support for every key it owns. Use `browsercompat_get_feature` to inspect its `compat_keys`, then select the key for the actual behavior. Use `browsercompat_list_reference` to resolve browser and group vocabulary rather than translating ids by guesswork.
|
|
19
|
+
|
|
20
|
+
## Gates
|
|
21
|
+
|
|
22
|
+
1. Establish the project's browser target policy before making a project shipping claim. Baseline describes general availability across its core browsers; it does not replace the project's explicit targets. If the policy is unknown, report the available evidence and leave the project verdict unresolved.
|
|
23
|
+
2. Match the evidence to the code's behavior before accepting a feature-level answer. When a multi-key id cannot answer for the required browser or subfeature, inspect its keys and compare the relevant BCD key. Keep the target policy intact; excluding unchecked browsers to obtain a pass changes the question.
|
|
24
|
+
3. Separate lack of evidence from evidence of no support. A miss asks for identifier discovery; `not_mapped` means no Baseline mapping; `no_compat_data` means no per-browser compatibility record; an unchecked target remains unresolved. None alone proves that the browser cannot run the feature. If a filtered search finds nothing, broaden the filters before declaring the feature absent.
|
|
25
|
+
4. Assess deprecation and discouragement separately from availability. `all_widely_available` does not account for either advisory, and an omitted status field does not establish that a feature is recommended.
|
|
26
|
+
5. For an older target, inspect the statement behind its verdict before recommending a prefix, flag, or fallback. A current-browser support row can select a different statement from the one relevant to that historical release. Preserve partial-support qualifiers and version bounds when describing the result.
|
|
27
|
+
6. Complete the requested feature set before giving an aggregate decision: entries in `omitted_features` still need another call. Use whole-query verdicts and failure totals for the decision; page target rows only when their individual evidence is needed.
|
|
28
|
+
7. Carry the snapshot date or dataset versions into conclusions about recent browser changes. When the returned snapshot cannot establish a recent release's behavior, verify current primary evidence before giving a definitive answer.
|
|
29
|
+
|
|
30
|
+
## Core chain
|
|
31
|
+
|
|
32
|
+
Read the code to identify the exact API, property value, attribute, or subfeature it requires. Search for that behavior, inspect the candidate record, and confirm that its identifier describes the dependency. Compare those identifiers against the project's explicit browser policy. Report supported behavior, demonstrated failures, and unresolved coverage separately, with the returned evidence for each.
|
|
33
|
+
|
|
34
|
+
## Workflows
|
|
35
|
+
|
|
36
|
+
### Review a change for shipping
|
|
37
|
+
|
|
38
|
+
Use `browsercompat_check_baseline` for availability and advisories across the identified features, then `browsercompat_compare_support` for the project's targets. For a failure, use the per-feature `failing_ranges` to identify affected browser versions. Inspect target rows and the full feature record only where needed to decide whether the code requires a fallback, a different feature, or a stated browser restriction. A fallback needs its own compatibility assessment; this server does not prove that the application selects it correctly.
|
|
39
|
+
|
|
40
|
+
### Diagnose a historical browser failure
|
|
41
|
+
|
|
42
|
+
Compare the exact failing browser version and the BCD key for the failing behavior. Inspect the failing row's support statement, then use `browsercompat_get_feature` to read the browser's main row and `other_statements`, including notes and links. An earlier prefixed or flagged implementation may be there even when the main row describes clean support in the newest release. If the verdict is unknown, preserve that uncertainty rather than inferring an exact release from a bound.
|
|
43
|
+
|
|
44
|
+
### Express the target policy
|
|
45
|
+
|
|
46
|
+
Pass a self-contained browserslist expression. Use explicit browser versions for a reproduction and the project's actual expression for a shipping review. A comma or `or` forms a union (`chrome 100, firefox 100`); `and` intersects selections (`last 2 versions and > 0.5%`). Do not turn a union into an intersection to reduce failures. `defaults` is a browserslist policy, not a way to load the project's configuration.
|
|
47
|
+
|
|
48
|
+
Resolve configuration packages and custom usage statistics in the project's own environment before calling this server; it cannot read the caller's project configuration. Preserve the resulting browser/version targets when expressing them explicitly. Follow the tool's current query validation and recovery guidance.
|