@lornatang/dsh-atlassian 0.1.13 → 0.1.15

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.15 - 2026-11-19
4
+
5
+ - Serialize connection replacement and refresh the Jira site cache when the connection changes.
6
+ - Apply connection settings only after saving them and use the same Jira resource parser during connection and board loading.
7
+
8
+ ## 0.1.14 - 2026-11-19
9
+
10
+ - Reuse the site resolved while connecting for the first Jira board render, removing a duplicate accessibleatlassianresources MCP round-trip; the board still falls back to its own lookup when the cached site is stale.
11
+
3
12
  ## 0.1.13 - 2026-11-19
4
13
 
5
14
  - Remove a duplicated request-target pre-check left over from the route hardening; malformed URLs still receive the same 400 response.
package/README.md CHANGED
@@ -34,7 +34,7 @@ dsh plugin --profile <name> add @lornatang/dsh-atlassian
34
34
  dsh plugin --profile <name> remove @lornatang/dsh-atlassian
35
35
  ```
36
36
 
37
- The same release is also attached as an archive on GitHub: `dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.13/lornatang-dsh-atlassian-0.1.13.tgz`.
37
+ The same release is also attached as an archive on GitHub: `dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.15/lornatang-dsh-atlassian-0.1.15.tgz`.
38
38
 
39
39
  `add` composes the layer into the profile: the profile's `cordis.patch.yml` gains an insert entry with row id `atlassian`, package `@lornatang/dsh-atlassian`, and the five values the shipped patch carries — `mode: cloud`, `serverName: atlassian`, `url: https://mcp.atlassian.com/v1/mcp`, `redirectPort: 3334` and `autoOpenBrowser: true`. The manifest declares `dsh.bundle.patch: ./cordis.patch.yml`, which is the declaration the reconcile step reads; `remove` deletes the entry again. Restart DSH after either command, because the profile composes its rows and its client half only at startup, then open Settings → Atlassian. Releases before 0.1.5 published this package as `@lornatang/dsh-atlassian-bridge`; add the scoped name, remove the old package from the same profile and restart once — the row, its settings and the stored credentials survive.
40
40
 
package/README.zh.md CHANGED
@@ -34,7 +34,7 @@ dsh plugin --profile <name> add @lornatang/dsh-atlassian
34
34
  dsh plugin --profile <name> remove @lornatang/dsh-atlassian
35
35
  ```
36
36
 
37
- 也可以从 GitHub release 附带的压缩包安装同一版本:`dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.13/lornatang-dsh-atlassian-0.1.13.tgz`。
37
+ 也可以从 GitHub release 附带的压缩包安装同一版本:`dsh plugin --profile <name> add https://github.com/Lornatang/dsh-atlassian/releases/download/v0.1.15/lornatang-dsh-atlassian-0.1.15.tgz`。
38
38
 
39
39
  `add` 会把本层组合进 profile:profile 的 `cordis.patch.yml` 会增加一条 insert 记录,行 id 为 `atlassian`,包名为 `@lornatang/dsh-atlassian`,并带上随包提供的补丁中的五个值——`mode: cloud`、`serverName: atlassian`、`url: https://mcp.atlassian.com/v1/mcp`、`redirectPort: 3334` 与 `autoOpenBrowser: true`。包的 manifest 声明了 `dsh.bundle.patch: ./cordis.patch.yml`,reconcile 步骤读取的正是这条声明;`remove` 会再次删除该记录。两条命令执行后都要重启 DSH,因为 profile 只在启动时组合自己的行与客户端部分,随后打开 Settings → Atlassian。0.1.5 之前的版本以 `@lornatang/dsh-atlassian-bridge` 发布;添加带作用域的新名称、从同一 profile 删除旧包、重启一次即可——行、其设置与已保存的凭据都会保留。
40
40
 
