create-mcp-kit 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/dist/index.js CHANGED
@@ -1,3 +1,87 @@
1
1
  #!/usr/bin/env node
2
- import*as e from"@clack/prompts";import t from"picocolors";import{fileURLToPath as r}from"url";import a,{dirname as n,join as o,resolve as s}from"path";import{cp as i,mkdir as c,readFile as p,readdir as l,rename as m,stat as g,writeFile as u}from"fs/promises";import{setTimeout as d}from"timers/promises";import{spawn as f}from"child_process";const w=n(r(import.meta.url));e.intro(t.inverse(" create-mcp-kit "));const y=await e.group({type:()=>e.select({message:"Project type:",options:[{value:"server",label:t.magenta("MCP Server")}]}),name:({results:t})=>e.text({message:"Project name:",defaultValue:`mcp-${t.type}-starter`,placeholder:`mcp-${t.type}-starter`}),language:()=>e.select({message:"Project language:",options:[{value:"ts",label:t.magenta("TypeScript")}]}),template:()=>e.select({message:"Project template:",options:[{value:"standard",label:t.magenta("Standard")}]}),install:()=>e.confirm({message:"Do you want to install dependencies?"})},{onCancel:()=>{e.cancel("Operation cancelled."),process.exit(0)}}),v=o(w,"../template",`${y.template}-${y.language}`),j=s(process.cwd(),y.name);try{await g(v)}catch{e.log.error(`Template not found: ${v}`),process.exit(1)}try{await g(j),e.log.error(`Directory ${y.name} already exists`),process.exit(1)}catch{}{const r=e.spinner();r.start("Creating project..."),await d(100);try{await async function(e,t,r){await c(e,{recursive:!0}),await i(t,e,{recursive:!0}),await async function(e){const t={_env:".env",_gitignore:".gitignore",_git:".git",_nvmrc:".nvmrc",_prettierrc:".prettierrc",_husky:".husky",_github:".github"},r=await l(e,{recursive:!0});for(const n of r)n in t&&await m(a.join(e,n),a.join(e,t[n]))}(e),await async function(e,t){const r={"{{PROJECT_NAME}}":t.projectName,"{{YEAR}}":(new Date).getFullYear().toString()},n=await l(e,{recursive:!0});for(const t of n){const n=a.join(e,t);if(!(await g(n)).isDirectory())for(const[e,t]of Object.entries(r)){const r=await p(n,"utf-8"),a=new RegExp(e,"g"),o=r.replace(a,t);await u(n,o,"utf-8")}}}(e,r)}(j,v,{projectName:y.name})}catch(t){r.stop("Failed to create project"),e.log.error(t.message),process.exit(1)}r.stop(t.green("Project created!"))}if(y.install){const r=e.spinner();r.start("Installing dependencies..."),await($=j,new Promise((e,t)=>{const r=f("npm",["install"],{cwd:$,stdio:"pipe"});r.on("close",r=>{0===r?e():t(new Error(`npm install failed with code ${r}`))}),r.on("error",t)})),r.stop(t.green("Dependencies installed!"))}var $;e.outro(`\n${t.green("✓")} Project created successfully!\n\n${t.cyan("Next steps:")}\n ${t.dim("cd")} ${y.name}\n ${t.dim("npm install")}\n ${t.dim("npm run dev")}\n\nEnjoy coding! 🎉\n `);
3
- //# sourceMappingURL=index.js.map
2
+ import * as clack from "@clack/prompts";
3
+ import pc from "picocolors";
4
+ import { fileURLToPath } from "url";
5
+ import { dirname, join, resolve } from "path";
6
+ import { stat } from "fs/promises";
7
+ import { createProject, installDependencies, sleep } from "@mcp-tool-kit/shared";
8
+
9
+ //#region src/index.ts
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
12
+ clack.intro(pc.inverse(" create-mcp-kit "));
13
+ const group = await clack.group({
14
+ type: () => clack.select({
15
+ message: "Project type:",
16
+ options: [{
17
+ value: "server",
18
+ label: pc.magenta("MCP Server")
19
+ }]
20
+ }),
21
+ name: ({ results }) => clack.text({
22
+ message: "Project name:",
23
+ defaultValue: `mcp-${results.type}-starter`,
24
+ placeholder: `mcp-${results.type}-starter`
25
+ }),
26
+ language: () => clack.select({
27
+ message: "Project language:",
28
+ options: [{
29
+ value: "ts",
30
+ label: pc.magenta("TypeScript")
31
+ }]
32
+ }),
33
+ template: () => clack.select({
34
+ message: "Project template:",
35
+ options: [{
36
+ value: "standard",
37
+ label: pc.magenta("Standard")
38
+ }]
39
+ }),
40
+ install: () => clack.confirm({ message: "Do you want to install dependencies?" })
41
+ }, { onCancel: () => {
42
+ clack.cancel("Operation cancelled.");
43
+ process.exit(0);
44
+ } });
45
+ const templatePath = join(__dirname, "../template", `${group.template}-${group.language}`);
46
+ const targetPath = resolve(process.cwd(), group.name);
47
+ try {
48
+ await stat(templatePath);
49
+ } catch {
50
+ clack.log.error(`Template not found: ${templatePath}`);
51
+ process.exit(1);
52
+ }
53
+ try {
54
+ await stat(targetPath);
55
+ clack.log.error(`Directory ${group.name} already exists`);
56
+ process.exit(1);
57
+ } catch {}
58
+ {
59
+ const createSpinner = clack.spinner();
60
+ createSpinner.start("Creating project...");
61
+ await sleep(100);
62
+ try {
63
+ await createProject(targetPath, templatePath, { projectName: group.name });
64
+ } catch (error) {
65
+ createSpinner.stop("Failed to create project");
66
+ clack.log.error(error.message);
67
+ process.exit(1);
68
+ }
69
+ createSpinner.stop(pc.green("Project created!"));
70
+ }
71
+ if (group.install) {
72
+ const spinner = clack.spinner();
73
+ spinner.start("Installing dependencies...");
74
+ await installDependencies(targetPath);
75
+ spinner.stop(pc.green("Dependencies installed!"));
76
+ }
77
+ clack.outro(`
78
+ ${pc.green("✓")} Project created successfully!
79
+
80
+ ${pc.cyan("Next steps:")}
81
+ ${pc.dim("cd")} ${group.name}
82
+ ${group.install ? "" : `${pc.dim("npm install")}\n `}${pc.dim("npm run dev")}
83
+
84
+ Enjoy coding! 🎉
85
+ `);
86
+
87
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mcp-kit",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "create mcp tool kit",
5
5
  "type": "module",
