From 767dde44a67833cfaa17842288e800bff12360a2 Mon Sep 17 00:00:00 2001 From: Ben Sully Date: Wed, 19 Mar 2025 10:42:09 +0000 Subject: [PATCH] feat: expose GitHub server instance to npm library This commit separates the `main` logic into a separate file, now marked as the binary entry point for the package, and updates the index to export the server instance. This allows the package to be used as a library, enabling the server to be used with custom transports in other projects. --- package-lock.json | 2 +- src/github/Dockerfile | 2 +- src/github/index.ts | 5 +---- src/github/main.ts | 6 ++++++ src/github/package.json | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 src/github/main.ts diff --git a/package-lock.json b/package-lock.json index 69308e1fb5..30b35a4b1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5400,7 +5400,7 @@ "zod-to-json-schema": "^3.23.5" }, "bin": { - "mcp-server-github": "dist/index.js" + "mcp-server-github": "dist/main.js" }, "devDependencies": { "shx": "^0.3.4", diff --git a/src/github/Dockerfile b/src/github/Dockerfile index a3ad36b8d9..4327842805 100644 --- a/src/github/Dockerfile +++ b/src/github/Dockerfile @@ -20,4 +20,4 @@ WORKDIR /app RUN npm ci --ignore-scripts --omit-dev -ENTRYPOINT ["node", "dist/index.js"] \ No newline at end of file +ENTRYPOINT ["node", "dist/main.js"] diff --git a/src/github/index.ts b/src/github/index.ts index 33b62ff7fb..1f9caded4e 100644 --- a/src/github/index.ts +++ b/src/github/index.ts @@ -476,7 +476,4 @@ async function runServer() { console.error("GitHub MCP Server running on stdio"); } -runServer().catch((error) => { - console.error("Fatal error in main():", error); - process.exit(1); -}); \ No newline at end of file +export { server, runServer }; \ No newline at end of file diff --git a/src/github/main.ts b/src/github/main.ts new file mode 100644 index 0000000000..83dfccb61d --- /dev/null +++ b/src/github/main.ts @@ -0,0 +1,6 @@ +import { runServer } from "./index.js"; + +runServer().catch((error) => { + console.error("Fatal error in main():", error); + process.exit(1); +}); diff --git a/src/github/package.json b/src/github/package.json index 29f5296b6b..e0b6e9a790 100644 --- a/src/github/package.json +++ b/src/github/package.json @@ -8,7 +8,7 @@ "bugs": "https://github.com/modelcontextprotocol/servers/issues", "type": "module", "bin": { - "mcp-server-github": "dist/index.js" + "mcp-server-github": "dist/main.js" }, "files": [ "dist"