package/lib/board.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { decodeToolJson, selectJiraResource } from './jira-resource.js';
1
2
  export class BoardError extends Error {
2
3
  code;
3
4
  constructor(code, message) {
@@ -31,8 +32,15 @@ export class JiraBoard {
31
32
  #resource;
32
33
  #pending;
33
34
  constructor(bridge) { this.#bridge = bridge; }
34
- get site() { return this.#resource?.epoch === (this.#bridge.epoch?.() ?? 0) ? this.#resource.site : undefined; }
35
- async #call(pattern, args, timeoutMs) {
35
+ get site() { return this.#resource?.epoch === this.#epoch() ? this.#resource.site : undefined; }
36
+ #epoch() { return this.#bridge.epoch?.() ?? 0; }
37
+ #checkEpoch(epoch) {
38
+ if (this.#epoch() !== epoch)
39
+ throw new BoardError('not-connected', 'Atlassian connection changed; retry the request');
40
+ }
41
+ async #call(pattern, args, timeoutMs, epoch) {
42
+ if (epoch !== undefined)
43
+ this.#checkEpoch(epoch);
36
44
  const name = this.#bridge.rawNameMatching(pattern);
37
45
  if (!name) {
38
46
  const state = this.#bridge.snapshot?.();
@@ -47,18 +55,26 @@ export class JiraBoard {
47
55
  catch (error) {
48
56
  throw new BoardError('tool-failed', error instanceof Error ? error.message : String(error));
49
57
  }
50
- const raw = blocks.map((entry) => val(obj(entry)['text']) ?? '').join('\n').trim().replace(/^```[a-z]*\s*/i, '').replace(/```\s*$/, '');
51
58
  try {
52
- return JSON.parse(raw);
59
+ return decodeToolJson(blocks);
53
60
  }
54
61
  catch {
55
62
  throw new BoardError('unparsable', 'Jira response is not valid JSON');
56
63
  }
57
64
  }
58
65
  async cloudId() {
59
- const epoch = this.#bridge.epoch?.() ?? 0;
66
+ const resource = await this.#getResource();
67
+ this.#checkEpoch(resource.epoch);
68
+ return resource.id;
69
+ }
70
+ async #getResource() {
71
+ const epoch = this.#epoch();
60
72
  if (this.#resource?.epoch === epoch)
61
- return this.#resource.id;
73
+ return this.#resource;
74
+ // The bridge may already have resolved the site while connecting.
75
+ const shared = this.#bridge.resource?.();
76
+ if (shared?.epoch === epoch)
77
+ return this.#resource = shared;
62
78
  if (this.#pending?.epoch === epoch)
63
79
  return this.#pending.promise;
64
80
  const promise = this.#resolveSite(epoch);
@@ -73,37 +89,21 @@ export class JiraBoard {
73
89
  }
74
90
  async #resolveSite(epoch) {
75
91
  const data = await this.#call(/accessibleatlassianresources/i, {}, 20000);
76
- const list = Array.isArray(data) ? data : [data];
77
- for (const item of list) {
78
- const entry = obj(item);
79
- const id = val(entry['id']);
80
- const url = val(entry['url']);
81
- if (!id || !url)
82
- continue;
83
- try {
84
- const parsed = new URL(url);
85
- if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password)
86
- continue;
87
- // A reconnect may have invalidated this resolution while it was in flight.
88
- if ((this.#bridge.epoch?.() ?? 0) === epoch)
89
- this.#resource = { epoch, id, base: `${parsed.origin}${parsed.pathname.replace(/\/$/, '')}`, site: parsed.host };
90
- return id;
91
- }
92
- catch {
93
- continue;
94
- }
95
- }
96
- throw new BoardError('no-site', 'No accessible Jira site was found');
92
+ this.#checkEpoch(epoch);
93
+ const resource = selectJiraResource(data, (url) => this.#bridge.allowsHttpResource?.(url) ?? false);
94
+ if (!resource)
95
+ throw new BoardError('no-site', 'No accessible Jira site was found');
96
+ return this.#resource = { epoch, ...resource };
97
97
  }
98
98
  async load(query) {
99
- const id = await this.cloudId();
99
+ const { id, base, site, epoch } = await this.#getResource();
100
100
  const fallback = 'updated >= -180d ORDER BY updated DESC';
101
101
  let jql = query.jql?.trim() || fallback;
102
102
  let retried = false;
103
103
  let result;
104
104
  for (;;) {
105
105
  try {
106
- result = obj(await this.#call(/searchJiraIssuesUsingJql/i, { cloudId: id, jql, maxResults: query.limit, fields: ['summary', 'status', 'issuetype', 'priority', 'assignee', 'reporter', 'updated', 'project'] }, query.timeoutMs));
106
+ result = obj(await this.#call(/searchJiraIssuesUsingJql/i, { cloudId: id, jql, maxResults: query.limit, fields: ['summary', 'status', 'issuetype', 'priority', 'assignee', 'reporter', 'updated', 'project'] }, query.timeoutMs, epoch));
107
107
  break;
108
108
  }
109
109
  catch (error) {
@@ -116,21 +116,21 @@ export class JiraBoard {
116
116
  }
117
117
  }
118
118
  const rows = Array.isArray(result['issues']) ? result['issues'] : [];
119
- const issues = rows.map((value) => issue(value, this.#resource?.base)).filter((value) => !!value);
120
- return { issues, constrained: retried, jql, site: this.#resource?.site, cloudId: id, truncated: result['isLast'] === false, limit: query.limit };
119
+ const issues = rows.map((value) => issue(value, base)).filter((value) => !!value);
120
+ return { issues, constrained: retried, jql, site, cloudId: id, truncated: result['isLast'] === false, limit: query.limit };
121
121
  }
122
122
  async detail(key, timeoutMs) {
123
- const id = await this.cloudId();
124
- const data = obj(await this.#call(/^getJiraIssue$/i, { cloudId: id, issueIdOrKey: key, responseContentFormat: 'markdown' }, timeoutMs));
123
+ const { id, base, epoch } = await this.#getResource();
124
+ const data = obj(await this.#call(/^getJiraIssue$/i, { cloudId: id, issueIdOrKey: key, responseContentFormat: 'markdown' }, timeoutMs, epoch));
125
125
  const row = Array.isArray(data['issues']) ? data['issues'][0] : data;
126
- const found = issue(row, this.#resource?.base);
126
+ const found = issue(row, base);
127
127
  if (!found)
128
128
  throw new BoardError('not-found', `Issue ${key} was not found`);
129
129
  return { issue: found, description: val(obj(obj(row)['fields'])['description']) ?? '' };
130
130
  }
131
131
  async transitions(key, timeoutMs) {
132
- const id = await this.cloudId();
133
- const data = obj(await this.#call(/getTransitionsForJiraIssue/i, { cloudId: id, issueIdOrKey: key }, timeoutMs));
132
+ const { id, epoch } = await this.#getResource();
133
+ const data = obj(await this.#call(/getTransitionsForJiraIssue/i, { cloudId: id, issueIdOrKey: key }, timeoutMs, epoch));
134
134
  const rows = Array.isArray(data['transitions']) ? data['transitions'] : [];
135
135
  return rows.map((raw) => {
136
136
  const row = obj(raw);
@@ -140,10 +140,12 @@ export class JiraBoard {
140
140
  }).filter((row) => row.id && row.name);
141
141
  }
142
142
  async transition(key, transitionId, timeoutMs) {
143
- await this.#call(/^transitionJiraIssue$/i, { cloudId: await this.cloudId(), issueIdOrKey: key, transition: { id: transitionId } }, timeoutMs);
143
+ const { id, epoch } = await this.#getResource();
144
+ await this.#call(/^transitionJiraIssue$/i, { cloudId: id, issueIdOrKey: key, transition: { id: transitionId } }, timeoutMs, epoch);
144
145
  }
145
146
  async projects(timeoutMs) {
146
- const data = await this.#call(/getVisibleJiraProjects/i, { cloudId: await this.cloudId() }, timeoutMs);
147
+ const { id, epoch } = await this.#getResource();
148
+ const data = await this.#call(/getVisibleJiraProjects/i, { cloudId: id }, timeoutMs, epoch);
147
149
  const rows = Array.isArray(data) ? data : Array.isArray(obj(data)['values']) ? obj(data)['values'] : [];
148
150
  return rows.map((raw) => { const row = obj(raw); return { key: val(row['key']) ?? '', name: val(row['name']) ?? val(row['key']) ?? '' }; }).filter((row) => row.key).sort((a, b) => a.key.localeCompare(b.key));
149
151
  }
package/lib/bridge.js CHANGED
@@ -3,8 +3,9 @@ import { AsyncLocalStorage } from 'node:async_hooks';
3
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
4
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
5
5
  import { UnauthorizedError, auth } from '@modelcontextprotocol/sdk/client/auth.js';
6
- import { AtlassianOAuthProvider, CallbackServer, RedirectRegistrationChanged, createCloudFetch, secureUrl } from './oauth.js';
6
+ import { AtlassianOAuthProvider, CallbackServer, RedirectRegistrationChanged, createCloudFetch, isLoopbackHost, secureUrl } from './oauth.js';
7
7
  import { OAuthTokensSchema } from '@modelcontextprotocol/sdk/shared/auth.js';
8
+ import { decodeToolJson, selectJiraResource } from './jira-resource.js';
8
9
  import { openInBrowser } from './open-url.js';
9
10
  import { sameTokens } from './store.js';
10
11
  async function waitForFlight(flight, signal) {
@@ -57,6 +58,7 @@ export class AtlassianBridge {
57
58
  #refreshes = new Set();
58
59
  #waiters = new Set();
59
60
  #waiting = false;
61
+ #resource;
60
62
  #allowLoopbackHttp;
61
63
  constructor(host, options) {
62
64
  this.#host = host;
@@ -212,8 +214,19 @@ export class AtlassianBridge {
212
214
  },
213
215
  });
214
216
  }
215
- #newOperation() { return { generation: this.#generation, signal: this.#controller.signal }; }
217
+ #advanceGeneration() {
218
+ this.#generation++;
219
+ this.#resource = undefined;
220
+ this.#controller.abort();
221
+ this.#controller = new AbortController();
222
+ return this.#generation;
223
+ }
216
224
  epoch() { return this.#generation; }
225
+ /** Site resolved during connect, shared with the board to avoid a duplicate MCP call. */
226
+ resource() {
227
+ return this.#status === 'ready' ? this.#resource : undefined;
228
+ }
229
+ allowsHttpResource(url) { return this.#allowLoopbackHttp && isLoopbackHost(url.hostname); }
217
230
  #setStatus(status) { this.#status = status; this.#wake(); }
218
231
  #setUrl(url) { this.#url = url; this.#wake(); }
219
232
  #wake() { const waiters = [...this.#waiters]; this.#waiters.clear(); for (const wake of waiters)
@@ -236,7 +249,7 @@ export class AtlassianBridge {
236
249
  });
237
250
  }
238
251
  snapshot() {
239
- const site = this.#options.store.current.site;
252
+ const site = this.resource()?.site;
240
253
  let mismatch = false;
241
254
  if (site && this.#options.expectedSite.trim()) {
242
255
  try {
@@ -256,7 +269,9 @@ export class AtlassianBridge {
256
269
  async start() {
257
270
  if (this.#boot)
258
271
  return this.#boot;
259
- const generation = this.#generation;
272
+ if (this.#disposed || this.#work || this.#status === 'ready')
273
+ return;
274
+ const generation = this.#advanceGeneration();
260
275
  const boot = (async () => {
261
276
  this.#setStatus('connecting');
262
277
  await this.#options.store.load(this.#controller.signal);
@@ -288,29 +303,39 @@ export class AtlassianBridge {
288
303
  }
289
304
  }
290
305
  async authorize() {
291
- await this.#boot;
306
+ if (this.#boot)
307
+ await this.#boot;
292
308
  if (this.#disposed || this.#status === 'ready')
293
309
  return this.snapshot();
294
- if (!this.#callback.listening)
295
- await this.#callback.listen(this.#options.redirectPort);
296
310
  if (this.#status === 'authorizing' && this.#url) {
297
311
  if (this.#options.autoOpenBrowser)
298
312
  await openInBrowser(this.#url);
299
313
  return this.snapshot();
300
314
  }
301
- if (!this.#work) {
302
- await this.#closeClient();
303
- this.#clearTools();
304
- this.#setUrl(undefined);
305
- this.#launch(true, this.#generation);
306
- }
315
+ if (!this.#work)
316
+ this.#launch(true, this.#advanceGeneration());
307
317
  // Wait for a settled state: the authorization URL is published just before
308
318
  // the status leaves 'connecting', and callers act on the returned status.
309
319
  await this.#waitFor(20000, () => this.#status !== 'connecting');
310
320
  return this.snapshot();
311
321
  }
312
322
  #launch(open, generation) {
313
- const work = this.#connect(open, generation).catch((error) => {
323
+ this.#setStatus('connecting');
324
+ this.#error = undefined;
325
+ const signal = this.#controller.signal;
326
+ const work = Promise.resolve().then(async () => {
327
+ // Assign the flight before the old client closes or a listener starts.
328
+ if (signal.aborted)
329
+ return;
330
+ await this.#closeClient();
331
+ if (signal.aborted)
332
+ return;
333
+ this.#clearTools();
334
+ this.#setUrl(undefined);
335
+ if (!this.#callback.listening)
336
+ await this.#callback.listen(this.#options.redirectPort);
337
+ await this.#connect(open, generation, signal);
338
+ }).catch((error) => {
314
339
  if (!this.#disposed && generation === this.#generation) {
315
340
  this.#setStatus('error');
316
341
  this.#error = error instanceof Error ? error.message : String(error);
@@ -321,14 +346,13 @@ export class AtlassianBridge {
321
346
  void work.finally(() => { if (this.#work === work)
322
347
  this.#work = undefined; });
323
348
  }
324
- async #connect(open, generation) {
325
- const check = () => { if (this.#disposed || generation !== this.#generation)
349
+ async #connect(open, generation, signal) {
350
+ const check = () => { if (signal.aborted)
326
351
  throw new Error('connection cancelled'); };
327
352
  for (let attempt = 0; attempt < 2; attempt++) {
328
353
  check();
329
354
  this.#setStatus('connecting');
330
- this.#error = undefined;
331
- const client = new Client({ name: 'dsh-atlassian', version: '0.1.13' });
355
+ const client = new Client({ name: 'dsh-atlassian', version: '0.1.15' });
332
356
  // Releasing the session lease here would race the SDK's saveTokens; an
333
357
  // exchange that is still in flight is released by its own finally block.
334
358
  client.onerror = () => { const operation = this.#operation.getStore(); if (operation?.exchangePending)
@@ -336,7 +360,7 @@ export class AtlassianBridge {
336
360
  const transport = new StreamableHTTPClientTransport(new URL(this.#options.url), { authProvider: this.#provider, fetch: this.#fetch });
337
361
  const send = transport.send.bind(transport);
338
362
  transport.send = (message, options) => {
339
- const operation = this.#newOperation();
363
+ const operation = { generation, signal };
340
364
  return this.#operation.run(operation, async () => {
341
365
  try {
342
366
  return await send(message, options);
@@ -373,9 +397,9 @@ export class AtlassianBridge {
373
397
  try {
374
398
  const callback = await waiting;
375
399
  check();
376
- await this.#operation.run(this.#newOperation(), () => auth(this.#provider, { serverUrl: this.#options.url, authorizationCode: callback.code, fetchFn: this.#fetch }));
400
+ await this.#operation.run({ generation, signal }, () => auth(this.#provider, { serverUrl: this.#options.url, authorizationCode: callback.code, fetchFn: this.#fetch }));
377
401
  check();
378
- await this.#options.store.clearCredentialsIf(() => !this.#disposed && generation === this.#generation, undefined, undefined, this.#controller.signal, false, 'codeVerifier');
402
+ await this.#options.store.clearCredentialsIf(() => !this.#disposed && generation === this.#generation, undefined, undefined, signal, false, 'codeVerifier');
379
403
  }
380
404
  finally {
381
405
  this.#waiting = false;
@@ -385,7 +409,7 @@ export class AtlassianBridge {
385
409
  this.#client = client;
386
410
  await this.#registerTools(client);
387
411
  check();
388
- await this.#readSite(client, generation, this.#controller.signal);
412
+ await this.#readSite(client, generation, signal);
389
413
  check();
390
414
  this.#setUrl(undefined);
391
415
  this.#setStatus('ready');
@@ -448,13 +472,13 @@ export class AtlassianBridge {
448
472
  return;
449
473
  try {
450
474
  const result = await client.callTool({ name, arguments: {} }, undefined, { timeout: 20000, signal });
451
- const items = JSON.parse(display(result.content));
452
- const first = Array.isArray(items) ? items[0] : items;
453
- if (first && typeof first === 'object' && typeof first['url'] === 'string') {
454
- const reported = new URL(first['url']);
455
- secureUrl(reported, this.#allowLoopbackHttp);
456
- await this.#options.store.patch({ site: reported.host }, () => !this.#disposed && generation === this.#generation && !signal.aborted, undefined, undefined, signal);
457
- }
475
+ if (result.isError || signal.aborted)
476
+ return;
477
+ const site = selectJiraResource(decodeToolJson(result.content), (url) => this.allowsHttpResource(url));
478
+ if (!site)
479
+ return;
480
+ this.#resource = { epoch: generation, ...site };
481
+ await this.#options.store.patch({ site: site.site }, () => !signal.aborted, undefined, undefined, signal);
458
482
  }
459
483
  catch { /* The connection can work without a site label. */ }
460
484
  }
@@ -467,9 +491,7 @@ export class AtlassianBridge {
467
491
  return Array.isArray(result.content) ? result.content : [];
468
492
  }
469
493
  async disconnect() {
470
- this.#generation++;
471
- this.#controller.abort();
472
- this.#controller = new AbortController();
494
+ this.#advanceGeneration();
473
495
  this.#setStatus('idle');
474
496
  this.#callback.cancelWait();
475
497
  await this.#boot?.catch(() => undefined);
@@ -488,6 +510,7 @@ export class AtlassianBridge {
488
510
  return;
489
511
  this.#disposed = true;
490
512
  this.#generation++;
513
+ this.#resource = undefined;
491
514
  this.#controller.abort();
492
515
  this.#setStatus('idle');
493
516
  this.#callback.cancelWait();
package/lib/index.js CHANGED
@@ -22,12 +22,13 @@ export function apply(ctx, config) {
22
22
  const connection = {
23
23
  snapshot: () => ({ ...config.server }),
24
24
  update: async (input) => {
25
- const next = Object.assign(config, configureEndpoints(config, input));
25
+ const next = configureEndpoints(config, input);
26
26
  const editor = scope.get('configEditor');
27
27
  const entry = editor?.entries().find((candidate) => candidate.options.id === 'atlassian');
28
28
  if (!editor || !entry)
29
29
  throw new Error('DSH configuration editor is unavailable');
30
30
  await editor.edit(entry, (current) => configureEndpoints(Config(current), input));
31
+ Object.assign(config, next);
31
32
  if (identityFor(next) !== identity) {
32
33
  // The profile now points at a different endpoint; leave no credentials behind for the old one.
33
34
  void store.destroy().catch((error) => ctx.logger.warn(`atlassian: ${String(error)}`));
@@ -0,0 +1,29 @@
1
+ export function decodeToolJson(content) {
2
+ const blocks = Array.isArray(content) ? content : [];
3
+ const raw = blocks.map((entry) => {
4
+ const text = entry && typeof entry === 'object' ? entry['text'] : undefined;
5
+ return typeof text === 'string' ? text : '';
6
+ }).join('\n').trim().replace(/^```[a-z]*\s*/i, '').replace(/```\s*$/, '');
7
+ return JSON.parse(raw);
8
+ }
9
+ export function selectJiraResource(data, allowsHttp) {
10
+ for (const item of Array.isArray(data) ? data : [data]) {
11
+ if (!item || typeof item !== 'object')
12
+ continue;
13
+ const { id, url } = item;
14
+ if (typeof id !== 'string' || !id.trim() || typeof url !== 'string' || !url.trim())
15
+ continue;
16
+ let parsed;
17
+ try {
18
+ parsed = new URL(url);
19
+ }
20
+ catch {
21
+ continue;
22
+ }
23
+ if (parsed.username || parsed.password)
24
+ continue;
25
+ if (parsed.protocol !== 'https:' && !(parsed.protocol === 'http:' && allowsHttp?.(parsed)))
26
+ continue;
27
+ return { id, base: `${parsed.origin}${parsed.pathname.replace(/\/$/, '')}`, site: parsed.host };
28
+ }
29
+ }
@@ -78,6 +78,7 @@ export class ServerBridge {
78
78
  };
79
79
  }
80
80
  epoch() { return this.#generation; }
81
+ allowsHttpResource() { return this.#config.allowInsecureHttp; }
81
82
  rawNames() { return [...this.#operations.keys()]; }
82
83
  rawNameMatching(pattern) { return this.rawNames().find((name) => pattern.test(name)); }
83
84
  async start() {
@@ -90,7 +91,7 @@ export class ServerBridge {
90
91
  return;
91
92
  this.#credentials = this.#store.current.serverCredentials ?? {};
92
93
  if (this.#credentials.jira || this.#credentials.confluence)
93
- await this.#begin({}, generation);
94
+ await this.#begin({});
94
95
  })();
95
96
  try {
96
97
  await this.#starting;
@@ -104,12 +105,13 @@ export class ServerBridge {
104
105
  if (this.#disposed)
105
106
  return this.snapshot();
106
107
  if (!this.#running)
107
- await this.#begin(input, this.#generation);
108
+ await this.#begin(input);
108
109
  else
109
110
  await this.#running;
110
111
  return this.snapshot();
111
112
  }
112
- async #begin(input, generation) {
113
+ async #begin(input) {
114
+ const generation = ++this.#generation;
113
115
  this.#status = 'connecting';
114
116
  this.#error = undefined;
115
117
  const run = this.#connect(input, generation).catch((error) => {
@@ -1,3 +1,4 @@
1
+ import { type ConnectionResource } from './jira-resource.js';
1
2
  export interface ToolBridge {
2
3
  rawNameMatching(pattern: RegExp): string | undefined;
3
4
  callTool(name: string, args: Record<string, unknown>, timeoutMs?: number): Promise<readonly unknown[]>;
@@ -7,6 +8,9 @@ export interface ToolBridge {
7
8
  };
8
9
  /** Changes whenever the connection is replaced, so cached site data can be invalidated. */
9
10
  epoch?(): number;
11
+ /** Site resolved while connecting, so the first board render need not repeat that MCP call. */
12
+ resource?(): ConnectionResource | undefined;
13
+ allowsHttpResource?(url: URL): boolean;
10
14
  }
11
15
  export interface BoardStatus {
12
16
  name: string;
@@ -1,5 +1,6 @@
1
1
  import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
2
2
  import { type Logger } from './oauth.js';
3
+ import { type ConnectionResource } from './jira-resource.js';
3
4
  import { type SessionStore } from './store.js';
4
5
  export interface BridgeHost {
5
6
  register(definition: ToolDefinition): () => void;
@@ -37,6 +38,9 @@ export declare class AtlassianBridge {
37
38
  #private;
38
39
  constructor(host: BridgeHost, options: BridgeOptions);
39
40
  epoch(): number;
41
+ /** Site resolved during connect, shared with the board to avoid a duplicate MCP call. */
42
+ resource(): ConnectionResource | undefined;
43
+ allowsHttpResource(url: URL): boolean;
40
44
  snapshot(): BridgeSnapshot;
41
45
  rawNames(): readonly string[];
42
46
  rawNameMatching(pattern: RegExp): string | undefined;
@@ -0,0 +1,10 @@
1
+ export interface JiraResource {
2
+ readonly id: string;
3
+ readonly base: string;
4
+ readonly site: string;
5
+ }
6
+ export interface ConnectionResource extends JiraResource {
7
+ readonly epoch: number;
8
+ }
9
+ export declare function decodeToolJson(content: unknown): unknown;
10
+ export declare function selectJiraResource(data: unknown, allowsHttp?: (url: URL) => boolean): JiraResource | undefined;
@@ -13,6 +13,7 @@ export declare class ServerBridge {
13
13
  });
14
14
  snapshot(): BridgeSnapshot;
15
15
  epoch(): number;
16
+ allowsHttpResource(): boolean;
16
17
  rawNames(): readonly string[];
17
18
  rawNameMatching(pattern: RegExp): string | undefined;
18
19
  start(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lornatang/dsh-atlassian",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Connect Atlassian Cloud or self-hosted Jira and Confluence to DeepSeek Harness with tools and a Jira board.",
5
5
  "keywords": [
6
6
  "deepseek-harness",