6
6
  "author": "zhensherlock",
@@ -41,10 +41,10 @@
41
41
  "dependencies": {
42
42
  "@clack/prompts": "^0.11.0",
43
43
  "picocolors": "^1.1.1",
44
- "@mcp-tool-kit/shared": "^0.0.2"
44
+ "@mcp-tool-kit/shared": "^0.0.3"
45
45
  },
46
46
  "devDependencies": {
47
- "@modelcontextprotocol/sdk": "^1.17.0",
47
+ "@modelcontextprotocol/sdk": "^1.17.1",
48
48
  "@types/express": "^5.0.3",
49
49
  "@types/yargs": "^17.0.33",
50
50
  "express": "^5.1.0",
@@ -55,8 +55,8 @@
55
55
  "scripts": {
56
56
  "clean:dist": "rimraf dist",
57
57
  "build:types": "tsc --noEmit",
58
- "build": "npm run clean:dist && npm run build:types && rolldown -c rolldown.config.ts",
59
- "dev": "rolldown -c rolldown.config.ts --watch",
58
+ "build": "cross-env NODE_ENV=production && npm run clean:dist && npm run build:types && rolldown -c rolldown.config.ts",
59
+ "dev": "cross-env NODE_ENV=local && rolldown -c rolldown.config.ts --watch",
60
60
  "start": "node ./dist/index.js"
61
61
  }
62
62
  }
