testSessionClient
A server's client is the directory it runs from, as the shell that started it named it when that's the same one (a link to it, say), and as it is otherwise.
import { sessionClient } from "#codebase/tcmts/cli/mcp"; import assert from "node:assert/strict"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; export const testSessionClient = () => { const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "tcm mcp client "))); const real = path.join(root, "real"); const link = path.join(root, "link"); fs.mkdirSync(real); fs.symlinkSync(real, link); const pwd = process.env.PWD; try { process.env.PWD = link; assert.equal(sessionClient(real), link); process.env.PWD = root; assert.equal(sessionClient(real), real); delete process.env.PWD; assert.equal(sessionClient(real), real); } finally { if (pwd === undefined) delete process.env.PWD; else process.env.PWD = pwd; fs.rmSync(root, { recursive: true, force: true }); } }