@jam-mcp/server 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -74,10 +74,10 @@ auth login Store Jira credentials in this user's OS secret store
74
74
  runtime Show or change which JAM build this machine runs
75
75
  ```
76
76
 
77
- Written out, that is `npx --yes @jam-mcp/launcher@1.4.0 doctor`, or just `jam
77
+ Written out, that is `npx --yes @jam-mcp/launcher@1.4.1 doctor`, or just `jam
78
78
  doctor` if you took the launcher's optional global install. Starting from
79
79
  nothing — no install, no runtime chosen yet — use
80
- `npx --yes @jam-mcp/bootstrap@1.4.0 init` instead.
80
+ `npx --yes @jam-mcp/bootstrap@1.4.1 init` instead.
81
81
 
82
82
  Credentials come from the process environment or this user's OS secret store —
83
83
  never from a repository file — and never appear in logs, telemetry, or tool
@@ -18,6 +18,18 @@ export type HostState = {
18
18
  cliAvailable: boolean;
19
19
  /** Whether it already has a `jam` entry registered for this user. */
20
20
  hasJamEntry: boolean;
21
+ /**
22
+ * The launcher pin that entry actually runs, when the listing shows it.
23
+ *
24
+ * An entry existing is not the same as an entry being current: a pin written
25
+ * by an older release keeps running that release's server, which serves a
26
+ * different set of tools. Reading only the name made a stale registration
27
+ * indistinguishable from a good one, and setup then reported
28
+ * `already_configured` over it.
29
+ */
30
+ entryVersion?: string;
31
+ /** The entry is present but does not run the launcher this release registers. */
32
+ entryStale?: boolean;
21
33
  };
