lighthouse-mcp 0.1.9 → 0.1.12
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/README.md +4 -42
- package/build/index.js +57 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
An MCP server that wraps around Google's Lighthouse tool to help measure various performance metrics for web pages.
|
|
4
4
|
|
|
5
|
-

|
|
6
|
-
|
|
7
5
|
## Features
|
|
8
6
|
|
|
9
7
|
- Run comprehensive Lighthouse audits on any URL
|
|
@@ -150,43 +148,7 @@ Claude will use the `get_performance_score` tool to analyze the website and retu
|
|
|
150
148
|
- Node.js 16+
|
|
151
149
|
- Chrome/Chromium browser (for Lighthouse)
|
|
152
150
|
|
|
153
|
-
##
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
Before releasing, ensure you're authenticated with both registries:
|
|
158
|
-
|
|
159
|
-
**NPM Authentication:**
|
|
160
|
-
```bash
|
|
161
|
-
npm login
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
**MCP Registry Authentication:**
|
|
165
|
-
```bash
|
|
166
|
-
mcp-publisher login github
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
If your authentication tokens expire, you'll need to re-login to the respective services.
|
|
170
|
-
|
|
171
|
-
### Making Releases
|
|
172
|
-
|
|
173
|
-
Use the interactive release script to publish to both NPM and the MCP Registry:
|
|
174
|
-
|
|
175
|
-
```bash
|
|
176
|
-
./release.sh
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
The script will:
|
|
180
|
-
1. Check NPM login status
|
|
181
|
-
2. Check for uncommitted changes
|
|
182
|
-
3. Run tests (if they exist)
|
|
183
|
-
4. Build the project
|
|
184
|
-
5. Prompt for version bump type (patch/minor/major/custom)
|
|
185
|
-
6. Update both package.json and server.json versions
|
|
186
|
-
7. Create a preview of the package contents
|
|
187
|
-
8. Publish to NPM
|
|
188
|
-
9. Publish to MCP Registry (if mcp-publisher is available)
|
|
189
|
-
10. Create git commit and tag
|
|
190
|
-
11. Optionally push to remote repository
|
|
191
|
-
|
|
192
|
-
This ensures consistent releases to both registries with proper version synchronization.
|
|
151
|
+
## Endorsements
|
|
152
|
+
<a href="https://glama.ai/mcp/servers/@priyankark/lighthouse-mcp">
|
|
153
|
+
<img width="380" height="200" src="https://glama.ai/mcp/servers/@priyankark/lighthouse-mcp/badge" />
|
|
154
|
+
</a>
|
package/build/index.js
CHANGED
|
@@ -4,6 +4,40 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
4
4
|
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import lighthouse from 'lighthouse';
|
|
6
6
|
import * as chromeLauncher from 'chrome-launcher';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
// Workaround for modelcontextprotocol/typescript-sdk#1380
|
|
11
|
+
// In some Zod runtimes, the method literal is stored under `_def.values[0]`
|
|
12
|
+
// instead of `_def.value` / `.value`, causing "Schema method literal must be a string"
|
|
13
|
+
// during Server initialization. This patches setRequestHandler to handle both cases.
|
|
14
|
+
const originalSetRequestHandler = Server.prototype.setRequestHandler;
|
|
15
|
+
Server.prototype.setRequestHandler = function patchedSetRequestHandler(requestSchema, handler) {
|
|
16
|
+
try {
|
|
17
|
+
return originalSetRequestHandler.call(this, requestSchema, handler);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err?.message !== 'Schema method literal must be a string')
|
|
21
|
+
throw err;
|
|
22
|
+
// Attempt to fix the schema by copying values[0] to value
|
|
23
|
+
try {
|
|
24
|
+
const shape = requestSchema?.shape ?? requestSchema?._def?.shape?.();
|
|
25
|
+
const methodSchema = shape?.method;
|
|
26
|
+
const def = methodSchema?._def;
|
|
27
|
+
const maybeValue = Array.isArray(def?.values) ? def.values[0] : undefined;
|
|
28
|
+
if (typeof maybeValue === 'string') {
|
|
29
|
+
if (def && def.value === undefined)
|
|
30
|
+
def.value = maybeValue;
|
|
31
|
+
if (methodSchema && methodSchema.value === undefined)
|
|
32
|
+
methodSchema.value = maybeValue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// If patching fails, rethrow the original error
|
|
37
|
+
}
|
|
38
|
+
return originalSetRequestHandler.call(this, requestSchema, handler);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
7
41
|
const isValidAuditArgs = (args) => {
|
|
8
42
|
return (typeof args === 'object' &&
|
|
9
43
|
args !== null &&
|
|
@@ -111,7 +145,29 @@ class LighthouseServer {
|
|
|
111
145
|
throw new McpError(ErrorCode.InvalidParams, 'Invalid audit arguments');
|
|
112
146
|
}
|
|
113
147
|
try {
|
|
114
|
-
|
|
148
|
+
// Ensure temp directory exists and is writable (fixes #19 - Windows EPERM)
|
|
149
|
+
// On Windows, os.tmpdir() reads TEMP -> TMP -> USERPROFILE, so we verify
|
|
150
|
+
// the resolved path is usable before launching Chrome.
|
|
151
|
+
const tmpDir = os.tmpdir();
|
|
152
|
+
try {
|
|
153
|
+
fs.accessSync(tmpDir, fs.constants.W_OK);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// If the default temp dir isn't writable, create a fallback in the user's home
|
|
157
|
+
const fallbackTmp = path.join(os.homedir(), '.lighthouse-tmp');
|
|
158
|
+
if (!fs.existsSync(fallbackTmp)) {
|
|
159
|
+
fs.mkdirSync(fallbackTmp, { recursive: true });
|
|
160
|
+
}
|
|
161
|
+
process.env.TEMP = fallbackTmp;
|
|
162
|
+
process.env.TMP = fallbackTmp;
|
|
163
|
+
process.env.TMPDIR = fallbackTmp;
|
|
164
|
+
}
|
|
165
|
+
// Explicitly pass process.env so MCP-configured env vars (TEMP, TMP, TMPDIR)
|
|
166
|
+
// propagate to the Chrome child process on all platforms.
|
|
167
|
+
const chrome = await chromeLauncher.launch({
|
|
168
|
+
chromeFlags: ['--headless', '--no-sandbox'],
|
|
169
|
+
envVars: process.env,
|
|
170
|
+
});
|
|
115
171
|
const options = {
|
|
116
172
|
logLevel: 'info',
|
|
117
173
|
output: 'json',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "MCP server for Google Lighthouse performance metrics",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -35,10 +35,14 @@
|
|
|
35
35
|
"url": ""
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@modelcontextprotocol/sdk": "
|
|
38
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
39
39
|
"chrome-launcher": "^0.15.2",
|
|
40
40
|
"lighthouse": "^12.5.1"
|
|
41
41
|
},
|
|
42
|
+
"overrides": {
|
|
43
|
+
"basic-ftp": ">=5.2.0",
|
|
44
|
+
"lodash-es": ">=4.17.23"
|
|
45
|
+
},
|
|
42
46
|
"devDependencies": {
|
|
43
47
|
"@types/node": "^20.4.5",
|
|
44
48
|
"typescript": "^5.1.6"
|