mcp-optimizer 0.0.1 → 0.0.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/README.md CHANGED
@@ -2,7 +2,25 @@
2
2
 
3
3
  A minimal scaffold that runs Lighthouse to produce performance reports. The project includes a placeholder fixer that can be extended to integrate an LLM for automatic code fixes.
4
4
 
5
- Quick start
5
+ ## Using with an MCP Host
6
+ This section provides an example of launching via an MCP host (stdio).
7
+
8
+ If you want to configure an MCP host to spawn the optimizer via `npx`, add a server entry like the following to your host config:
9
+
10
+ ```json
11
+ {
12
+ "mcpServers": {
13
+ "mcp-optimizer": {
14
+ "command": "npx",
15
+ "args": ["-y", "mcp-optimizer@latest", "--","--port", "5000"]
16
+ }
17
+ }
18
+ }
19
+ ```
20
+
21
+ This will instruct the host to spawn `npx -y mcp-optimizer@latest -- --port 5000` and communicate with the child over stdio.
22
+
23
+ ## Quick start
6
24
 
7
25
  1. Install runtime dependencies:
8
26
 
@@ -25,22 +43,5 @@ npm run dev
25
43
  curl -X POST http://localhost:3000/audit -H "Content-Type: application/json" -d '{"url":"https://example.com"}'
26
44
  ```
27
45
 
28
- Notes
29
- This section provides an example of launching via an MCP host (stdio).
30
-
31
- If you want to configure an MCP host to spawn the optimizer via `npx`, add a server entry like the following to your host config:
32
-
33
- ```json
34
- {
35
- "mcpServers": {
36
- "mcp-optimizer": {
37
- "command": "npx",
38
- "args": ["-y", "mcp-optimizer@0.0.6-alpha.1", "--","--port", "5000"]
39
- }
40
- }
41
- }
42
- ```
43
-
44
- This will instruct the host to spawn `npx -y mcp-optimizer@0.0.6-alpha.1 -- --port 5000` and communicate with the child over stdio.
45
46
 
46
47
 
package/dist/mcpServer.js CHANGED
@@ -106,12 +106,11 @@ class LighthouseMcpServer {
106
106
  performance: perf !== null ? Math.round(perf * 100) : undefined,
107
107
  accessibility: accessibility !== null ? Math.round(accessibility * 100) : undefined
108
108
  };
109
- // 返回所有信息,便于 HTTP 路由复用
109
+ // 返回精简信息:只返回 summary 与 reportId,完整报告保存在服务器以便按需获取
110
110
  return {
111
111
  content: [
112
112
  { type: "text", text: JSON.stringify(summary, null, 2) },
113
- { type: "text", text: JSON.stringify(lhr, null, 2) },
114
- { type: "text", text: JSON.stringify(reportObj, null, 2) }
113
+ { type: "text", text: `reportId:${id}` }
115
114
  ]
116
115
  };
117
116
  }
@@ -166,12 +165,12 @@ class LighthouseMcpServer {
166
165
  performance: perf !== null ? Math.round(perf * 100) : undefined,
167
166
  accessibility: accessibility !== null ? Math.round(accessibility * 100) : undefined
168
167
  };
168
+ const fixAvailable = !!fix;
169
169
  return {
170
170
  content: [
171
171
  { type: "text", text: JSON.stringify(summary, null, 2) },
172
- { type: "text", text: JSON.stringify(result.lhr || {}, null, 2) },
173
- { type: "text", text: JSON.stringify(result.report || {}, null, 2) },
174
- { type: "text", text: JSON.stringify({ fix }, null, 2) }
172
+ { type: "text", text: `reportId:${result.id}` },
173
+ { type: "text", text: JSON.stringify({ fixAvailable }, null, 2) }
175
174
  ]
176
175
  };
177
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-optimizer",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "An MCP server that runs Lighthouse audits and enables LLMs to automatically optimize your code.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/mcpServer.ts CHANGED
@@ -80,12 +80,11 @@ export class LighthouseMcpServer {
80
80
  performance: perf !== null ? Math.round(perf * 100) : undefined,
81
81
  accessibility: accessibility !== null ? Math.round(accessibility * 100) : undefined
82
82
  };
83
- // 返回所有信息,便于 HTTP 路由复用
83
+ // 返回精简信息:只返回 summary 与 reportId,完整报告保存在服务器以便按需获取
84
84
  return {
85
85
  content: [
86
86
  { type: "text", text: JSON.stringify(summary, null, 2) },
87
- { type: "text", text: JSON.stringify(lhr, null, 2) },
88
- { type: "text", text: JSON.stringify(reportObj, null, 2) }
87
+ { type: "text", text: `reportId:${id}` }
89
88
  ]
90
89
  };
91
90
  } catch (error) {
@@ -150,12 +149,12 @@ export class LighthouseMcpServer {
150
149
  performance: perf !== null ? Math.round(perf * 100) : undefined,
151
150
  accessibility: accessibility !== null ? Math.round(accessibility * 100) : undefined
152
151
  };
152
+ const fixAvailable = !!fix;
153
153
  return {
154
154
  content: [
155
155
  { type: "text", text: JSON.stringify(summary, null, 2) },
156
- { type: "text", text: JSON.stringify(result.lhr || {}, null, 2) },
157
- { type: "text", text: JSON.stringify(result.report || {}, null, 2) },
158
- { type: "text", text: JSON.stringify({ fix }, null, 2) }
156
+ { type: "text", text: `reportId:${result.id}` },
157
+ { type: "text", text: JSON.stringify({ fixAvailable }, null, 2) }
159
158
  ]
160
159
  };
161
160
  } catch (err: any) {