@@ -1,27 +1,25 @@
1
1
  export default {
2
2
  extends: ['@commitlint/config-conventional'],
3
3
  rules: {
4
- // type 类型定义,表示 git 提交的 type 必须在以下类型范围内
5
4
  'type-enum': [
6
5
  2,
7
6
  'always',
8
7
  [
9
- 'feat', // 新功能
10
- 'fix', // 修复
11
- 'docs', // 文档变更
12
- 'style', // 代码格式
13
- 'refactor', // 重构
14
- 'perf', // 性能优化
15
- 'test', // 增加测试
16
- 'build', // 构建
17
- 'ci', // CI配置
18
- 'chore', // 构建过程或辅助工具的变动
19
- 'revert', // 回退
20
- 'build', // 打包
21
- 'release', // 发版
8
+ 'feat',
9
+ 'fix',
10
+ 'docs',
11
+ 'style',
12
+ 'refactor',
13
+ 'perf',
14
+ 'test',
15
+ 'build',
16
+ 'ci',
17
+ 'chore',
18
+ 'revert',
19
+ 'build',
20
+ 'release',
22
21
  ],
23
22
  ],
24
- // subject 大小写不做校验
25
23
  'subject-case': [0],
26
24
  },
27
25
  }
@@ -26,7 +26,7 @@
26
26
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 -n changelog-option.js"
27
27
  },
