Skip to content

Commit 6615c9b

Browse files
committed
feat: update server-standard-js template
1 parent b16f5a6 commit 6615c9b

File tree

14 files changed

+77
-12
lines changed

14 files changed

+77
-12
lines changed

.changeset/lovely-peaches-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-mcp-kit': patch
3+
---
4+
5+
feat: update server-standard-js template

packages/create-mcp-kit/template/server-standard-js/LICENSE renamed to packages/create-mcp-kit/template/server-standard-js/LICENSE.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) {{YEAR}} {{PROJECT_NAME}}
3+
Copyright (c) {{year}} {{projectName}}
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

packages/create-mcp-kit/template/server-standard-js/_github/workflows/build.yml renamed to packages/create-mcp-kit/template/server-standard-js/_github/workflows/build.yml.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
build:
10-
if: github.repository == '{{PROJECT_NAME}}'
10+
if: github.repository == '{{projectName}}'
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout

packages/create-mcp-kit/template/server-standard-js/_github/workflows/npm-publish.yml renamed to packages/create-mcp-kit/template/server-standard-js/_github/workflows/npm-publish.yml.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
build:
9-
if: github.repository == '{{PROJECT_NAME}}'
9+
if: github.repository == '{{projectName}}'
1010
runs-on: ubuntu-latest
1111
permissions:
1212
contents: read

packages/create-mcp-kit/template/server-standard-js/package.json renamed to packages/create-mcp-kit/template/server-standard-js/package.json.hbs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "{{PROJECT_NAME}}",
2+
"name": "{{projectName}}",
33
"version": "0.0.0",
4-
"description": "{{PROJECT_NAME}}",
4+
"description": "{{projectName}}",
55
"author": "zhensherlock",
66
"type": "module",
77
"license": "MIT",
88
"bin": {
9-
"{{PROJECT_NAME}}": "./build/index.js"
9+
"{{projectName}}": "./build/index.js"
1010
},
1111
"files": [
1212
"build",
@@ -18,20 +18,27 @@
1818
"prepare": "husky",
1919
"lint": "npx eslint \"src/**/*.js\"",
2020
"build": "cross-env NODE_ENV=production node scripts/build.js",
21+
{{#if (and (includes transports 'stdio') (or (includes transports 'streamable') (includes transports 'sse')))}}
2122
"dev": "npm run dev:stdio",
2223
"dev:stdio": "cross-env NODE_ENV=local node scripts/dev.js",
24+
{{else if (includes transports 'web')}}
25+
"dev": "npm run dev:stdio",
26+
"dev:stdio": "cross-env NODE_ENV=local node scripts/dev.js",
27+
{{else}}
28+
"dev": "npm run dev:web",
2329
"dev:web": "cross-env NODE_ENV=local TRANSPORT=web node scripts/dev.js",
30+
{{/if}}
2431
"test": "vitest run",
2532
"coverage": "rimraf coverage && npm run test && c8 report --reporter=lcov --reporter=html",
2633
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 -n changelog-option.js"
2734
},
2835
"dependencies": {
2936
"@modelcontextprotocol/sdk": "^1.17.1",
30-
"cors": "^2.8.5",
3137
"dotenv": "^17.2.1",
38+
{{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
3239
"express": "^5.1.0",
3340
"nanoid": "^5.1.5",
34-
"node-fetch": "^3.3.2",
41+
{{/if}}
3542
"yargs": "^17.7.2",
3643
"zod": "^3.25.76"
3744
},

packages/create-mcp-kit/template/server-standard-js/src/index.js renamed to packages/create-mcp-kit/template/server-standard-js/src/index.js.hbs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
#!/usr/bin/env node
22
import yargs from 'yargs'
33
import { hideBin } from 'yargs/helpers'
4+
{{#if (and (includes transports 'stdio') (or (includes transports 'streamable') (includes transports 'sse')))}}
45
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}}
511
import { getOptions } from './utils/index.js'
612
import 'dotenv/config'
713
import pkg from '../package.json' with { type: 'json' }
@@ -11,40 +17,60 @@ const name = 'node-mcp-server'
1117
const argv = await yargs()
1218
.scriptName(name)
1319
.usage('$0 <command> [options]')
20+
{{#if (includes transports 'stdio')}}
1421
.command(
1522
'stdio',
1623
'Start the server using the stdio transport protocol.',
1724
() => {},
1825
argv => startServer('stdio', argv),
1926
)
27+
{{/if}}
28+
{{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
2029
.command(
2130
'web',
2231
'Start the web server transport protocol.',
2332
() => {},
2433
argv => startServer('web', argv),
2534
)
35+
{{/if}}
36+
{{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
2637
.options({
2738
port: {
2839
describe: 'Specify the port for SSE or streamable transport (default: 8401)',
2940
type: 'string',
3041
default: process.env.PORT || '8401',
3142
},
3243
})
44+
{{/if}}
3345
.help()
3446
.parse(hideBin(process.argv))
3547

3648
if (!argv._[0]) {
49+
{{#if (includes transports 'stdio')}}
3750
startServer('stdio', argv)
51+
{{else}}
52+
startServer('web', argv)
53+
{{/if}}
3854
}
3955

4056
async function startServer(mode, argv) {
4157
const options = getOptions(argv, {
4258
name,
4359
version: pkg.version,
4460
})
61+
{{#if (and (includes transports 'stdio') (or (includes transports 'streamable') (includes transports 'sse')))}}
4562
if (mode === 'stdio') {
4663
startStdioServer(options).catch(console.error)
4764
} else if (mode === 'web') {
4865
startWebServer(options).catch(console.error)
4966
}
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}}
5076
}

0 commit comments

Comments
 (0)