@reus-able/frontend-helper-mcp 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/dist/index.js +52 -52
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,101 +1,101 @@
1
1
  #!/usr/bin/env node
2
- import { McpServer as w } from "@modelcontextprotocol/sdk/server/mcp.js";
3
- import { StdioServerTransport as y } from "@modelcontextprotocol/sdk/server/stdio.js";
4
- import i from "fs/promises";
2
+ import { McpServer as d } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport as f } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import c from "fs/promises";
5
5
  import s from "path";
6
- import { fileURLToPath as p } from "url";
7
- import { ListPromptsRequestSchema as h, GetPromptRequestSchema as R, ListResourcesRequestSchema as v, ReadResourceRequestSchema as g, ListToolsRequestSchema as S, CallToolRequestSchema as q } from "@modelcontextprotocol/sdk/types.js";
8
- async function u(e) {
6
+ import { fileURLToPath as w } from "url";
7
+ import { ListPromptsRequestSchema as y, GetPromptRequestSchema as h, ListResourcesRequestSchema as R, ReadResourceRequestSchema as v, ListToolsRequestSchema as g, CallToolRequestSchema as S } from "@modelcontextprotocol/sdk/types.js";
8
+ async function m(e) {
9
9
  try {
10
- return await i.access(e), (await i.readdir(e)).filter(
10
+ return await c.access(e), (await c.readdir(e)).filter(
11
11
  (o) => [".txt", ".md", ".json"].includes(s.extname(o).toLowerCase())
12
12
  );
13
13
  } catch (r) {
14
14
  return console.error(`Error accessing prompts directory ${e}:`, r), [];
15
15
  }
16
16
  }
17
- async function d(e, r) {
18
- return (await u(e)).find((t) => s.parse(t).name === r);
17
+ async function u(e, r) {
18
+ return (await m(e)).find((t) => s.parse(t).name === r);
19
19
  }
20
- function l(e) {
20
+ function p(e) {
21
21
  const r = s.extname(e).toLowerCase();
22
22
  return r === ".md" ? "text/markdown" : r === ".json" ? "application/json" : "text/plain";
23
23
  }
24
- function x(e) {
25
- const r = s.dirname(p(import.meta.url)), o = s.resolve(r, "../../../resources/command-prompts");
26
- e.server.setRequestHandler(h, async () => {
24
+ function q(e) {
25
+ const r = s.resolve(__dirname, "../../../resources/command-prompts");
26
+ e.server.setRequestHandler(y, async () => {
27
27
  try {
28
- return { prompts: (await u(o)).map((n) => ({
28
+ return { prompts: (await m(r)).map((n) => ({
29
29
  name: s.parse(n).name,
30
30
  description: `Content of ${n}`
31
31
  })) };
32
- } catch (t) {
33
- return console.error("Error listing prompts:", t), { prompts: [] };
32
+ } catch (o) {
33
+ return console.error("Error listing prompts:", o), { prompts: [] };
34
34
  }
35
- }), e.server.setRequestHandler(R, async (t) => {
36
- const a = t.params.name;
35
+ }), e.server.setRequestHandler(h, async (o) => {
36
+ const t = o.params.name;
37
37
  try {
38
- const n = await d(o, a);
38
+ const n = await u(r, t);
39
39
  if (!n)
40
- throw new Error(`Prompt not found: ${a}`);
40
+ throw new Error(`Prompt not found: ${t}`);
41
41
  return {
42
42
  messages: [
43
43
  {
44
44
  role: "user",
45
45
  content: {
46
46
  type: "text",
47
- text: await i.readFile(s.join(o, n), "utf-8")
47
+ text: await c.readFile(s.join(r, n), "utf-8")
48
48
  }
49
49
  }
50
50
  ]
51
51
  };
52
52
  } catch (n) {
53
- throw new Error(`Failed to load prompt ${a}: ${n}`);
53
+ throw new Error(`Failed to load prompt ${t}: ${n}`);
54
54
  }
55
55
  });
56
56
  }
57
- function F(e) {
58
- const r = s.dirname(p(import.meta.url)), o = s.resolve(r, "../../../resources/command-prompts");
59
- e.server.setRequestHandler(v, async () => {
57
+ function x(e) {
58
+ const r = s.resolve(__dirname, "../../../resources/command-prompts");
59
+ e.server.setRequestHandler(R, async () => {
60
60
  try {
61
- return { resources: (await u(o)).map((n) => {
62
- const c = s.parse(n).name, m = l(n);
61
+ return { resources: (await m(r)).map((n) => {
62
+ const a = s.parse(n).name, i = p(n);
63
63
  return {
64
- uri: `prompt://${c}`,
65
- name: c,
66
- mimeType: m,
64
+ uri: `prompt://${a}`,
65
+ name: a,
66
+ mimeType: i,
67
67
  description: `Content of ${n}`
68
68
  };
69
69
  }) };
70
- } catch (t) {
71
- return console.error("Error listing resources:", t), { resources: [] };
70
+ } catch (o) {
71
+ return console.error("Error listing resources:", o), { resources: [] };
72
72
  }
73
73
  }), e.server.setRequestHandler(
74
- g,
75
- async (t) => {
76
- const a = t.params.uri, n = a.replace(/^prompt:\/\//, "");
74
+ v,
75
+ async (o) => {
76
+ const t = o.params.uri, n = t.replace(/^prompt:\/\//, "");
77
77
  try {
78
- const c = await d(o, n);
79
- if (!c)
80
- throw new Error(`Resource not found: ${a}`);
81
- const m = await i.readFile(s.join(o, c), "utf-8"), f = l(c);
78
+ const a = await u(r, n);
79
+ if (!a)
80
+ throw new Error(`Resource not found: ${t}`);
81
+ const i = await c.readFile(s.join(r, a), "utf-8"), l = p(a);
82
82
  return {
83
83
  contents: [
84
84
  {
85
- uri: a,
86
- mimeType: f,
87
- text: m
85
+ uri: t,
86
+ mimeType: l,
87
+ text: i
88
88
  }
89
89
  ]
90
90
  };
91
- } catch (c) {
92
- throw new Error(`Failed to read resource ${a}: ${c}`);
91
+ } catch (a) {
92
+ throw new Error(`Failed to read resource ${t}: ${a}`);
93
93
  }
94
94
  }
95
95
  );
96
96
  }
97
- function $(e) {
98
- e.server.setRequestHandler(S, async () => ({ tools: [] })), e.server.setRequestHandler(q, async (r) => ({
97
+ function F(e) {
98
+ e.server.setRequestHandler(g, async () => ({ tools: [] })), e.server.setRequestHandler(S, async (r) => ({
99
99
  content: [
100
100
  {
101
101
  type: "text",
@@ -105,8 +105,8 @@ function $(e) {
105
105
  isError: !0
106
106
  }));
107
107
  }
108
- async function H() {
109
- const e = s.dirname(p(import.meta.url)), r = s.resolve(e, "../package.json"), o = JSON.parse(await i.readFile(r, "utf-8")), t = new w(
108
+ async function $() {
109
+ const e = s.dirname(w(import.meta.url)), r = s.resolve(e, "../package.json"), o = JSON.parse(await c.readFile(r, "utf-8")), t = new d(
110
110
  {
111
111
  name: o.name,
112
112
  version: o.version
@@ -119,13 +119,13 @@ async function H() {
119
119
  }
120
120
  }
121
121
  );
122
- return x(t), F(t), $(t), t;
122
+ return q(t), x(t), F(t), t;
123
123
  }
124
- async function P() {
124
+ async function H() {
125
125
  console.error("Starting MCP server serving...");
126
- const e = await H(), r = new y();
126
+ const e = await $(), r = new f();
127
127
  await e.connect(r);
128
128
  }
129
- P().catch((e) => {
129
+ H().catch((e) => {
130
130
  console.error("Fatal error:", e), process.exit(1);
131
131
  });
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.9",
4
+ "version": "1.0.10",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },