create-mcp-kit 0.0.2 → 0.0.4

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 (74) hide show
  1. package/README.md +17 -0
  2. package/dist/index.js +101 -14
  3. package/package.json +4 -2
  4. package/template/{standard-ts/_prettierrc → server-standard-js/.prettierrc.hbs} +2 -0
  5. package/template/{standard-ts/LICENSE → server-standard-js/LICENSE.hbs} +1 -1
  6. package/template/{standard-ts/_github/workflows/build.yml → server-standard-js/_github/workflows/build.yml.hbs} +6 -1
  7. package/template/{standard-ts/_github/workflows/npm-publish.yml → server-standard-js/_github/workflows/npm-publish.yml.hbs} +6 -1
  8. package/template/server-standard-js/_husky/commit-msg.hbs +3 -0
  9. package/template/server-standard-js/_husky/pre-commit.hbs +3 -0
  10. package/template/{standard-ts/changelog-option.js → server-standard-js/changelog-option.js.hbs} +2 -0
  11. package/template/{standard-ts/commitlint.config.js → server-standard-js/commitlint.config.js.hbs} +2 -0
  12. package/template/server-standard-js/eslint.config.js.hbs +48 -0
  13. package/template/server-standard-js/jsconfig.json.hbs +21 -0
  14. package/template/server-standard-js/lint-staged.config.js.hbs +5 -0
  15. package/template/server-standard-js/package.json.hbs +97 -0
  16. package/template/server-standard-js/scripts/base.js.hbs +88 -0
  17. package/template/server-standard-js/src/index.js.hbs +76 -0
  18. package/template/server-standard-js/src/prompts/index.js +27 -0
  19. package/template/server-standard-js/src/resources/index.js +24 -0
  20. package/template/server-standard-js/src/services/index.js.hbs +35 -0
  21. package/template/server-standard-js/src/services/stdio.js.hbs +8 -0
  22. package/template/server-standard-js/src/services/web.js.hbs +105 -0
  23. package/template/server-standard-js/src/tools/index.js +5 -0
  24. package/template/server-standard-js/src/tools/registerGetData.js +38 -0
  25. package/template/server-standard-js/src/utils/index.js +7 -0
  26. package/template/{standard-ts/tests/prompts/index.test.ts → server-standard-js/tests/prompts/index.test.js.hbs} +2 -0
  27. package/template/{standard-ts/tests/resources/index.test.ts → server-standard-js/tests/resources/index.test.js.hbs} +2 -0
  28. package/template/{standard-ts/tests/tools/index.test.ts → server-standard-js/tests/tools/index.test.js.hbs} +2 -0
  29. package/template/server-standard-js/vitest.config.js.hbs +12 -0
  30. package/template/server-standard-js/vitest.setup.js.hbs +21 -0
  31. package/template/server-standard-ts/.env.hbs +1 -0
  32. package/template/server-standard-ts/.gitignore.hbs +112 -0
  33. package/template/server-standard-ts/.nvmrc.hbs +1 -0
  34. package/template/server-standard-ts/.prettierrc.hbs +13 -0
  35. package/template/server-standard-ts/LICENSE.hbs +21 -0
  36. package/template/server-standard-ts/_github/workflows/build.yml.hbs +39 -0
  37. package/template/server-standard-ts/_github/workflows/npm-publish.yml.hbs +41 -0
  38. package/template/server-standard-ts/_husky/commit-msg.hbs +3 -0
  39. package/template/server-standard-ts/_husky/pre-commit.hbs +3 -0
  40. package/template/server-standard-ts/changelog-option.js.hbs +89 -0
  41. package/template/server-standard-ts/commitlint.config.js.hbs +27 -0
  42. package/template/{standard-ts/eslint.config.js → server-standard-ts/eslint.config.js.hbs} +6 -0
  43. package/template/{standard-ts/lint-staged.config.js → server-standard-ts/lint-staged.config.js.hbs} +2 -0
  44. package/template/{standard-ts/package.json → server-standard-ts/package.json.hbs} +49 -12
  45. package/template/{standard-ts/scripts/base.js → server-standard-ts/scripts/base.js.hbs} +9 -3
  46. package/template/server-standard-ts/scripts/build.js.hbs +4 -0
  47. package/template/server-standard-ts/scripts/dev.js.hbs +7 -0
  48. package/template/server-standard-ts/src/constants/index.ts +1 -0
  49. package/template/{standard-ts/src/index.ts → server-standard-ts/src/index.ts.hbs} +28 -2
  50. package/template/{standard-ts → server-standard-ts}/src/prompts/index.ts +1 -1
  51. package/template/{standard-ts → server-standard-ts}/src/resources/index.ts +1 -1
  52. package/template/{standard-ts/src/services/index.ts → server-standard-ts/src/services/index.ts.hbs} +8 -0
  53. package/template/{standard-ts/src/services/stdio.ts → server-standard-ts/src/services/stdio.ts.hbs} +2 -0
  54. package/template/{standard-ts/src/services/web.ts → server-standard-ts/src/services/web.ts.hbs} +20 -3
  55. package/template/server-standard-ts/tests/prompts/index.test.ts.hbs +26 -0
  56. package/template/server-standard-ts/tests/resources/index.test.ts.hbs +20 -0
  57. package/template/server-standard-ts/tests/tools/index.test.ts.hbs +44 -0
  58. package/template/{standard-ts/tests/vitest-global.d.ts → server-standard-ts/tests/vitest-global.d.ts.hbs} +2 -0
  59. package/template/{standard-ts/tsconfig.json → server-standard-ts/tsconfig.json.hbs} +4 -0
  60. package/template/{standard-ts/vitest.config.ts → server-standard-ts/vitest.config.ts.hbs} +2 -0
  61. package/template/{standard-ts/vitest.setup.ts → server-standard-ts/vitest.setup.ts.hbs} +3 -1
  62. package/template/standard-ts/_husky/commit-msg +0 -1
  63. package/template/standard-ts/_husky/pre-commit +0 -1
  64. /package/template/{standard-ts/_env → server-standard-js/.env.hbs} +0 -0
  65. /package/template/{standard-ts/_gitignore → server-standard-js/.gitignore.hbs} +0 -0
  66. /package/template/{standard-ts/_nvmrc → server-standard-js/.nvmrc.hbs} +0 -0
  67. /package/template/{standard-ts/scripts/build.js → server-standard-js/scripts/build.js.hbs} +0 -0
  68. /package/template/{standard-ts/scripts/dev.js → server-standard-js/scripts/dev.js.hbs} +0 -0
  69. /package/template/{standard-ts/src/constants/index.ts → server-standard-js/src/constants/index.js} +0 -0
  70. /package/template/{standard-ts → server-standard-ts}/src/tools/index.ts +0 -0
  71. /package/template/{standard-ts → server-standard-ts}/src/tools/registerGetData.ts +0 -0
  72. /package/template/{standard-ts → server-standard-ts}/src/types/global.ts +0 -0
  73. /package/template/{standard-ts → server-standard-ts}/src/types/index.ts +0 -0
  74. /package/template/{standard-ts → server-standard-ts}/src/utils/index.ts +0 -0
