Skip to content

Commit 19921b3

Browse files
committed
fix: fixed binary to be executable with npx
1 parent b5992cc commit 19921b3

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

Diff for: bin/cli.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,21 @@
22

33
import { startServer } from '../build/index.js';
44

5-
startServer();
5+
const args = process.argv.slice(2);
6+
const mode = args[0]?.toLowerCase();
7+
8+
if (mode === 'http') {
9+
// If the HTTP server module exists, import and run it
10+
import('../build/http-server.js')
11+
.catch(error => {
12+
console.error('Error starting HTTP server:', error);
13+
process.exit(1);
14+
});
15+
} else {
16+
// Default to stdio server
17+
startServer()
18+
.catch(error => {
19+
console.error('Error starting stdio server:', error);
20+
process.exit(1);
21+
});
22+
}

Diff for: src/index.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
2-
import startServer from "./server/server.js";
2+
import startServerImpl from "./server/server.js";
33

4-
// Start the server
5-
async function main() {
4+
export const startServer = async () => {
65
try {
7-
const server = await startServer();
6+
const server = await startServerImpl();
87
const transport = new StdioServerTransport();
98
await server.connect(transport);
109
console.error("Starknet MCP Server running on stdio");
10+
return server;
1111
} catch (error) {
1212
console.error("Error starting Starknet MCP server:", error);
1313
process.exit(1);
1414
}
15-
}
15+
};
1616

17-
main().catch((error) => {
18-
console.error("Fatal error in main():", error);
19-
process.exit(1);
20-
});
17+
// Start the server when this file is run directly
18+
if (import.meta.url === `file://${process.argv[1]}`) {
19+
startServer().catch((error) => {
20+
console.error("Fatal error in main():", error);
21+
process.exit(1);
22+
});
23+
}

0 commit comments

Comments
 (0)