a2a-bridge-for-mcp-clients 0.2.3 → 0.2.4

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
@@ -91,7 +91,7 @@ To continue a conversation, pass the same `agent` and `contextId`. To answer a t
91
91
 
92
92
  The agent owns its tasks' lifecycle and is asked for their current state; the bridge only keeps its own side, in a private file next to the credentials (`_sessions.json`, shared by all bridge processes, kept for 30 days, at most 500 conversations):
93
93
 
94
- - **Every conversation it starts is saved**: agent, site, routing (target, tenant, extension), the first 80 characters of the first message as a title, and each task's last known state. Follow-ups, `get_agent_task` and `cancel_agent_task` reuse it after a restart too, on the same site only, and `list_agent_tasks` lists them. Each MCP client lists only the conversations it started.
94
+ - **Every conversation it starts is saved**: agent, site, routing (target, tenant, extension), the first 80 characters of the first message as a title (`A2A_BRIDGE_SESSION_TITLES=0` turns titles off: conversations are then listed by start time, and titles saved earlier are removed on the next write), and each task's last known state. Follow-ups, `get_agent_task` and `cancel_agent_task` reuse it after a restart too, on the same site only, and `list_agent_tasks` lists them. Each MCP client lists only the conversations it started.
95
95
  - **An answer goes to the waiting task**: a message with only the `contextId` of a conversation whose task waits for input (`input-required`, `auth-required`) is sent with that task's `taskId`, after the agent confirms (`GetTask`) that it still waits.
96
96
  - **Listing never signs in**: `list_agent_tasks` refreshes states with saved or refreshable credentials only; a site whose sign-in has lapsed is shown as not refreshed.