package/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # create-mcp-kit
2
2
  A CLI tool to create MCP (Model Context Protocol) applications with ease.
3
3
 
4
+ [![][npm-release-shield]][npm-release-link]
5
+ [![][codecov-shield]][codecov-link]
6
+ [![][github-release-date-shield]][github-release-date-link]
7
+ [![][github-action-build-shield]][github-action-build-link]
8
+ [![][github-license-shield]][github-license-link]
9
+
4
10
  ## Features
5
11
  - 🚀 Quick project scaffolding
6
12
  - 📦 TypeScript support out of the box
@@ -123,3 +129,14 @@ This project exists thanks to all the people who contribute.
123
129
  ## License
124
130
 
125
131
  [MIT](LICENSE) © MichaelSun
132
+
133
+ [npm-release-link]: https://www.npmjs.com/package/create-mcp-kit
134
+ [npm-release-shield]: https://img.shields.io/npm/v/create-mcp-kit?color=1677FF&labelColor=black&logo=npm&logoColor=white&style=flat-square
135
+ [codecov-link]: https://coveralls.io/github/my-mcp-hub/mcp-kit?branch=main
136
+ [codecov-shield]: https://img.shields.io/coverallsCoverage/github/my-mcp-hub/mcp-kit?color=1677FF&labelColor=black&style=flat-square&logo=codecov&logoColor=white
137
+ [github-release-date-link]: https://github.com/my-mcp-hub/mcp-kit/releases
138
+ [github-release-date-shield]: https://img.shields.io/github/release-date/my-mcp-hub/mcp-kit?color=1677FF&labelColor=black&style=flat-square
139
+ [github-action-build-link]: https://github.com/my-mcp-hub/mcp-kit/actions/workflows/build.yml
140
+ [github-action-build-shield]: https://img.shields.io/github/actions/workflow/status/my-mcp-hub/mcp-kit/build.yml?branch=main&color=1677FF&label=build&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
141
+ [github-license-link]: https://github.com/my-mcp-hub/mcp-kit/blob/main/LICENSE
142
+ [github-license-shield]: https://img.shields.io/github/license/my-mcp-hub/mcp-kit?color=1677FF&labelColor=black&style=flat-square
package/dist/index.js CHANGED
@@ -1,15 +1,32 @@
1
1
  #!/usr/bin/env node
