Skip to content

Commit 4a7808d

Browse files
committed
test(sequentialthinking): smoke stdio initialize serverInfo.version
Spawn the built server over stdio and assert getServerVersion() matches package.json (and is not the old hardcoded 0.2.0). Skip when dist/ is absent so test-before-build CI still passes.
1 parent 64fd8cd commit 4a7808d

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

‎src/sequentialthinking/__tests__/server-version.test.ts‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import { createRequire } from 'node:module';
33
import { existsSync } from 'node:fs';
44
import path from 'node:path';
55
import { fileURLToPath, pathToFileURL } from 'node:url';
6+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
7+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
68
import { resolvePackageVersion, SERVER_VERSION } from '../version.js';
79

810
const packageJson = createRequire(import.meta.url)('../package.json') as { version: string };
9-
const distVersionPath = path.join(
10-
path.dirname(fileURLToPath(import.meta.url)),
11-
'..',
12-
'dist',
13-
'version.js',
14-
);
11+
const packageRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
12+
const distVersionPath = path.join(packageRoot, 'dist', 'version.js');
13+
const distIndexPath = path.join(packageRoot, 'dist', 'index.js');
1514

1615
describe('server version', () => {
1716
it('uses package.json version instead of a hardcoded string', () => {
@@ -32,4 +31,27 @@ describe('server version', () => {
3231
expect(distModule.SERVER_VERSION).toBe(packageJson.version);
3332
},
3433
);
34+
35+
it.skipIf(!existsSync(distIndexPath))(
36+
'stdio initialize reports package.json version in serverInfo',
37+
async () => {
38+
const transport = new StdioClientTransport({
39+
command: process.execPath,
40+
args: [distIndexPath],
41+
cwd: packageRoot,
42+
stderr: 'pipe',
43+
});
44+
const client = new Client({ name: 'version-smoke', version: '0.0.0' });
45+
46+
try {
47+
await client.connect(transport);
48+
const serverInfo = client.getServerVersion();
49+
expect(serverInfo?.name).toBe('sequential-thinking-server');
50+
expect(serverInfo?.version).toBe(packageJson.version);
51+
expect(serverInfo?.version).not.toBe('0.2.0');
52+
} finally {
53+
await client.close();
54+
}
55+
},
56+
);
3557
});

‎src/sequentialthinking/version.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createRequire } from 'node:module';
2-
import path from 'path';
3-
import { fileURLToPath } from 'url';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
44

55
/**
66
* Resolve this package's version from package.json.

0 commit comments

Comments
 (0)