Skip to content

Commit 27cb517

Browse files
committed
feat: add mcp-build cli
1 parent b5789af commit 27cb517

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mcp-framework",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "Framework for building Model Context Protocol (MCP) servers in Typescript",
55
"type": "module",
66
"author": "Alex Andru <[email protected]>",
@@ -15,6 +15,9 @@
1515
"files": [
1616
"dist"
1717
],
18+
"bin": {
19+
"mcp-build": "./dist/cli/build.js"
20+
},
1821
"scripts": {
1922
"build": "tsc",
2023
"watch": "tsc --watch",

src/cli/build.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env node
2+
import { spawnSync } from "child_process";
3+
import { readFileSync, writeFileSync } from "fs";
4+
import { join } from "path";
5+
6+
function runTsc() {
7+
const tscPath = join(process.cwd(), "node_modules", ".bin", "tsc");
8+
const tsc = spawnSync(tscPath, [], {
9+
stdio: "inherit",
10+
shell: true,
11+
});
12+
13+
if (tsc.status !== 0) {
14+
process.exit(tsc.status ?? 1);
15+
}
16+
}
17+
18+
function addShebang() {
19+
const indexPath = join(process.cwd(), "dist", "index.js");
20+
try {
21+
const content = readFileSync(indexPath, "utf8");
22+
const shebang = "#!/usr/bin/env node\n";
23+
24+
if (!content.startsWith(shebang)) {
25+
writeFileSync(indexPath, shebang + content);
26+
console.log("Added shebang to dist/index.js");
27+
}
28+
} catch (error) {
29+
console.error("Error adding shebang:", error);
30+
process.exit(1);
31+
}
32+
}
33+
34+
runTsc();
35+
36+
addShebang();
37+
38+
console.log("MCP Build complete");

0 commit comments

Comments
 (0)