2
- import * as clack from "@clack/prompts";
3
- import pc from "picocolors";
4
2
  import { fileURLToPath } from "url";
5
3
  import { dirname, join, resolve } from "path";
6
- import { stat } from "fs/promises";
7
- import { createProject, installDependencies, sleep } from "@mcp-tool-kit/shared";
4
+ import * as clack from "@clack/prompts";
5
+ import pc from "picocolors";
6
+ import gradient from "gradient-string";
7
+ import { createProject, fileExists, installDependencies, sleep } from "@mcp-tool-kit/shared";
8
8
 
9
9
  //#region src/index.ts
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = dirname(__filename);
12
- clack.intro(pc.inverse(" create-mcp-kit "));
12
+ clack.intro(gradient([
13
+ {
14
+ color: "#a855f7",
15
+ pos: 0
16
+ },
17
+ {
18
+ color: "#3b82f6",
19
+ pos: .4
20
+ },
21
+ {
22
+ color: "#06b6d4",
23
+ pos: .8
24
+ },
25
+ {
26
+ color: "#10b981",
27
+ pos: 1
28
+ }
29
+ ])("MCP Kit - The Modern Context Protocol Builder"));
13
30
  const group = await clack.group({
14
31
  type: () => clack.select({
15
32
  message: "Project type:",
@@ -28,39 +45,109 @@ const group = await clack.group({
28
45
  options: [{
29
46
  value: "ts",
30
47
  label: pc.magenta("TypeScript")
48
+ }, {
49
+ value: "js",
50
+ label: pc.blue("JavaScript")
31
51
  }]
32
52
  }),
33
53
  template: () => clack.select({
34
54
  message: "Project template:",
35
55
  options: [{
36
56
  value: "standard",
37
- label: pc.magenta("Standard")
57
+ label: pc.magenta("Standard (recommended)")
58
+ }, {
59
+ value: "custom",
60
+ label: pc.blue("Custom")
38
61
  }]
39
62
  }),
63
+ transports: () => {
64
+ return clack.multiselect({
65
+ message: "Project Transport Type:",
66
+ required: true,
67
+ initialValues: ["stdio"],
68
+ options: [
69
+ {
70
+ value: "stdio",
71
+ label: pc.magenta("STDIO")
72
+ },
73
+ {
74
+ value: "streamable",
75
+ label: pc.blue("Streamable HTTP")
76
+ },
77
+ {
78
+ value: "sse",
79
+ label: pc.yellow("SSE")
80
+ }
81
+ ]
82
+ });
83
+ },
84
+ plugins: ({ results }) => {
85
+ if (results.template !== "custom") return Promise.resolve([
86
+ "github-action",
87
+ "vitest",
88
+ "inspector",
89
+ "style",
90
+ "commitlint",
91
+ "changelog"
92
+ ]);
93
+ return clack.multiselect({
94
+ message: "Project plugins:",
95
+ required: false,
96
+ options: [
97
+ {
98
+ value: "github-action",
99
+ label: pc.magenta("GitHub Action")
100
+ },
101
+ {
102
+ value: "vitest",
103
+ label: pc.green("Vitest")
104
+ },
105
+ {
106
+ value: "inspector",
107
+ label: pc.blue("Inspector")
108
+ },
109
+ {
110
+ value: "style",
111
+ label: pc.white("ESLint + Prettier + Lint-staged")
112
+ },
113
+ {
114
+ value: "commitlint",
115
+ label: pc.gray("Commitlint")
116
+ },
117
+ {
118
+ value: "changelog",
119
+ label: pc.blueBright("Changelog")
120
+ }
121
+ ]
122
+ });
123
+ },
40
124
  install: () => clack.confirm({ message: "Do you want to install dependencies?" })
41
125
  }, { onCancel: () => {
42
126
  clack.cancel("Operation cancelled.");
43
127
  process.exit(0);
44
128
  } });
45
- const templatePath = join(__dirname, "../template", `${group.template}-${group.language}`);
129
+ const templatePath = join(__dirname, "../template", `${group.type}-${group.template}-${group.language}`);
46
130
  const targetPath = resolve(process.cwd(), group.name);
47
- try {
48
- await stat(templatePath);
49
- } catch {
131
+ if (!await fileExists(templatePath)) {
50
132
  clack.log.error(`Template not found: ${templatePath}`);
51
133
  process.exit(1);
52
134
  }
53
- try {
54
- await stat(targetPath);
135
+ if (await fileExists(targetPath)) {
55
136
  clack.log.error(`Directory ${group.name} already exists`);
56
137
  process.exit(1);
57
- } catch {}
138
+ }
58
139
  {
59
140
  const createSpinner = clack.spinner();
60
141
  createSpinner.start("Creating project...");
61
142
  await sleep(100);
62
143
  try {
63
- await createProject(targetPath, templatePath, { projectName: group.name });
144
+ await createProject(targetPath, templatePath, {
145
+ projectName: group.name,
146
+ year: (/* @__PURE__ */ new Date()).getFullYear().toString(),
147
+ transports: group.transports,
148
+ plugins: group.plugins,
149
+ components: []
150
+ });
64
151
  } catch (error) {
65
152
  createSpinner.stop("Failed to create project");
66
153
  clack.log.error(error.message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mcp-kit",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "create mcp tool kit",
5
5
  "type": "module",
6
6
  "author": "zhensherlock",
@@ -40,8 +40,10 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@clack/prompts": "^0.11.0",
43
+ "gradient-string": "^3.0.0",
44
+ "handlebars": "^4.7.8",
43
45
  "picocolors": "^1.1.1",
44
- "@mcp-tool-kit/shared": "^0.0.3"
46
+ "@mcp-tool-kit/shared": "^0.0.5"
45
47
  },
46
48
  "devDependencies": {
47
49
  "@modelcontextprotocol/sdk": "^1.17.1",
@@ -1,3 +1,4 @@
1
+ {{#if (includes plugins 'style')}}
1
2
  {
2
3
  "tabWidth": 2,
3
4
  "printWidth": 120,
@@ -9,3 +10,4 @@
9
10
  "jsxBracketSameLine": false,
10
11
  "arrowParens": "avoid"
11
12
  }
13
+ {{/if}}
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) {{YEAR}} {{PROJECT_NAME}}
3
+ Copyright (c) {{year}} {{projectName}}
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,3 +1,4 @@
1
+ {{#if (includes plugins 'github-action')}}
1
2
  name: build
2
3
 
3
4
  on:
@@ -7,7 +8,7 @@ on:
7
8
 
8
9
  jobs:
9
10
  build:
10
- if: github.repository == '{{PROJECT_NAME}}'
11
+ if: github.repository == '{{projectName}}'
11
12
  runs-on: ubuntu-latest
12
13
  steps:
13
14
  - name: Checkout
@@ -24,6 +25,9 @@ jobs:
24
25
  - name: Install Package
25
26
  run: npm i
26
27
 
28
+ - name: Lint
29
+ run: npm run lint
30
+
27
31
  - name: Build Package
28
32
  run: npm run build
29
33
 
@@ -32,3 +36,4 @@ jobs:
32
36
 
33
37
  - name: Coveralls
34
38
  uses: coverallsapp/github-action@v2
39
+ {{/if}}
@@ -1,3 +1,4 @@
1
+ {{#if (includes plugins 'github-action')}}
1
2
  name: npm-publish
2
3
 
3
4
  on:
@@ -6,7 +7,7 @@ on:
6
7
 
7
8
  jobs:
8
9
  build:
9
- if: github.repository == '{{PROJECT_NAME}}'
10
+ if: github.repository == '{{projectName}}'
10
11
  runs-on: ubuntu-latest
11
12
  permissions:
12
13
  contents: read
@@ -27,6 +28,9 @@ jobs:
27
28
  - name: Install Package
28
29
  run: npm i
29
30
 
31
+ - name: Lint
32
+ run: npm run lint
33
+
30
34
  - name: Build Package
31
35
  run: npm run build
32
36
 
@@ -34,3 +38,4 @@ jobs:
34
38
  run: npm publish --provenance --access public
35
39
  env:
36
40
  NODE_AUTH_TOKEN: ${{secrets.npm_token}}
41
+ {{/if}}
@@ -0,0 +1,3 @@
1
+ {{#if (includes plugins 'commitlint')}}
2
+ npx --no-install commitlint --edit $1
3
+ {{/if}}
@@ -0,0 +1,3 @@
1
+ {{#if (includes plugins 'style')}}
2
+ npx lint-staged
3
+ {{/if}}
@@ -1,3 +1,4 @@
1
+ {{#if (includes plugins 'changelog')}}
1
2
  import compareFunc from 'compare-func'
2
3
 
3
4
  export default {
@@ -85,3 +86,4 @@ export default {
85
86
  notesSort: compareFunc,
86
87
  },
87
88
  }
89
+ {{/if}}
@@ -1,3 +1,4 @@
1
+ {{#if (includes plugins 'commitlint')}}
1
2
  export default {
2
3
  extends: ['@commitlint/config-conventional'],
3
4
  rules: {
@@ -23,3 +24,4 @@ export default {
23
24
  'subject-case': [0],
24
25
  },
25
26
  }
27
+ {{/if}}
@@ -0,0 +1,48 @@
1
+ {{#if (includes plugins 'style')}}
2
+ import importPlugin from 'eslint-plugin-import'
3
+ import prettierPlugin from 'eslint-plugin-prettier'
4
+ import globals from 'globals'
5
+
6
+ export default [
7
+ {
8
+ ignores: ['**/build', '**/node_modules', '**/.*', '.husky/'],
9
+ },
10
+ {
11
+ {{#if (includes plugins 'vitest')}}
12
+ files: ['src/**/*.js', 'tests/**/*.js'],
13
+ {{else}}
14
+ files: ['src/**/*.js'],
15
+ {{/if}}
16
+ },
17
+ {
18
+ languageOptions: {
19
+ parserOptions: {
20
+ ecmaVersion: 'latest',
21
+ sourceType: 'module',
22
+ },
23
+ globals: {
24
+ ...globals.es2022,
25
+ ...globals.node,
26
+ },
27
+ },
28
+ plugins: {
29
+ import: importPlugin,
30
+ prettier: prettierPlugin,
31
+ },
32
+ rules: {
33
+ 'prettier/prettier': 'error',
34
+ 'no-console': 'off',
35
+ semi: ['warn', 'never'],
36
+ quotes: ['warn', 'single'],
37
+ 'no-unused-vars': 'off',
38
+ },
39
+ settings: {
40
+ 'import/resolver': {
41
+ node: {
42
+ extensions: ['.js'],
43
+ },
44
+ },
45
+ },
46
+ },
47
+ ]
48
+ {{/if}}
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "outDir": "./build",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "paths": {
12
+ "@/*": ["./src/*"]
13
+ }
14
+ },
15
+ {{#if (includes plugins 'vitest')}}
16
+ "include": ["src", "tests", "vitest.setup.js", "vitest.config.js"],
17
+ {{else}}
18
+ "include": ["src"],
19
+ {{/if}}
20
+ "exclude": ["node_modules"]
21
+ }
@@ -0,0 +1,5 @@
1
+ {{#if (includes plugins 'style')}}
2
+ export default {
3
+ 'src/**/*.js': ['npx eslint'],
4
+ }
5
+ {{/if}}
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "{{projectName}}",
3
+ "version": "0.0.0",
4
+ "description": "{{projectName}}",
5
+ "author": "zhensherlock",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "bin": {
9
+ "{{projectName}}": "./build/index.js"
10
+ },
11
+ "files": [
12
+ "build",
13
+ "LICENSE",
14
+ "README.md"
15
+ ],
16
+ "main": "build/index.js",
17
+ "scripts": {
18
+ {{#if (includes plugins 'style')}}
19
+ "lint": "npx eslint \"src/**/*.js\"",
20
+ {{/if}}
21
+ "build": "cross-env NODE_ENV=production node scripts/build.js",
22
+ {{#if (and (includes transports 'stdio') (or (includes transports 'streamable') (includes transports 'sse')))}}
23
+ "dev": "npm run dev:stdio",
24
+ "dev:stdio": "cross-env NODE_ENV=local node scripts/dev.js",
25
+ {{else if (includes transports 'web')}}
26
+ "dev": "npm run dev:stdio",
27
+ "dev:stdio": "cross-env NODE_ENV=local node scripts/dev.js",
28
+ {{else}}
29
+ "dev": "npm run dev:web",
30
+ "dev:web": "cross-env NODE_ENV=local TRANSPORT=web node scripts/dev.js",
31
+ {{/if}}
32
+ {{#if (includes plugins 'vitest')}}
33
+ "test": "vitest run",
34
+ "coverage": "rimraf coverage && npm run test && c8 report --reporter=lcov --reporter=html",
35
+ {{/if}}
36
+ {{#if (includes plugins 'changelog')}}
37
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 -n changelog-option.js",
38
+ {{/if}}
39
+ "prepare": "husky"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.17.1",
43
+ "dotenv": "^17.2.1",
44
+ {{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
45
+ "express": "^5.1.0",
46
+ "nanoid": "^5.1.5",
47
+ {{/if}}
48
+ "yargs": "^17.7.2",
49
+ "zod": "^3.25.76"
50
+ },
51
+ "devDependencies": {
52
+ {{#if (includes plugins 'commitlint')}}
53
+ "@commitlint/cli": "^19.8.1",
54
+ "@commitlint/config-conventional": "^19.8.1",
55
+ {{/if}}
56
+ {{#if (includes plugins 'inspector')}}
57
+ "@modelcontextprotocol/inspector": "^0.16.2",
58
+ {{/if}}
59
+ {{#if (includes plugins 'vitest')}}
60
+ "@vitest/coverage-v8": "^3.2.4",
61
+ "c8": "^10.1.3",
62
+ {{/if}}
63
+ {{#if (includes plugins 'changelog')}}
64
+ "compare-func": "^2.0.0",
65
+ {{/if}}
66
+ "concurrently": "^9.2.0",
67
+ {{#if (includes plugins 'changelog')}}
68
+ "conventional-changelog-angular": "^8.0.0",
69
+ "conventional-changelog-cli": "^5.0.0",
70
+ {{/if}}
71
+ "cross-env": "^10.0.0",
72
+ "esbuild": "^0.25.8",
73
+ {{#if (includes plugins 'style')}}
74
+ "eslint": "^9.32.0",
75
+ "eslint-plugin-import": "^2.32.0",
76
+ "eslint-plugin-prettier": "^5.5.3",
77
+ "globals": "^16.3.0",
78
+ {{/if}}
79
+ "husky": "^9.1.7",
80
+ {{#if (includes plugins 'style')}}
81
+ "lint-staged": "^16.1.4",
82
+ {{/if}}
83
+ {{#if (includes plugins 'vitest')}}
84
+ "nyc": "^17.1.0",
85
+ {{/if}}
86
+ {{#if (includes plugins 'style')}}
87
+ "prettier": "^3.6.2",
88
+ {{/if}}
89
+ {{#if (includes plugins 'inspector')}}
90
+ "tree-kill": "^1.2.2",
91
+ {{/if}}
92
+ {{#if (includes plugins 'vitest')}}
93
+ "vitest": "^3.2.4",
94
+ {{/if}}
95
+ "rimraf": "^6.0.1"
96
+ }
97
+ }
@@ -0,0 +1,88 @@
1
+ import path from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { promises as fs } from 'fs'
4
+ {{#if (includes plugins 'inspector')}}
5
+ import { spawn } from 'child_process'
6
+ {{/if}}
7
+ import { rimraf } from 'rimraf'
8
+ {{#if (includes plugins 'inspector')}}
9
+ import kill from 'tree-kill'
10
+ {{/if}}
11
+
12
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
13
+ const isProd = process.env.NODE_ENV === 'production'
14
+ const isDev = process.env.NODE_ENV === 'local'
15
+ {{#if (includes plugins 'inspector')}}
16
+ let inspectorProcess = null
17
+ let webProcess = null
18
+ let autoOpenBrowser = true
19
+ {{/if}}
20
+
21
+ /** @type {import('esbuild').BuildOptions} */
22
+ export const config = {
23
+ entryPoints: [path.resolve(__dirname, '../src/index.js')],
24
+ outfile: path.resolve(__dirname, '../build/index.js'),
25
+ format: 'esm',
26
+ bundle: true,
27
+ sourcemap: isDev,
28
+ minify: isProd,
29
+ platform: 'node',
30
+ external: ['yargs', 'express', 'nanoid', 'zod', 'dotenv', '@modelcontextprotocol/sdk'],
31
+ alias: {
32
+ '@': path.resolve(__dirname, '../src'),
33
+ },
34
+ plugins: [
35
+ {
36
+ name: 'build-plugin',
37
+ setup(build) {
38
+ build.onStart(async result => {
39
+ await before(result)
40
+ })
41
+ build.onEnd(async result => {
42
+ await after(result)
43
+ })
44
+ },
45
+ },
46
+ ],
47
+ }
48
+
49
+ const before = async () => {
50
+ await rimraf('build')
51
+ }
52
+
53
+ const after = async result => {
54
+ await fs.chmod('build/index.js', 0o755)
55
+ console.log('✅ chmod 755 build/index.js done')
56
+ if (isDev) {
57
+ if (result.errors.length === 0) {
58
+ console.log('✅ Rebuild succeeded')
59
+ } else {
60
+ console.error('❌ Rebuild failed')
61
+ }
62
+ {{#if (includes plugins 'inspector')}}
63
+ console.log('🚀 Starting @modelcontextprotocol/inspector...')
64
+ if (inspectorProcess) {
65
+ kill(inspectorProcess.pid, 'SIGINT')
66
+ }
67
+ inspectorProcess = spawn('npx', ['@modelcontextprotocol/inspector', 'build/index.js'], {
68
+ stdio: 'inherit',
69
+ shell: true,
70
+ env: {
71
+ ...process.env,
72
+ DANGEROUSLY_OMIT_AUTH: true,
73
+ MCP_AUTO_OPEN_ENABLED: autoOpenBrowser,
74
+ },
75
+ })
76
+ autoOpenBrowser = false
77
+
78
+ if (process.env.TRANSPORT === 'web') {
79
+ if (webProcess) {
80
+ webProcess.kill('SIGINT')
81
+ }
82
+ webProcess = spawn('node', ['build/index.js', 'web'], {
83
+ stdio: 'inherit',
84
+ })
85
+ }
86
+ {{/if}}
87
+ }
88
+ }
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ import yargs from 'yargs'
3
+ import { hideBin } from 'yargs/helpers'
4
+ {{#if (and (includes transports 'stdio') (or (includes transports 'streamable') (includes transports 'sse')))}}
5
+ import { startWebServer, startStdioServer } from './services/index.js'
6
+ {{else if (includes transports 'stdio')}}
7
+ import { startStdioServer } from './services/index.js'
8
+ {{else}}
9
+ import { startWebServer } from './services/index.js'
10
+ {{/if}}
11
+ import { getOptions } from './utils/index.js'
12
+ import 'dotenv/config'
13
+ import pkg from '../package.json' with { type: 'json' }
14
+
15
+ const name = '{{projectName}}'
16
+
17
+ const argv = await yargs()
18
+ .scriptName(name)
19
+ .usage('$0 <command> [options]')
20
+ {{#if (includes transports 'stdio')}}
21
+ .command(
22
+ 'stdio',
23
+ 'Start the server using the stdio transport protocol.',
24
+ () => {},
25
+ argv => startServer('stdio', argv),
26
+ )
27
+ {{/if}}
28
+ {{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
29
+ .command(
30
+ 'web',
31
+ 'Start the web server transport protocol.',
32
+ () => {},
33
+ argv => startServer('web', argv),
34
+ )
35
+ {{/if}}
36
+ {{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
37
+ .options({
38
+ port: {
39
+ describe: 'Specify the port for SSE or streamable transport (default: 8401)',
40
+ type: 'string',
41
+ default: process.env.PORT || '8401',
42
+ },
43
+ })
44
+ {{/if}}
45
+ .help()
46
+ .parse(hideBin(process.argv))
47
+
48
+ if (!argv._[0]) {
49
+ {{#if (includes transports 'stdio')}}
50
+ startServer('stdio', argv)
51
+ {{else}}
52
+ startServer('web', argv)
53
+ {{/if}}
54
+ }
55
+
56
+ async function startServer(mode, argv) {
57
+ const options = getOptions(argv, {
58
+ name,
59
+ version: pkg.version,
60
+ })
61
+ {{#if (and (includes transports 'stdio') (or (includes transports 'streamable') (includes transports 'sse')))}}
62
+ if (mode === 'stdio') {
63
+ startStdioServer(options).catch(console.error)
64
+ } else if (mode === 'web') {
65
+ startWebServer(options).catch(console.error)
66
+ }
67
+ {{else if (includes transports 'stdio')}}
68
+ if (mode === 'stdio') {
69
+ startStdioServer(options).catch(console.error)
70
+ }
71
+ {{else}}
72
+ if (mode === 'web') {
73
+ startWebServer(options).catch(console.error)
74
+ }
75
+ {{/if}}
76
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod'
2
+
3
+ export const registerPrompts = server => {
4
+ server.registerPrompt(
5
+ 'echo',
6
+ {
7
+ title: 'Echo Prompt',
8
+ description: 'Creates a prompt to process a message.',
9
+ argsSchema: {
10
+ message: z.string(),
11
+ },
12
+ },
13
+ ({ message }) => {
14
+ return {
15
+ messages: [
16
+ {
17
+ role: 'user',
18
+ content: {
19
+ type: 'text',
20
+ text: `Please process this message: ${message}`,
21
+ },
22
+ },
23
+ ],
24
+ }
25
+ },
26
+ )
27
+ }