@jaypie/mcp 0.1.0
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/LICENSE.txt +21 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +127 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Finlayson Studio, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import * as fs from 'fs/promises';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import matter from 'gray-matter';
|
|
9
|
+
|
|
10
|
+
// Version will be injected during build
|
|
11
|
+
const version = "0.0.0";
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
const PROMPTS_PATH = path.join(__dirname, "..", "prompts");
|
|
15
|
+
const server = new McpServer({
|
|
16
|
+
name: "jaypie",
|
|
17
|
+
version,
|
|
18
|
+
}, {
|
|
19
|
+
capabilities: {},
|
|
20
|
+
});
|
|
21
|
+
async function parseMarkdownFile(filePath) {
|
|
22
|
+
try {
|
|
23
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
24
|
+
const filename = path.basename(filePath);
|
|
25
|
+
if (content.startsWith("---")) {
|
|
26
|
+
const parsed = matter(content);
|
|
27
|
+
const frontMatter = parsed.data;
|
|
28
|
+
return {
|
|
29
|
+
filename,
|
|
30
|
+
description: frontMatter.description,
|
|
31
|
+
include: frontMatter.include || frontMatter.globs,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return { filename };
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return { filename: path.basename(filePath) };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function formatPromptListItem(prompt) {
|
|
41
|
+
const { filename, description, include } = prompt;
|
|
42
|
+
if (description && include) {
|
|
43
|
+
return `* ${filename}: ${description} - Required for ${include}`;
|
|
44
|
+
}
|
|
45
|
+
else if (description) {
|
|
46
|
+
return `* ${filename}: ${description}`;
|
|
47
|
+
}
|
|
48
|
+
else if (include) {
|
|
49
|
+
return `* ${filename} - Required for ${include}`;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return `* ${filename}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
server.tool("list_prompts", "Returns a bulleted list of all .md files in the prompts directory with their descriptions and requirements", {}, async () => {
|
|
56
|
+
try {
|
|
57
|
+
const files = await fs.readdir(PROMPTS_PATH);
|
|
58
|
+
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
59
|
+
const prompts = await Promise.all(mdFiles.map((file) => parseMarkdownFile(path.join(PROMPTS_PATH, file))));
|
|
60
|
+
const formattedList = prompts.map(formatPromptListItem).join("\n");
|
|
61
|
+
return {
|
|
62
|
+
content: [
|
|
63
|
+
{
|
|
64
|
+
type: "text",
|
|
65
|
+
text: formattedList || "No .md files found in the prompts directory.",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: `Error listing prompts: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
server.tool("read_prompt", "Returns the contents of a specified prompt file", {
|
|
82
|
+
filename: z
|
|
83
|
+
.string()
|
|
84
|
+
.describe("The name of the prompt file to read (e.g., example_prompt.md)"),
|
|
85
|
+
}, async ({ filename }) => {
|
|
86
|
+
try {
|
|
87
|
+
const filePath = path.join(PROMPTS_PATH, filename);
|
|
88
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
89
|
+
return {
|
|
90
|
+
content: [
|
|
91
|
+
{
|
|
92
|
+
type: "text",
|
|
93
|
+
text: content,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error.code === "ENOENT") {
|
|
100
|
+
return {
|
|
101
|
+
content: [
|
|
102
|
+
{
|
|
103
|
+
type: "text",
|
|
104
|
+
text: `Error: Prompt file "${filename}" not found in prompts directory`,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: "text",
|
|
113
|
+
text: `Error reading prompt file: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
async function main() {
|
|
120
|
+
const transport = new StdioServerTransport();
|
|
121
|
+
await server.connect(transport);
|
|
122
|
+
// Server is running on stdio
|
|
123
|
+
}
|
|
124
|
+
main();
|
|
125
|
+
|
|
126
|
+
export { server };
|
|
127
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { z } from \"zod\";\nimport * as fs from \"fs/promises\";\nimport * as path from \"path\";\nimport { fileURLToPath } from \"url\";\nimport matter from \"gray-matter\";\n// Version will be injected during build\nconst version = \"0.0.0\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\nconst PROMPTS_PATH = path.join(__dirname, \"..\", \"prompts\");\n\nconst server = new McpServer(\n {\n name: \"jaypie\",\n version,\n },\n {\n capabilities: {},\n },\n);\n\ninterface FrontMatter {\n description?: string;\n include?: string;\n globs?: string;\n}\n\nasync function parseMarkdownFile(filePath: string): Promise<{\n filename: string;\n description?: string;\n include?: string;\n}> {\n try {\n const content = await fs.readFile(filePath, \"utf-8\");\n const filename = path.basename(filePath);\n\n if (content.startsWith(\"---\")) {\n const parsed = matter(content);\n const frontMatter = parsed.data as FrontMatter;\n return {\n filename,\n description: frontMatter.description,\n include: frontMatter.include || frontMatter.globs,\n };\n }\n\n return { filename };\n } catch {\n return { filename: path.basename(filePath) };\n }\n}\n\nfunction formatPromptListItem(prompt: {\n filename: string;\n description?: string;\n include?: string;\n}): string {\n const { filename, description, include } = prompt;\n\n if (description && include) {\n return `* ${filename}: ${description} - Required for ${include}`;\n } else if (description) {\n return `* ${filename}: ${description}`;\n } else if (include) {\n return `* ${filename} - Required for ${include}`;\n } else {\n return `* ${filename}`;\n }\n}\n\nserver.tool(\n \"list_prompts\",\n \"Returns a bulleted list of all .md files in the prompts directory with their descriptions and requirements\",\n {},\n async () => {\n try {\n const files = await fs.readdir(PROMPTS_PATH);\n const mdFiles = files.filter((file) => file.endsWith(\".md\"));\n\n const prompts = await Promise.all(\n mdFiles.map((file) => parseMarkdownFile(path.join(PROMPTS_PATH, file))),\n );\n\n const formattedList = prompts.map(formatPromptListItem).join(\"\\n\");\n\n return {\n content: [\n {\n type: \"text\" as const,\n text:\n formattedList || \"No .md files found in the prompts directory.\",\n },\n ],\n };\n } catch (error) {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error listing prompts: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n },\n ],\n };\n }\n },\n);\n\nserver.tool(\n \"read_prompt\",\n \"Returns the contents of a specified prompt file\",\n {\n filename: z\n .string()\n .describe(\n \"The name of the prompt file to read (e.g., example_prompt.md)\",\n ),\n },\n async ({ filename }) => {\n try {\n const filePath = path.join(PROMPTS_PATH, filename);\n const content = await fs.readFile(filePath, \"utf-8\");\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: content,\n },\n ],\n };\n } catch (error) {\n if ((error as { code?: string }).code === \"ENOENT\") {\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error: Prompt file \"${filename}\" not found in prompts directory`,\n },\n ],\n };\n }\n\n return {\n content: [\n {\n type: \"text\" as const,\n text: `Error reading prompt file: ${error instanceof Error ? error.message : \"Unknown error\"}`,\n },\n ],\n };\n }\n },\n);\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n // Server is running on stdio\n}\n\nmain();\n\nexport { server };\n"],"names":[],"mappings":";;;;;;;;;AAQA;AACA,MAAM,OAAO,GAAG,OAAO;AAEvB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;AAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC;AAE1D,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;AACE,IAAA,IAAI,EAAE,QAAQ;IACd,OAAO;CACR,EACD;AACE,IAAA,YAAY,EAAE,EAAE;AACjB,CAAA;AASH,eAAe,iBAAiB,CAAC,QAAgB,EAAA;AAK/C,IAAA,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAExC,QAAA,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;AAC7B,YAAA,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC;AAC9B,YAAA,MAAM,WAAW,GAAG,MAAM,CAAC,IAAmB;YAC9C,OAAO;gBACL,QAAQ;gBACR,WAAW,EAAE,WAAW,CAAC,WAAW;AACpC,gBAAA,OAAO,EAAE,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,KAAK;aAClD;QACH;QAEA,OAAO,EAAE,QAAQ,EAAE;IACrB;AAAE,IAAA,MAAM;QACN,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;IAC9C;AACF;AAEA,SAAS,oBAAoB,CAAC,MAI7B,EAAA;IACC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MA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M,CAAC,OAAO,CAAC,SAAS,CAAC;;AAEjC;AAEA,IAAI,EAAE;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jaypie/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Jaypie MCP server",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Finlayson Studio",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"bin": {
|
|
17
|
+
"jaypie-mcp": "dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rollup --config",
|
|
24
|
+
"format": "eslint . --fix",
|
|
25
|
+
"lint": "eslint .",
|
|
26
|
+
"test": "vitest run .",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.17.0",
|
|
32
|
+
"commander": "^14.0.0",
|
|
33
|
+
"gray-matter": "^4.0.3",
|
|
34
|
+
"zod": "^3.23.8"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"gitHead": "f9017346106103230809370764572ac5e65eae09"
|
|
40
|
+
}
|