22
34
  export type HostRunResult = {
23
35
  status: number | null;
@@ -29,6 +41,8 @@ export type HostRunResult = {
29
41
  export type HostRunner = (command: HostCommand) => HostRunResult;
30
42
  export declare const defaultHostRunner: HostRunner;
31
43
  export declare function hostRegistration(id: HostId): HostCommand | undefined;
44
+ /** The removal that has to precede re-registering an entry this host already has. */
45
+ export declare function hostUnregistration(id: HostId): HostCommand | undefined;
32
46
  /**
33
47
  * Is `jam` in this listing?
34
48
  *
@@ -42,6 +56,19 @@ export declare function hostRegistration(id: HostId): HostCommand | undefined;
42
56
  * `mcp add` on an existing entry writes the same launcher line back.
43
57
  */
44
58
  export declare function listsJamEntry(stdout: string): boolean;
59
+ /** The listing line for `jam`, ANSI stripped, or null when there is none. */
60
+ export declare function jamEntryLine(stdout: string): string | null;
61
+ /** The launcher version a listing line runs, when the line names one. */
62
+ export declare function entryLauncherVersion(line: string): string | undefined;
63
+ /**
64
+ * Does this entry run the launcher this release registers?
65
+ *
66
+ * Anything else - an older pin, an unpinned spec, a line whose command JAM
67
+ * cannot read - counts as stale. That direction is deliberate: `mcp add`
68
+ * rewrites the same entry, so a needless repair costs one command, while a
69
+ * missed one leaves the agent talking to a server nobody tested it against.
70
+ */
71
+ export declare function isEntryStale(line: string): boolean;
45
72
  /**
46
73
  * Ask each host what it has, and whether it is there at all.
47
74
  *
@@ -30,16 +30,22 @@ const ADAPTERS = [
30
30
  // `-s user` is the whole point: registered for this user on this machine,
31
31
  // not for whichever project happens to be open.
32
32
  register: { command: "claude", args: ["mcp", "add", "jam", "-s", "user", ...LAUNCH] },
33
+ unregister: { command: "claude", args: ["mcp", "remove", "jam", "-s", "user"] },
33
34
  },
34
35
  {
35
36
  id: "codex",
36
37
  probe: { command: "codex", args: ["mcp", "list"] },
37
38
  register: { command: "codex", args: ["mcp", "add", "jam", ...LAUNCH] },
39
+ unregister: { command: "codex", args: ["mcp", "remove", "jam"] },
38
40
  },
39
41
  ];
40
42
  export function hostRegistration(id) {
41
43
  return ADAPTERS.find((a) => a.id === id)?.register;
42
44
  }
45
+ /** The removal that has to precede re-registering an entry this host already has. */
46
+ export function hostUnregistration(id) {
47
+ return ADAPTERS.find((a) => a.id === id)?.unregister;
48
+ }
43
49
  const ANSI = /\[[0-9;?]*[A-Za-z]/g;
44
50
  /**
45
51
  * Is `jam` in this listing?
@@ -54,11 +60,32 @@ const ANSI = /\[[0-9;?]*[A-Za-z]/g;
54
60
  * `mcp add` on an existing entry writes the same launcher line back.
55
61
  */
56
62
  export function listsJamEntry(stdout) {
57
- return stdout
63
+ return jamEntryLine(stdout) !== null;
64
+ }
65
+ /** The listing line for `jam`, ANSI stripped, or null when there is none. */
66
+ export function jamEntryLine(stdout) {
67
+ const line = stdout
58
68
  .replace(ANSI, "")
59
69
  .split(/\r?\n/)
60
- .some((line) => /^\s*jam(?=[\s:])/.test(line));
70
+ .find((candidate) => /^\s*jam(?=[\s:])/.test(candidate));
71
+ return line ?? null;
72
+ }
73
+ /** The launcher version a listing line runs, when the line names one. */
74
+ export function entryLauncherVersion(line) {
75
+ return /@jam-mcp\/launcher@([^\s"']+)/.exec(line)?.[1];
76
+ }
77
+ /**
78
+ * Does this entry run the launcher this release registers?
79
+ *
80
+ * Anything else - an older pin, an unpinned spec, a line whose command JAM
81
+ * cannot read - counts as stale. That direction is deliberate: `mcp add`
82
+ * rewrites the same entry, so a needless repair costs one command, while a
83
+ * missed one leaves the agent talking to a server nobody tested it against.
84
+ */
85
+ export function isEntryStale(line) {
86
+ return entryLauncherVersion(line) !== EXPECTED_LAUNCHER_VERSION;
61
87
  }
88
+ const EXPECTED_LAUNCHER_VERSION = entryLauncherVersion(JAM_MCP_ENTRY.args.join(" "));
62
89
  /**
63
90
  * Ask each host what it has, and whether it is there at all.
64
91
  *
@@ -85,10 +112,16 @@ function probeHosts(run) {
85
112
  if (result.failed || result.status !== 0) {
86
113
  return { id: adapter.id, cliAvailable: false, hasJamEntry: false };
87
114
  }
115
+ const line = jamEntryLine(result.stdout);
116
+ if (!line)
117
+ return { id: adapter.id, cliAvailable: true, hasJamEntry: false };
118
+ const version = entryLauncherVersion(line);
88
119
  return {
89
120
  id: adapter.id,
90
121
  cliAvailable: true,
91
- hasJamEntry: listsJamEntry(result.stdout),
122
+ hasJamEntry: true,
123
+ ...(version ? { entryVersion: version } : {}),
124
+ entryStale: isEntryStale(line),
92
125
  };
93
126
  });
94
127
  }
@@ -13,7 +13,7 @@ import { LAUNCHER_PACKAGE_SPEC } from "@jam-mcp/launcher";
13
13
  export { LAUNCHER_PACKAGE_SPEC };
14
14
  export declare const JAM_MCP_ENTRY: {
15
15
  readonly command: "npx";
16
- readonly args: readonly ["--yes", "@jam-mcp/launcher@1.4.0", "serve"];
16
+ readonly args: readonly ["--yes", "@jam-mcp/launcher@1.4.1", "serve"];
17
17
  };
18
18
  /**
19
19
  * Recognise wiring from before the launcher existed: a hard-coded `node` path
@@ -36,6 +36,11 @@ export function applySetupPlan(plan, options = {}) {
36
36
  // decides nothing. A failure is that host's failure, reported with the
37
37
  // command that produced it - never retried against another host.
38
38
  const run = options.runHost ?? defaultHostRunner;
39
+ // A repair removes the stale entry first. Its failure is not reported on
40
+ // its own: if the entry is already gone the removal fails harmlessly, and
41
+ // if it is still there the registration below fails and says so.
42
+ if (change.precede)
43
+ run({ command: change.precede.command, args: change.precede.args });
39
44
  const result = run({ command: change.command, args: change.args });
40
45
  if (result.failed || result.status !== 0) {
41
46
  throw new Error(`Registering JAM with ${change.host} failed: ${change.command} ${change.args.join(" ")}`);
@@ -34,7 +34,7 @@ export type SetupChange = {
34
34
  /** Present on a rebind, so the preview shows what is being replaced. */
35
35
  previousKey?: string;
36
36
  } | {
37
- type: "create";
37
+ type: "create" | "replace";
38
38
  target: "host-mcp";
39
39
  host: HostId;
40
40
  /**
@@ -44,6 +44,18 @@ export type SetupChange = {
44
44
  */
45
45
  command: string;
46
46
  args: string[];
47
+ /**
48
+ * Run before the registration, on a repair. The host CLI refuses to add an
49
+ * entry that already exists, so the stale one has to go first - and which
50
+ * command does that is decided here, not worked out during apply.
51
+ */
52
+ precede?: {
53
+ command: string;
54
+ args: string[];
55
+ };
56
+ /** On a repair: the launcher pin the entry runs today, so the preview names it. */
57
+ previousVersion?: string;
58
+ reason?: "stale-registration";
47
59
  };
48
60
  export type SetupPlan = {
49
61
  status: SetupStatus;
@@ -1,6 +1,6 @@
1
1
  import { join } from "node:path";
2
2
  import { CONFIG_RELATIVE_PATH } from "../config/load-config.js";
3
- import { hostRegistration } from "./host-mcp.js";
3
+ import { hostRegistration, hostUnregistration } from "./host-mcp.js";
4
4
  import { projectBindingsPath } from "./project-bindings.js";
5
5
  import { decideProjectKey } from "./project-config-bootstrapper.js";
6
6
  import { portableBootstrapCommand } from "@jam-mcp/launcher";
@@ -155,17 +155,25 @@ function finish(changes, state, project) {
155
155
  function planHostChanges(state) {
156
156
  const changes = [];
157
157
  for (const host of state.hosts) {
158
- if (!host.cliAvailable || host.hasJamEntry)
158
+ if (!host.cliAvailable)
159
+ continue;
160
+ // An entry that exists but runs an older launcher is not "already set up":
161
+ // that pin decides which server, and so which tools, the agent actually gets.
162
+ if (host.hasJamEntry && host.entryStale !== true)
159
163
  continue;
160
164
  const registration = hostRegistration(host.id);
161
165
  if (!registration)
162
166
  continue;
167
+ const removal = hostUnregistration(host.id);
163
168
  changes.push({
164
- type: "create",
169
+ type: host.hasJamEntry ? "replace" : "create",
165
170
  target: "host-mcp",
166
171
  host: host.id,
167
172
  command: registration.command,
168
173
  args: registration.args,
174
+ ...(host.hasJamEntry && removal ? { precede: { command: removal.command, args: removal.args } } : {}),
175
+ ...(host.entryVersion ? { previousVersion: host.entryVersion } : {}),
176
+ ...(host.hasJamEntry ? { reason: "stale-registration" } : {}),
169
177
  });
170
178
  }
171
179
  return changes;
@@ -1,6 +1,7 @@
1
1
  import { type MigrationTarget } from "../bootstrap/migration-target.js";
2
2
  import type { CredentialPort } from "../ports/credentials.port.js";
3
- import type { HostRunner } from "../bootstrap/host-mcp.js";
3
+ import { type HostRunner } from "../bootstrap/host-mcp.js";
4
+ import { type ToolsetProbe } from "../bootstrap/live-toolset.js";
4
5
  import type { GitRemoteFn } from "../bootstrap/workspace-identity.js";
5
6
  /**
6
7
  * The machine-readable half of setup.
@@ -27,6 +28,8 @@ export type AgentOptions = {
27
28
  env?: NodeJS.ProcessEnv;
28
29
  /** Injected by tests so a plan never shells out to npm to verify a migration target. */
29
30
  migrationTarget?: MigrationTarget;
31
+ /** Injected by tests so doctor never launches a real MCP server to read its tools. */
32
+ toolsetProbe?: ToolsetProbe;
30
33
  /** Injected by tests so identity never depends on the checkout under test. */
31
34
  git?: GitRemoteFn;
32
35
  /** Injected by tests so no test ever registers JAM with a real host. */
@@ -52,7 +55,15 @@ export declare function setupApplyCommand(options?: AgentOptions): Promise<numbe
52
55
  * authenticating), and reports exactly how far it got.
53
56
  */
54
57
  export declare function setupAgentCommand(options?: AgentOptions): Promise<number>;
55
- /** `jam doctor --json`. */
58
+ /**
59
+ * `jam doctor --json`.
60
+ *
61
+ * Three axes, kept apart on purpose. The package on this machine being current
62
+ * says nothing about what the host registration launches, and neither says what
63
+ * the agent can actually call - a stale pin serves an older tool set while every
64
+ * local check passes. Reporting them as one verdict is how a broken setup was
65
+ * reported as ready.
66
+ */
56
67
  export declare function doctorJsonCommand(options?: AgentOptions): Promise<number>;
57
68
  /**
58
69
  * `jam auth status --json` - presence and origin only.
@@ -5,6 +5,9 @@ import { applySetupPlan } from "../bootstrap/setup-apply.js";
5
5
  import { detectSetupState } from "../bootstrap/setup-state.js";
6
6
  import { buildDeps } from "../deps.js";
7
7
  import { toJamError } from "../domain/errors.js";
8
+ import { hostRegistration } from "../bootstrap/host-mcp.js";
9
+ import { checkLiveToolset } from "../bootstrap/live-toolset.js";
10
+ import { SERVER_VERSION } from "@jam-mcp/launcher";
8
11
  export function emitJson(payload) {
9
12
  process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
10
13
  }
@@ -108,17 +111,74 @@ export async function setupAgentCommand(options = {}) {
108
111
  });
109
112
  return health.passed ? 0 : 1;
110
113
  }
111
- /** `jam doctor --json`. */
114
+ /**
115
+ * `jam doctor --json`.
116
+ *
117
+ * Three axes, kept apart on purpose. The package on this machine being current
118
+ * says nothing about what the host registration launches, and neither says what
119
+ * the agent can actually call - a stale pin serves an older tool set while every
120
+ * local check passes. Reporting them as one verdict is how a broken setup was
121
+ * reported as ready.
122
+ */
112
123
  export async function doctorJsonCommand(options = {}) {
124
+ // detect() already probes the hosts for every non-shared path; doctor wants that.
113
125
  const state = detect(options);
114
126
  const health = await gateResult(state.project.root);
127
+ const axes = await inspectAxes(state, options);
128
+ // 등록이 아예 없는 것은 결함이 아니다 — 새 머신, 호스트 CLI 없는 CI, 아직 setup 을
129
+ // 안 한 사용자 모두 정상 상태다. 전체 판정을 무너뜨리는 것은 **거짓말하는 상태**뿐:
130
+ // 낡은 핀을 실행 중인 등록(STALE)과, 등록은 맞는데 실제 도구가 다른 경우(MISMATCH).
131
+ const axesOk = axes.registration !== "HOST_REGISTRATION_STALE" && axes.live !== "LIVE_TOOLSET_MISMATCH";
132
+ const passed = health.passed && axesOk;
115
133
  emitJson({
116
- status: health.passed ? "ready" : "failed",
134
+ status: passed ? "ready" : "failed",
117
135
  ...(health.error ? { error: health.error } : {}),
118
136
  project: { root: state.project.root, ...(state.project.key ? { key: state.project.key } : {}) },
137
+ axes,
119
138
  checks: health.checks,
120
139
  });
121
- return health.passed ? 0 : 1;
140
+ return passed ? 0 : 1;
141
+ }
142
+ async function inspectAxes(state, options) {
143
+ const packageVersion = state.runtime.version;
144
+ const axes = {
145
+ package: packageVersion === SERVER_VERSION ? "PACKAGE_READY" : "PACKAGE_NOT_READY",
146
+ ...(packageVersion ? { packageVersion } : {}),
147
+ registration: "UNREGISTERED",
148
+ live: "UNCHECKED",
149
+ };
150
+ const hosts = state.hosts.filter((host) => host.cliAvailable);
151
+ if (state.hosts.length > 0 && hosts.length === 0) {
152
+ return { ...axes, registration: "HOST_UNREACHABLE", detail: "no host CLI answered" };
153
+ }
154
+ const registered = hosts.find((host) => host.hasJamEntry);
155
+ if (!registered)
156
+ return axes;
157
+ axes.registration = registered.entryStale ? "HOST_REGISTRATION_STALE" : "OK";
158
+ if (registered.entryVersion)
159
+ axes.registeredVersion = registered.entryVersion;
160
+ // A stale entry has already answered the question the live check would ask,
161
+ // and asking it means launching that older release. Repair first.
162
+ if (registered.entryStale)
163
+ return axes;
164
+ const registration = hostRegistration(registered.id);
165
+ const launch = registration ? launcherArgv(registration.args) : null;
166
+ if (!launch)
167
+ return { ...axes, live: "UNCHECKED", detail: "could not read the registered command" };
168
+ const result = await checkLiveToolset(launch, options.toolsetProbe);
169
+ axes.live = result.verdict === "OK" ? "OK" : result.verdict;
170
+ if (result.missing && result.missing.length > 0)
171
+ axes.missingTools = result.missing;
172
+ if (result.detail)
173
+ axes.detail = result.detail;
174
+ return axes;
175
+ }
176
+ /** The registration argv carries the launch command after `--`. */
177
+ function launcherArgv(args) {
178
+ const at = args.indexOf("--");
179
+ if (at < 0 || args.length <= at + 1)
180
+ return null;
181
+ return { command: args[at + 1], args: args.slice(at + 2) };
122
182
  }
123
183
  /**
124
184
  * `jam auth status --json` - presence and origin only.
package/dist/cli/setup.js CHANGED
@@ -108,7 +108,9 @@ function reportApplied(applied, plan) {
108
108
  continue;
109
109
  }
110
110
  if (change.target === "host-mcp") {
111
- line(`[OK] ${change.host} - jam registered for this user`);
111
+ line(change.type === "replace"
112
+ ? `[OK] ${change.host} - jam re-registered, replacing a stale launcher pin${change.previousVersion ? ` (${change.previousVersion})` : ""}`
113
+ : `[OK] ${change.host} - jam registered for this user`);
112
114
  continue;
113
115
  }
114
116
  if (change.target === "project-config") {
package/dist/index.js CHANGED
File without changes
@@ -2,6 +2,13 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { JamDeps } from "../deps.js";
3
3
  export declare const SERVER_NAME = "jam";
4
4
  export declare const TOOL_COUNT: number;
5
+ /**
6
+ * The same contract by name, for the checks that ask a *running* server what it
7
+ * serves. The registrars above cannot be introspected for their tool names, and
8
+ * counting is not enough: five tools with one renamed is still five.
9
+ * `tests/contract/tools.test.ts` holds this list to what the server registers.
10
+ */
11
+ export declare const TOOL_NAMES: readonly ["jira_search", "jira_context", "jira_full", "jira_write_plan", "jira_write_apply"];
5
12
  /**
6
13
  * The external contract: three read tools and two write tools.
7
14
  *
@@ -21,6 +21,19 @@ const REGISTER_TOOLS = [
21
21
  registerJiraWriteApply,
22
22
  ];
23
23
  export const TOOL_COUNT = REGISTER_TOOLS.length;
24
+ /**
25
+ * The same contract by name, for the checks that ask a *running* server what it
26
+ * serves. The registrars above cannot be introspected for their tool names, and
27
+ * counting is not enough: five tools with one renamed is still five.
28
+ * `tests/contract/tools.test.ts` holds this list to what the server registers.
29
+ */
30
+ export const TOOL_NAMES = [
31
+ "jira_search",
32
+ "jira_context",
33
+ "jira_full",
34
+ "jira_write_plan",
35
+ "jira_write_apply",
36
+ ];
24
37
  /**
25
38
  * The external contract: three read tools and two write tools.
26
39
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jam-mcp/server",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "JAM (Jira Agent MCP) - agent-facing Jira access layer: MCP server, setup core, and CLI",
5
5
  "keywords": [
6
6
  "jira",
@@ -41,7 +41,7 @@
41
41
  "test:watch": "vitest"
42
42
  },
43
43
  "dependencies": {
44
- "@jam-mcp/launcher": "1.4.0",
44
+ "@jam-mcp/launcher": "1.4.1",
45
45
  "@modelcontextprotocol/sdk": "^1.30.0",
46
46
  "yaml": "^2.9.0",
47
47
  "zod": "^4.4.3"