create-mctx-server 0.3.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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/index.js +136 -0
  3. package/package.json +30 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mctx
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/index.js ADDED
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env node
2
+ import { mkdirSync, writeFileSync, existsSync, readFileSync } from "fs";
3
+ import { join } from "path";
4
+
5
+ // Read version from own package.json
6
+ const selfPkg = JSON.parse(
7
+ readFileSync(new URL("./package.json", import.meta.url), "utf8"),
8
+ );
9
+ const version = selfPkg.version;
10
+
11
+ const projectName = process.argv[2];
12
+
13
+ if (!projectName) {
14
+ console.error("Usage: npm create mctx-server <project-name>");
15
+ process.exit(1);
16
+ }
17
+
18
+ if (existsSync(projectName)) {
19
+ console.error(`Error: Directory "${projectName}" already exists`);
20
+ process.exit(1);
21
+ }
22
+
23
+ // Create project directory
24
+ mkdirSync(projectName, { recursive: true });
25
+
26
+ // Generate package.json
27
+ const packageJson = {
28
+ name: projectName,
29
+ version: "0.0.1",
30
+ type: "module",
31
+ scripts: {
32
+ dev: "npx mctx-dev index.js",
33
+ build:
34
+ "node --experimental-sea-config sea-config.json || echo 'Build step placeholder'",
35
+ },
36
+ dependencies: {
37
+ "@mctx-ai/mcp-server": `^${version}`,
38
+ },
39
+ devDependencies: {
40
+ "@mctx-ai/mcp-dev": `^${version}`,
41
+ },
42
+ };
43
+
44
+ writeFileSync(
45
+ join(projectName, "package.json"),
46
+ JSON.stringify(packageJson, null, 2) + "\n",
47
+ );
48
+
49
+ // Generate index.js
50
+ const indexJs = `import { createServer, T } from '@mctx-ai/mcp-server';
51
+
52
+ const app = createServer();
53
+
54
+ // A simple greeting tool
55
+ function greet({ name }) {
56
+ return \`Hello, \${name}! Welcome to mctx.\`;
57
+ }
58
+ greet.description = 'Greet someone by name';
59
+ greet.input = {
60
+ name: T.string({ required: true, description: 'Name to greet' }),
61
+ };
62
+ app.tool('greet', greet);
63
+
64
+ // Learn more: https://docs.mctx.ai/framework/tools
65
+
66
+ export default app;
67
+ `;
68
+
69
+ writeFileSync(join(projectName, "index.js"), indexJs);
70
+
71
+ // Generate mctx.json
72
+ const mctxJson = {
73
+ name: projectName,
74
+ entrypoint: "index.js",
75
+ };
76
+
77
+ writeFileSync(
78
+ join(projectName, "mctx.json"),
79
+ JSON.stringify(mctxJson, null, 2) + "\n",
80
+ );
81
+
82
+ // Generate .gitignore
83
+ const gitignore = `node_modules/
84
+ dist/
85
+ `;
86
+
87
+ writeFileSync(join(projectName, ".gitignore"), gitignore);
88
+
89
+ // Generate README.md
90
+ const readme = `# ${projectName}
91
+
92
+ An MCP server built with [@mctx-ai/mcp-server](https://github.com/mctx-ai/mcp-server).
93
+
94
+ ## Development
95
+
96
+ \`\`\`bash
97
+ npm install
98
+ npm run dev
99
+ \`\`\`
100
+
101
+ ## Add a Tool
102
+
103
+ \`\`\`javascript
104
+ const myTool = ({ input }) => {
105
+ return \`Result: \${input}\`;
106
+ };
107
+ myTool.description = 'What this tool does';
108
+ myTool.input = {
109
+ input: T.string({ required: true, description: 'Input description' }),
110
+ };
111
+ app.tool('my-tool', myTool);
112
+ \`\`\`
113
+
114
+ ## Deploy
115
+
116
+ 1. Push to GitHub
117
+ 2. Connect your repo at [mctx.ai](https://mctx.ai)
118
+ 3. Deploy — mctx reads \`mctx.json\` and runs your server
119
+
120
+ ## Learn More
121
+
122
+ - [Framework Docs](https://docs.mctx.ai/docs/building-mcp-servers/framework-getting-started)
123
+ - [API Reference](https://docs.mctx.ai/docs/building-mcp-servers/framework-api-reference)
124
+ - [MCP Specification](https://modelcontextprotocol.io)
125
+ `;
126
+
127
+ writeFileSync(join(projectName, "README.md"), readme);
128
+
129
+ // Success message
130
+ console.log(`✓ Created ${projectName}
131
+
132
+ cd ${projectName}
133
+ npm install
134
+ npm run dev
135
+
136
+ Learn more: https://docs.mctx.ai`);
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "create-mctx-server",
3
+ "version": "0.3.0",
4
+ "description": "Create a new mctx MCP server project",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-mctx-server": "index.js"
8
+ },
9
+ "files": [
10
+ "index.js"
11
+ ],
12
+ "keywords": [
13
+ "mcp",
14
+ "model-context-protocol",
15
+ "create",
16
+ "scaffold",
17
+ "generator"
18
+ ],
19
+ "author": "mctx, Inc.",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/mctx-ai/mcp-server.git",
24
+ "directory": "packages/create-mctx-server"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/mctx-ai/mcp-server/issues"
28
+ },
29
+ "homepage": "https://docs.mctx.ai"
30
+ }