@reus-able/frontend-helper-mcp 1.0.0 → 1.0.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/dist/index.js +4 -64
- package/package.json +1 -7
- package/prompts/code-refactor.md +18 -0
- package/prompts/component-refactor.md +22 -0
- package/prompts/git-commit.md +10 -0
- package/prompts/demo.md +0 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
-
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
|
|
5
4
|
import { ListPromptsRequestSchema, GetPromptRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
6
5
|
import fs from 'fs/promises';
|
|
7
6
|
import path from 'path';
|
|
8
|
-
import yargs from 'yargs';
|
|
9
|
-
import { hideBin } from 'yargs/helpers';
|
|
10
7
|
import { fileURLToPath } from 'url';
|
|
11
|
-
import express from 'express';
|
|
12
|
-
import cors from 'cors';
|
|
13
8
|
async function createServer(promptsDir) {
|
|
14
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
15
10
|
const packageJsonPath = path.resolve(__dirname, '../package.json');
|
|
@@ -78,66 +73,11 @@ async function createServer(promptsDir) {
|
|
|
78
73
|
}
|
|
79
74
|
async function main() {
|
|
80
75
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
81
|
-
const packageJsonPath = path.resolve(__dirname, '../package.json');
|
|
82
|
-
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
|
|
83
|
-
const argv = await yargs(hideBin(process.argv))
|
|
84
|
-
.option('transport', {
|
|
85
|
-
alias: 't',
|
|
86
|
-
type: 'string',
|
|
87
|
-
choices: ['stdio', 'sse'],
|
|
88
|
-
default: 'stdio',
|
|
89
|
-
description: 'Transport mode (stdio or sse)',
|
|
90
|
-
})
|
|
91
|
-
.option('port', {
|
|
92
|
-
alias: 'p',
|
|
93
|
-
type: 'number',
|
|
94
|
-
default: 3000,
|
|
95
|
-
description: 'Port to listen on (only for sse transport)',
|
|
96
|
-
})
|
|
97
|
-
.help()
|
|
98
|
-
.parse();
|
|
99
76
|
const promptsDir = path.resolve(__dirname, '../prompts');
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const sessions = new Map();
|
|
105
|
-
app.get('/sse', async (req, res) => {
|
|
106
|
-
console.log(`New SSE connection from ${req.ip}`);
|
|
107
|
-
const mcpServer = await createServer(promptsDir);
|
|
108
|
-
const transport = new SSEServerTransport('/messages', res);
|
|
109
|
-
await mcpServer.connect(transport);
|
|
110
|
-
sessions.set(transport.sessionId, { server: mcpServer, transport });
|
|
111
|
-
transport.onclose = () => {
|
|
112
|
-
console.log(`Session closed: ${transport.sessionId}`);
|
|
113
|
-
sessions.delete(transport.sessionId);
|
|
114
|
-
};
|
|
115
|
-
await transport.start();
|
|
116
|
-
});
|
|
117
|
-
app.post('/messages', async (req, res) => {
|
|
118
|
-
const sessionId = req.query.sessionId;
|
|
119
|
-
if (!sessionId) {
|
|
120
|
-
res.status(400).send('Missing sessionId');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const session = sessions.get(sessionId);
|
|
124
|
-
if (!session) {
|
|
125
|
-
res.status(404).send('Session not found');
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
await session.transport.handlePostMessage(req, res);
|
|
129
|
-
});
|
|
130
|
-
app.listen(argv.port, () => {
|
|
131
|
-
console.log(`MCP Server running on SSE mode at http://localhost:${argv.port}/sse`);
|
|
132
|
-
console.log(`Prompts directory: ${promptsDir}`);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
console.error(`Starting MCP server serving prompts from: ${promptsDir}`);
|
|
137
|
-
const mcpServer = await createServer(promptsDir);
|
|
138
|
-
const transport = new StdioServerTransport();
|
|
139
|
-
await mcpServer.connect(transport);
|
|
140
|
-
}
|
|
77
|
+
console.error(`Starting MCP server serving prompts from: ${promptsDir}`);
|
|
78
|
+
const mcpServer = await createServer(promptsDir);
|
|
79
|
+
const transport = new StdioServerTransport();
|
|
80
|
+
await mcpServer.connect(transport);
|
|
141
81
|
}
|
|
142
82
|
main().catch((error) => {
|
|
143
83
|
console.error('Fatal error:', error);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "前端开发的一些cursor mcp工具集",
|
|
3
3
|
"name": "@reus-able/frontend-helper-mcp",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -24,16 +24,10 @@
|
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
27
|
-
"cors": "^2.8.5",
|
|
28
|
-
"express": "^5.2.1",
|
|
29
|
-
"yargs": "^18.0.0",
|
|
30
27
|
"zod": "^4.2.1"
|
|
31
28
|
},
|
|
32
29
|
"devDependencies": {
|
|
33
|
-
"@types/cors": "^2.8.19",
|
|
34
|
-
"@types/express": "^5.0.6",
|
|
35
30
|
"@types/node": "^25.0.3",
|
|
36
|
-
"@types/yargs": "^17.0.35",
|
|
37
31
|
"typescript": "^5.9.3"
|
|
38
32
|
}
|
|
39
33
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
## 协助用户进行代码重构
|
|
2
|
+
|
|
3
|
+
请你协助用户对声明的代码目录或文件进行重构,主要是识别出代码中是否存在重复的常量、工具函数或类型定义,并将其提取到对应的目录或文件中。
|
|
4
|
+
|
|
5
|
+
重点在于:
|
|
6
|
+
- 常量提取
|
|
7
|
+
- 工具函数提取
|
|
8
|
+
- 类型定义提取
|
|
9
|
+
- 大型函数的拆分
|
|
10
|
+
|
|
11
|
+
在计划中你需要:
|
|
12
|
+
- 列出更改后需要调整的文件,按照目录树的方式展示
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
**注意不要更改逻辑**
|
|
16
|
+
|
|
17
|
+
项目代码接口参考:`.cursor/rules/project-structure.mdc`
|
|
18
|
+
编码规范参考:`.cursor/rules/typescript-rules.mdc`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## 组件结构重构
|
|
2
|
+
你需要帮助用户进行组件结构重构,要求如下
|
|
3
|
+
|
|
4
|
+
1. 视图层与逻辑层分离,即SFC中只负责视图渲染,逻辑抽离到hook中。
|
|
5
|
+
1.1. 完善定义组件的常量、类型,将props,emit等类型也提取出来。
|
|
6
|
+
1.2. 组件中的主要逻辑需要放在对应的useXXX.ts文件中,入参为组件的props,并导出useXXX hook。
|
|
7
|
+
1.3. 组件中如果需要使用了其他的hook,你需要在SFC中组织他们的关系如果没有关系直接使用即可。
|
|
8
|
+
1.4. 不需要显式定义hook的return类型,ts会自动推导。
|
|
9
|
+
|
|
10
|
+
2. 组件声明周期处理
|
|
11
|
+
2.1. 分离出来的hook内部不需要处理组件的声明周期,而是暴露出相应的生命周期钩子函数。
|
|
12
|
+
2.2. 由SFC来处理组件的声明周期,如onMounted,onUnmounted等,而Watch可以保留在hook中
|
|
13
|
+
|
|
14
|
+
3. 组件样式重构
|
|
15
|
+
3.1. 对于style标签中的样式,如果是原生css写法请使用 tailwindcss 的@apply写法。
|
|
16
|
+
|
|
17
|
+
4. 注意点
|
|
18
|
+
** 不要设计逻辑的变更 **
|
|
19
|
+
** 不要修改类名或者html结构 **
|
|
20
|
+
** 注意不要破坏变量的响应式 **
|
|
21
|
+
|
|
22
|
+
在实施前请在计划中列举你的改动点并严格遵守注意点。
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## 协助用户提交当前变更
|
|
2
|
+
|
|
3
|
+
请你帮助用户提交当前变更,并按照约定式 commit 规范进行 git commit
|
|
4
|
+
你只需要分析用户的变更并生成commit message并commit
|
|
5
|
+
|
|
6
|
+
要求:
|
|
7
|
+
1. 一般情况下不允许改动任何要提交的文件
|
|
8
|
+
2. 不需要手动跑lint指令,husky会处理
|
|
9
|
+
3. 有时提交可能会报错,你需要分析报错原因并告知用户是否进行下一步操作,如果需要改动文件(例如修复lint错误,类型错误),需要获得用户同意后进行改动
|
|
10
|
+
4. 如果改动了文件,需要告知用户哪里有改动,并且在用户确认后再提交
|
package/prompts/demo.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello from MCP Prompt
|