97
97
  - **An ended task is never resumed**: a message naming a task that completed, failed, was canceled or rejected starts a new task in the same conversation, as A2A requires (Jira's "retry via chat" works the same way).
@@ -347,8 +347,23 @@ Agents may create, edit and delete content with your permissions, and their answ
347
347
  | `A2A_BRIDGE_LOGIN_TIMEOUT_MS` | `300000` |
348
348
  | `A2A_BRIDGE_CARD_TTL_MS` | `3600000` (how long an agent card, and the endpoint and OAuth settings from it, is reused) |
349
349
  | `A2A_BRIDGE_SESSIONS_FILE` | `<credentials dir>/_sessions.json` (saved conversations) |
350
+ | `A2A_BRIDGE_SESSION_TITLES` | on. `0` saves no message text in saved conversations (see [Conversations](#conversations-and-task-lifecycle)) |
351
+ | `A2A_BRIDGE_LOG_PAYLOADS` | off. `1` logs every JSON-RPC request sent to an agent; see [Inspecting what is sent](#inspecting-what-is-sent) |
350
352
  | `A2A_BRIDGE_SECRET_*` | Secrets referenced by profiles |
351
353
 
354
+ ### Inspecting what is sent
355
+
356
+ Set `A2A_BRIDGE_LOG_PAYLOADS=1` in the `env` block of the bridge's entry in your MCP client's configuration, and restart the client. The bridge then writes one line per JSON-RPC request to stderr, which the MCP client keeps in its log (Claude Desktop: `~/Library/Logs/Claude/mcp-server-<name>.log`):
357
+
358
+ ```text
359
+ [a2a-bridge 98221d9b] rovo@abc.atlassian.net request: {"method":"message/stream","url":"https://…","headers":{},"params":{"message":{"role":"user","parts":[{"kind":"text","text":"@engram Use the engram agent …"}],"metadata":{"agentKey":"…"},…}}}
360
+ ```
361
+
362
+ - **What is logged:** the method, the endpoint URL, routing headers (such as `A2A-Extensions`) and the full params: message text, data parts, `metadata`, `contextId` and `taskId`. The 8-character prefix is the start of the `trace:` id shown with the answer, so a line can be matched to its call. Lines are capped at 64 KB.
363
+ - **What is not:** credentials sent as headers (`Authorization` and `auth.valueEnv` header secrets are added separately and never reach the log), the endpoint URL's query string (shown as `?…`), and the agent's answers.
364
+ - **Profile `metadata` and `siteMetadata` are logged verbatim**, like the rest of the message. Never put secrets in them; header secrets belong in `auth.valueEnv`.
365
+ - **Turn it off afterwards.** The log keeps your messages, which can contain confidential content, in a file the MCP client writes outside the bridge's private credentials folder.
366
+
352
367
  Commands: `a2a-bridge [serve]`, `agents`, `login [agent] [--site <host>]`, `logout [agent] [--site <host>]` (without `--site`, `logout` forgets all of the agent's sign-ins), `help` (also `--help`, `-h`: commands, MCP tools, files and environment variables) and `--version`.
353
368
 
354
369
  ## Development
package/dist/a2a.js CHANGED
@@ -441,6 +441,7 @@ export class A2AClient {
441
441
  #quirks;
442
442
  #label;
443
443
  #retry;
444
+ #logPayloads;
444
445
  #nextId = 1;
445
446
  #hintedDeltas = false;
446
447
  /** `auth` supplies bearer tokens; omit it for agents using a static header or no authentication. */
@@ -456,6 +457,7 @@ export class A2AClient {
456
457
  this.#quirks = opts.quirks ?? {};
457
458
  this.#label = opts.label ?? endpoint.url;
458
459
  this.#retry = { ...DEFAULT_RETRY, ...opts.retry };
460
+ this.#logPayloads = opts.logPayloads ?? false;
459
461
  }
460
462
  async sendMessage(msg, routing = {}) {
461
463
  return normaliseSendResult(await this.call(this.#methods.send, buildSendParams(this.endpoint.version, msg, 'poll'), routing));
@@ -579,6 +581,8 @@ export class A2AClient {
579
581
  /** POSTs a JSON-RPC request; with OAuth, on 401 renews the token and retries once. */
580
582
  async #request(method, params, accept, signal, routing) {
581
583
  const target = this.#target(params, routing);
584
+ if (this.#logPayloads)
585
+ log(payloadLine(this.#label, method, target));
582
586
  // Reading or cancelling a task is safe to repeat; sending a message is retried only on 429.
583
587
  const idempotent = [this.#methods.get, this.#methods.cancel, this.#methods.extendedCard, this.#methods.subscribe].includes(method);
584
588
  const post = (credentials) => withRetries(() => this.#post(method, target, accept, signal, credentials), {
@@ -648,6 +652,27 @@ export class A2AClient {
648
652
  });
649
653
  }
650
654
  }
655
+ /** The URL without its query or fragment, which some gateways use for keys. */
656
+ function withoutQuery(url) {
657
+ try {
658
+ const u = new URL(url);
659
+ return `${u.origin}${u.pathname}${u.search || u.hash ? '?…' : ''}`;
660
+ }
661
+ catch {
662
+ return '(unparseable URL)';
663
+ }
664
+ }
665
+ /** At most this much of one logged request, so a large data part cannot flood the log. */
666
+ export const PAYLOAD_LOG_LIMIT = 64 * 1024;
667
+ /**
668
+ * One log line for an outgoing request. Only the routing headers (extensions) are
669
+ * included: credentials are added later, from a separate set, and never reach here.
670
+ */
671
+ export function payloadLine(label, method, target) {
672
+ const json = JSON.stringify({ method, url: withoutQuery(target.url), headers: target.headers, params: target.params });
673
+ const body = json.length > PAYLOAD_LOG_LIMIT ? `${json.slice(0, PAYLOAD_LOG_LIMIT)}… (${json.length - PAYLOAD_LOG_LIMIT} more characters)` : json;
674
+ return `${label} request: ${body}`;
675
+ }
651
676
  function tryParse(text, url) {
652
677
  try {
653
678
  const body = parseJson(text, url);
package/dist/bridge.js CHANGED
@@ -219,6 +219,7 @@ export async function connect(profile, config, fetchFn = fetch, env = process.en
219
219
  quirks,
220
220
  label: site ? `${profile.name}@${site}` : profile.name,
221
221
  ...(headers ? { headers } : {}),
222
+ ...(config.logPayloads ? { logPayloads: true } : {}),
222
223
  });
223
224
  log(`${profile.name}${site ? `@${site}` : ''}: ${card.name ?? 'agent'} at ${endpoint.url} (A2A ${endpoint.version}, ` +
224
225
  `${streaming ? 'streaming' : 'polling'}, auth ${auth.type}${quirks.streamDeltasWithoutAppend ? ', delta quirk' : ''})`);
package/dist/config.js CHANGED
@@ -12,6 +12,16 @@ function positiveInt(env, name, fallback, max = Number.MAX_SAFE_INTEGER) {
12
12
  }
13
13
  return value;
14
14
  }
15
+ function flag(env, name, fallback = false) {
16
+ const raw = (env[name] ?? '').trim().toLowerCase();
17
+ if (raw === '')
18
+ return fallback;
19
+ if (raw === '0' || raw === 'false' || raw === 'no' || raw === 'off')
20
+ return false;
21
+ if (raw === '1' || raw === 'true' || raw === 'yes' || raw === 'on')
22
+ return true;
23
+ throw new Error(`${name} must be 1/true/yes/on or 0/false/no/off, got "${env[name]}"`);
24
+ }
15
25
  export function configDir(env = process.env) {
16
26
  return join(env['XDG_CONFIG_HOME'] || join(homedir(), '.config'), APP_DIR_NAME);
17
27
  }
@@ -28,6 +38,8 @@ export function loadConfig(env = process.env) {
28
38
  cardTtlMs: positiveInt(env, 'A2A_BRIDGE_CARD_TTL_MS', 3_600_000),
29
39
  // In the private credentials directory; `_` keeps it apart from agent names.
30
40
  sessionsFile: env['A2A_BRIDGE_SESSIONS_FILE'] || join(credentialsDir, '_sessions.json'),
41
+ logPayloads: flag(env, 'A2A_BRIDGE_LOG_PAYLOADS'),
42
+ sessionTitles: flag(env, 'A2A_BRIDGE_SESSION_TITLES', true),
31
43
  };
32
44
  }
33
45
  /**
package/dist/help.js CHANGED
@@ -25,6 +25,8 @@ const ENV = [
25
25
  ['A2A_BRIDGE_LOGIN_TIMEOUT_MS', 'browser sign-in (default: 300000)'],
26
26
  ['A2A_BRIDGE_CARD_TTL_MS', 'how long an agent card is reused (default: 3600000)'],
27
27
  ['A2A_BRIDGE_SESSIONS_FILE', 'saved conversations (default: <credentials dir>/_sessions.json)'],
28
+ ['A2A_BRIDGE_SESSION_TITLES', 'save the first 80 characters of each conversation as its title; 0 turns it off (default: on)'],
29
+ ['A2A_BRIDGE_LOG_PAYLOADS', 'log every request sent to an agent, without credentials, to stderr (default: off)'],
28
30
  ['A2A_BRIDGE_SECRET_*', 'secrets named by profiles (clientSecretEnv, valueEnv)'],
29
31
  ['XDG_CONFIG_HOME', 'base of the config dir (default: ~/.config)'],
30
32
  ];
package/dist/server.js CHANGED
@@ -166,7 +166,11 @@ export function createServer(config, profiles, { now = Date.now } = {}) {
166
166
  * states), on disk so follow-ups, polls and cancels reach the same agent,
167
167
  * site and target after a restart too.
168
168
  */
169
- const sessions = new SessionStore(config.sessionsFile, { now, tightenDir: dirname(config.sessionsFile) === config.credentialsDir });
169
+ const sessions = new SessionStore(config.sessionsFile, {
170
+ now,
171
+ tightenDir: dirname(config.sessionsFile) === config.credentialsDir,
172
+ titles: config.sessionTitles,
173
+ });
170
174
  /** The MCP client this server talks to; each client lists only the conversations it started. */
171
175
  const clientName = () => oneLine(server.server.getClientVersion()?.name ?? '', 100) || undefined;
172
176
  /**
@@ -540,7 +544,7 @@ export function createServer(config, profiles, { now = Date.now } = {}) {
540
544
  ...(resultTask ? { taskId: resultTask } : {}),
541
545
  ...(result.kind === 'task' ? { state: result.task.state } : {}),
542
546
  ...(clientName() ? { client: clientName() } : {}),
543
- title: message,
547
+ ...(config.sessionTitles ? { title: message } : {}),
544
548
  ...(entry.target ? { target: entry.target } : {}),
545
549
  route: entry.route,
546
550
  routing: entry.routing,
@@ -635,7 +639,9 @@ export function createServer(config, profiles, { now = Date.now } = {}) {
635
639
  const lines = list.map((s) => {
636
640
  const task = currentTask(s);
637
641
  // Every value on its own line; ids are already restricted to the accepted form.
638
- const head = `- ${s.agent}${s.site ? ` @ ${s.site}` : ''}${s.target ? ` (target ${s.target})` : ''}: "${oneLine(s.title, 100)}"`;
642
+ // Without a title (or with titles turned off), the start time tells conversations apart.
643
+ const label = config.sessionTitles && s.title ? `"${oneLine(s.title, 100)}"` : `started ${when(s.createdAt)}`;
644
+ const head = `- ${s.agent}${s.site ? ` @ ${s.site}` : ''}${s.target ? ` (target ${s.target})` : ''}: ${label}`;
639
645
  const detail = [
640
646
  ` contextId: ${oneLine(s.contextId, 200)}`,
641
647
  task ? ` task ${oneLine(task.id, 200)}: ${task.state} (as of ${when(task.updatedAt)})` : ' no task yet',
package/dist/sessions.js CHANGED
@@ -73,11 +73,13 @@ export class SessionStore {
73
73
  #maxSessions;
74
74
  #maxAgeMs;
75
75
  #now;
76
- constructor(file, { maxSessions = 500, maxAgeMs = 30 * 24 * 3600_000, now = Date.now, tightenDir = false } = {}) {
76
+ #titles;
77
+ constructor(file, { maxSessions = 500, maxAgeMs = 30 * 24 * 3600_000, now = Date.now, tightenDir = false, titles = true } = {}) {
77
78
  this.#file = new PrivateJsonFile(file, { tightenDir, maxBytes: 4 * 1024 * 1024 });
78
79
  this.#maxSessions = maxSessions;
79
80
  this.#maxAgeMs = maxAgeMs;
80
81
  this.#now = now;
82
+ this.#titles = titles;
81
83
  }
82
84
  /** Valid, unexpired sessions, newest first. Never throws: an unreadable store is empty. */
83
85
  async all() {
@@ -116,7 +118,7 @@ export class SessionStore {
116
118
  ...(update.site ? { site: update.site } : {}),
117
119
  ...(update.client ? { client: oneLine(update.client, 100) } : {}),
118
120
  contextId: update.contextId,
119
- title: oneLine(update.title ?? '', TITLE_CHARS),
121
+ title: this.#titles ? oneLine(update.title ?? '', TITLE_CHARS) : '',
120
122
  route: update.route,
121
123
  routing: storedRouting(update.routing),
122
124
  createdAt: now,
@@ -169,6 +171,10 @@ export class SessionStore {
169
171
  .filter((s) => s.updatedAt >= cutoff)
170
172
  .sort((a, b) => b.updatedAt - a.updatedAt)
171
173
  .slice(0, this.#maxSessions);
174
+ // With titles turned off, titles saved earlier go on the next write.
175
+ if (!this.#titles)
176
+ for (const s of kept)
177
+ s.title = '';
172
178
  await this.#file.save({ version: 1, sessions: kept });
173
179
  });
174
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a2a-bridge-for-mcp-clients",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Local stdio MCP server that lets MCP clients talk to A2A agents, with an Atlassian Rovo preset",
5
5
  "mcpName": "io.github.kelemen-marton/a2a-bridge-for-mcp-clients",
6
6
  "keywords": [