Skip to content

Commit df58740

Browse files
committed
test(cli): pin the shared connect line beside the dev banner's pins
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017ihL2dLQEXWGsE2SZ3Qn5F
1 parent c57b8ca commit df58740

2 files changed

Lines changed: 31 additions & 12 deletions

File tree

‎packages/cli/src/commands/dev-mcp-connect-hint-origin.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@ import { OBJECTSTACK_MCP_SERVER_NAME, renderSkillMarkdown } from '@objectstack/m
3838
import { printMcpConnectHint } from './dev.js';
3939
import { AUTH_BASE_URL_ENV_NAMES, resolveAuthBaseUrl } from './serve.js';
4040
import { printServerReady, type ServerReadyOptions } from '../utils/format.js';
41+
import McpConnect from './mcp/connect.js';
42+
43+
// Pay the first load of what `serve.ts` reaches through dynamic `import()`s at
44+
// MODULE LOAD, outside any clocked case (`pnpm check:test-source-alias`).
45+
import '@objectstack/metadata-protocol';
46+
import '@objectstack/metadata';
47+
import '@objectstack/objectql';
48+
import '@objectstack/plugin-hono-server';
49+
import '@objectstack/rest';
50+
import '@objectstack/service-settings';
51+
import '@objectstack/service-datasource';
52+
import '@objectstack/driver-turso';
53+
import '@objectstack/driver-sql';
54+
import '@objectstack/platform-objects/plugin';
55+
import '@objectstack/plugin-security';
4156

4257
const HERE = dirname(fileURLToPath(import.meta.url));
4358
const DEV_SOURCE = readFileSync(resolve(HERE, 'dev.ts'), 'utf8');
@@ -371,6 +386,17 @@ describe('os dev MCP connect hint — origin (#16734)', () => {
371386
expect(skill).toEqual([OBJECTSTACK_MCP_SERVER_NAME]);
372387
});
373388

389+
it('`os mcp connect --url` for the same origin prints the very line the banner prints', async () => {
390+
const banner = boot(3000).split('\n').find((l) => l.includes('Connect claude mcp add'));
391+
expect(banner).toBeDefined();
392+
393+
lines = [];
394+
await McpConnect.run(['--url', 'http://localhost:3000', '--print']);
395+
const connect = lines.find((l) => l.includes('Connect claude mcp add'));
396+
397+
expect(connect?.trim()).toBe(banner!.trim());
398+
});
399+
374400
it('dev reads that constant and derives no name of its own', () => {
375401
// The name used to be the folder `os dev` ran in, so a `hotcrm/` checkout
376402
// registered the server as `hotcrm` while the skill said `objectstack`.

‎packages/cli/test/mcp-connect.test.ts‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@ const {
2323
mcpUrlFromBase,
2424
claudeMcpAddLine,
2525
} = await import('../src/commands/mcp/connect.js');
26-
const { printMcpConnectHint } = await import('../src/commands/dev.js');
2726

2827
const CLOUD_PLANE = 'http://cloud.test';
2928
const CLOUD_TOKEN = 'cloud_tok_30889';
30-
const { AUTH_BASE_URL_ENV_NAMES } = await import('../src/commands/serve.js');
31-
// The base-URL chain is cleared too: `os dev`'s banner resolves its origin through it.
32-
const MANAGED_ENV = ['OS_CLOUD_URL', 'OS_CLOUD_API_KEY', 'OS_TOKEN', 'OS_ENVIRONMENT_ID', ...AUTH_BASE_URL_ENV_NAMES];
29+
const MANAGED_ENV = ['OS_CLOUD_URL', 'OS_CLOUD_API_KEY', 'OS_TOKEN', 'OS_ENVIRONMENT_ID'] as const;
3330

3431
type Call = { url: string; method: string; auth: string | undefined };
3532

@@ -148,20 +145,16 @@ describe('os mcp connect', () => {
148145
]);
149146
});
150147

151-
it('--url http://localhost:3000: prints the local server, named and spelled as `os dev`\'s banner prints it, with no control plane', async () => {
148+
it('--url http://localhost:3000: prints the local server under the name `os dev`\'s banner gives it, with no control plane', async () => {
149+
// That the banner's Connect row is this same line is pinned beside the banner's other
150+
// pins, in `src/commands/dev-mcp-connect-hint-origin.test.ts`.
152151
const calls = stubPlane();
153152

154153
const exit = await connect(['--url', 'http://localhost:3000', '--print']);
155154

156155
expect(exit, text()).toBeUndefined();
157-
const line = `claude mcp add --transport http ${OBJECTSTACK_MCP_SERVER_NAME} http://localhost:3000/api/v1/mcp`;
158-
expect(text()).toContain(`Connect ${line}`);
156+
expect(text()).toContain(`Connect claude mcp add --transport http ${OBJECTSTACK_MCP_SERVER_NAME} http://localhost:3000/api/v1/mcp`);
159157
expect(calls).toEqual([]);
160-
161-
// One spelling: `os dev`'s Connect row for the same origin is this exact line.
162-
output = [];
163-
printMcpConnectHint({ boundPort: 3000 });
164-
expect(text()).toContain(`Connect ${line}`);
165158
});
166159

167160
it('several environments and no --env: refuses non-zero, as `os deploy` does, and registers nothing', async () => {

0 commit comments

Comments
 (0)