feat(server): wire HTTP transport into CLI, add docker-compose.server.yml, and update docs
This commit is contained in:
@@ -30,6 +30,18 @@ describe("Docker Container Packaging", () => {
|
||||
expect(content).toContain("scripts");
|
||||
});
|
||||
|
||||
test("docker-compose.server.yml exists and defines hosted server configuration", () => {
|
||||
const composePath = resolve(ROOT_DIR, "docker-compose.server.yml");
|
||||
expect(existsSync(composePath)).toBe(true);
|
||||
|
||||
const content = readFileSync(composePath, "utf-8");
|
||||
expect(content).toContain("ghcr.io/stereotypicalcat/openproject-mcp:latest");
|
||||
expect(content).toContain("openproject-mcp-hosted");
|
||||
expect(content).toContain("PORT=3000");
|
||||
expect(content).toContain("OPENPROJECT_BASE_URL=");
|
||||
expect(content).toContain("/health");
|
||||
});
|
||||
|
||||
test("Docker image builds and starts up cleanly in container", async () => {
|
||||
if (process.env.SKIP_DOCKER_TESTS === "true" || process.env.CI === "true") {
|
||||
console.log("Skipping live docker build test in CI / SKIP_DOCKER_TESTS environment");
|
||||
|
||||
@@ -315,4 +315,64 @@ describe("Hosted Remote MCP Server (HTTP/SSE)", () => {
|
||||
await readerA!.cancel();
|
||||
await readerB!.cancel();
|
||||
});
|
||||
|
||||
test("CLI entrypoint (src/index.ts) boots HTTP server when --port is provided", async () => {
|
||||
const proc = Bun.spawn(
|
||||
[
|
||||
"bun",
|
||||
"src/index.ts",
|
||||
"--port",
|
||||
"0",
|
||||
"--host",
|
||||
"127.0.0.1",
|
||||
"--read-only",
|
||||
],
|
||||
{
|
||||
env: {
|
||||
...process.env,
|
||||
OPENPROJECT_BASE_URL: "https://mock.openproject.example.com",
|
||||
},
|
||||
stderr: "pipe",
|
||||
stdout: "pipe",
|
||||
}
|
||||
);
|
||||
|
||||
let stderrOutput = "";
|
||||
const decoder = new TextDecoder();
|
||||
const reader = proc.stderr.getReader();
|
||||
|
||||
const readPromise = (async () => {
|
||||
try {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
if (done) break;
|
||||
stderrOutput += decoder.decode(value, { stream: true });
|
||||
if (stderrOutput.includes("[openproject-mcp] Starting hosted HTTP server on 127.0.0.1:0...")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Stream closed
|
||||
}
|
||||
})();
|
||||
|
||||
const start = Date.now();
|
||||
while (
|
||||
Date.now() - start < 5000 &&
|
||||
!stderrOutput.includes("[openproject-mcp] Starting hosted HTTP server on 127.0.0.1:0...")
|
||||
) {
|
||||
await Bun.sleep(50);
|
||||
}
|
||||
|
||||
expect(stderrOutput).toContain("[openproject-mcp] Starting hosted HTTP server on 127.0.0.1:0...");
|
||||
|
||||
proc.kill();
|
||||
await proc.exited;
|
||||
try {
|
||||
await reader.cancel();
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
await readPromise;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user