Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run build
- run: npm test
- run: npm run mcp:inspect
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "node dist/server.js",
"dev": "ts-node src/server.ts",
"test": "ts-node test-workflow.ts",
"test-workflow": "ts-node test-workflow.ts"
"test-workflow": "ts-node test-workflow.ts",
"mcp:inspect": "npx -y @modelcontextprotocol/inspector@0.15.0 --cli node dist/server.js --method tools/list"
},
"keywords": [],
"author": "",
Expand Down
32 changes: 24 additions & 8 deletions test-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MCPTestClient {
console.log('🚀 Starting Shared Memory MCP Test Workflow\n');

// Start the MCP server
this.server = spawn('npm', ['run', 'dev'], {
this.server = spawn(process.execPath, ['-r', 'ts-node/register', 'src/server.ts'], {
stdio: ['pipe', 'pipe', 'pipe']
});

Expand Down Expand Up @@ -341,10 +341,26 @@ class MCPTestClient {
});
}

cleanup(): void {
if (this.server) {
this.server.kill();
async cleanup(): Promise<void> {
if (!this.server) {
return;
}

const server = this.server;
this.server = null;

if (server.exitCode !== null || server.signalCode !== null) {
return;
}

await new Promise<void>(resolve => {
const timeout = setTimeout(resolve, 2000);
server.once('exit', () => {
clearTimeout(timeout);
resolve();
});
server.kill('SIGTERM');
});
}
}

Expand All @@ -354,19 +370,19 @@ async function main(): Promise<void> {

process.on('SIGINT', () => {
console.log('\n🛑 Shutting down...');
client.cleanup();
process.exit(0);
void client.cleanup().finally(() => process.exit(0));
});

try {
await client.start();
} catch (error: any) {
console.error('❌ Test failed:', error.message);
client.cleanup();
await client.cleanup();
process.exit(1);
}
await client.cleanup();
}

if (require.main === module) {
main();
}
}
Loading