28
28
  "dependencies": {
29
- "@modelcontextprotocol/sdk": "^1.17.0",
29
+ "@modelcontextprotocol/sdk": "^1.17.1",
30
30
  "cors": "^2.8.5",
31
31
  "dotenv": "^17.2.1",
32
32
  "express": "^5.1.0",
@@ -41,7 +41,7 @@
41
41
  "@modelcontextprotocol/inspector": "^0.16.2",
42
42
  "@types/cors": "^2.8.19",
43
43
  "@types/express": "^5.0.3",
44
- "@types/node-fetch": "^2.6.12",
44
+ "@types/node-fetch": "^2.6.13",
45
45
  "@types/yargs": "^17.0.33",
46
46
  "@typescript-eslint/eslint-plugin": "^8.38.0",
47
47
  "@typescript-eslint/parser": "^8.38.0",
@@ -51,7 +51,7 @@
51
51
  "concurrently": "^9.2.0",
52
52
  "conventional-changelog-angular": "^8.0.0",
53
53
  "conventional-changelog-cli": "^5.0.0",
54
- "cross-env": "^7.0.3",
54
+ "cross-env": "^10.0.0",
55
55
  "esbuild": "^0.25.8",
56
56
  "eslint": "^9.32.0",
57
57
  "eslint-plugin-import": "^2.32.0",
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["t","m","i","r","n"],"sources":["../../shared/dist/projectSetup.js","../src/index.ts"],"sourcesContent":["import{setTimeout as t}from\"timers/promises\";import{cp as i,mkdir as r,readFile as o,readdir as e,rename as n,stat as s,writeFile as a}from\"fs/promises\";import c from\"path\";import{spawn as f}from\"child_process\";function m(t){return new Promise((i,r)=>{const o=f(\"npm\",[\"install\"],{cwd:t,stdio:\"pipe\"});o.on(\"close\",t=>{0===t?i():r(new Error(`npm install failed with code ${t}`))}),o.on(\"error\",r)})}async function p(t,f,m){await r(t,{recursive:!0}),await i(f,t,{recursive:!0}),await async function(t){const i={_env:\".env\",_gitignore:\".gitignore\",_git:\".git\",_nvmrc:\".nvmrc\",_prettierrc:\".prettierrc\",_husky:\".husky\",_github:\".github\"},r=await e(t,{recursive:!0});for(const o of r)o in i&&await n(c.join(t,o),c.join(t,i[o]))}(t),await async function(t,i){const r={\"{{PROJECT_NAME}}\":i.projectName,\"{{YEAR}}\":(new Date).getFullYear().toString()},n=await e(t,{recursive:!0});for(const i of n){const e=c.join(t,i);if(!(await s(e)).isDirectory())for(const[t,i]of Object.entries(r)){const r=await o(e,\"utf-8\"),n=new RegExp(t,\"g\"),s=r.replace(n,i);await a(e,s,\"utf-8\")}}}(t,m)}export{p as createProject,m as installDependencies,t as sleep};\n//# sourceMappingURL=projectSetup.js.map","#!/usr/bin/env node\nimport * as clack from '@clack/prompts'\nimport pc from 'picocolors'\nimport { fileURLToPath } from 'url'\nimport { dirname, join, resolve } from 'path'\nimport { stat } from 'fs/promises'\nimport { sleep, createProject, installDependencies } from '@mcp-tool-kit/shared'\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = dirname(__filename)\nclack.intro(pc.inverse(' create-mcp-kit '))\n\nconst group = await clack.group(\n {\n type: () =>\n clack.select({\n message: 'Project type:',\n options: [\n { value: 'server', label: pc.magenta('MCP Server') },\n // { value: 'client', label: pc.blue('MCP Client') },\n // { value: 'host', label: pc.green('MCP Host') },\n ],\n }),\n name: ({ results }) =>\n clack.text({\n message: 'Project name:',\n defaultValue: `mcp-${results.type}-starter`,\n placeholder: `mcp-${results.type}-starter`,\n }),\n language: () =>\n clack.select({\n message: 'Project language:',\n options: [\n { value: 'ts', label: pc.magenta('TypeScript') },\n // { value: 'js', label: pc.blue('JavaScript') },\n ],\n }),\n template: () =>\n clack.select({\n message: 'Project template:',\n options: [\n { value: 'standard', label: pc.magenta('Standard') },\n // { value: 'custom', label: pc.blue('Custom') },\n ],\n }),\n install: () =>\n clack.confirm({\n message: 'Do you want to install dependencies?',\n }),\n },\n {\n onCancel: () => {\n clack.cancel('Operation cancelled.')\n process.exit(0)\n },\n },\n)\n\nconst templatePath = join(__dirname, '../template', `${group.template}-${group.language}`)\nconst targetPath = resolve(process.cwd(), group.name as string)\n\ntry {\n await stat(templatePath)\n} catch {\n clack.log.error(`Template not found: ${templatePath}`)\n process.exit(1)\n}\n\ntry {\n await stat(targetPath)\n clack.log.error(`Directory ${group.name} already exists`)\n process.exit(1)\n} catch {}\n\n{\n const createSpinner = clack.spinner()\n createSpinner.start('Creating project...')\n await sleep(100)\n try {\n await createProject(targetPath, templatePath, {\n projectName: group.name as string,\n })\n } catch (error) {\n createSpinner.stop('Failed to create project')\n clack.log.error((error as Error).message)\n process.exit(1)\n }\n createSpinner.stop(pc.green('Project created!'))\n}\n\nif (group.install) {\n const spinner = clack.spinner()\n spinner.start('Installing dependencies...')\n await installDependencies(targetPath)\n spinner.stop(pc.green('Dependencies installed!'))\n}\n\nclack.outro(`\n${pc.green('✓')} Project created successfully!\n\n${pc.cyan('Next steps:')}\n ${pc.dim('cd')} ${group.name}\n ${pc.dim('npm install')}\n ${pc.dim('npm run dev')}\n\nEnjoy coding! 🎉\n `)\n"],"mappings":";uVCQA,MACM,EAAY,EADC,cAA0B,MAE7C,EAAM,MAAM,EAAG,QAAQ,qBAEvB,MAAM,QAAc,EAAM,MACxB,CACE,KAAM,IACJ,EAAM,OAAO,CACX,QAAS,gBACT,QAAS,CACP,CAAE,MAAO,SAAU,MAAO,EAAG,QAAQ,kBAK3C,KAAM,EAAG,aACP,EAAM,KAAK,CACT,QAAS,gBACT,aAAc,OAAO,EAAQ,eAC7B,YAAa,OAAO,EAAQ,iBAEhC,SAAU,IACR,EAAM,OAAO,CACX,QAAS,oBACT,QAAS,CACP,CAAE,MAAO,KAAM,MAAO,EAAG,QAAQ,kBAIvC,SAAU,IACR,EAAM,OAAO,CACX,QAAS,oBACT,QAAS,CACP,CAAE,MAAO,WAAY,MAAO,EAAG,QAAQ,gBAI7C,QAAS,IACP,EAAM,QAAQ,CACZ,QAAS,0CAGf,CACE,SAAU,KACR,EAAM,OAAO,wBACb,QAAQ,KAAK,MAKb,EAAe,EAAK,EAAW,cAAe,GAAG,EAAM,YAAY,EAAM,YACzE,EAAa,EAAQ,QAAQ,MAAO,EAAM,MAEhD,UACQ,EAAK,EACZ,CAAA,MACC,EAAM,IAAI,MAAM,uBAAuB,KACvC,QAAQ,KAAK,EACd,CAED,UACQ,EAAK,GACX,EAAM,IAAI,MAAM,aAAa,EAAM,uBACnC,QAAQ,KA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