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

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
@@ -176,6 +176,16 @@ Profiles live in `~/.config/a2a-bridge-for-mcp-clients/agents.json`. Use `A2A_BR
176
176
  "scopes": ["read:agent:custom", "read:forge-app:jira", "offline_access"],
177
177
  "authorizeParams": { "audience": "api.atlassian.com", "prompt": "consent" }
178
178
  }
179
+ },
180
+
181
+ "forge-tools": {
182
+ "description": "A Forge app that exposes A2A methods as rovo:mcp tools",
183
+ "mcpTools": {
184
+ "url": "https://mcp.atlassian.com/forge/<app-id>",
185
+ "toolPrefix": "my-app-",
186
+ "toolSuffix": "_development"
187
+ },
188
+ "sites": ["abc.atlassian.net"]
179
189
  }
180
190
  }
181
191
  }
@@ -186,6 +196,7 @@ Profiles live in `~/.config/a2a-bridge-for-mcp-clients/agents.json`. Use `A2A_BR
186
196
  | `preset` | `"rovo"` fills in Rovo's card, auth, quirk and hints. Other fields override it. |
187
197
  | `cardUrl` | The agent card. It supplies the endpoint, protocol version, streaming support and OAuth hints. |
188
198
  | `endpoint` | `{ url, version }` for agents without a public card. Overrides the card. The URL may contain `{site}` and `{cloudId}`, filled per site (see the `forge-app` example). |
199
+ | `mcpTools` | Instead of `cardUrl` and `endpoint`: reach the agent through a remote MCP server whose tools implement the A2A methods. `{ url, toolPrefix?, toolSuffix?, tools?, version? }`; see [A2A over MCP tools](#a2a-over-mcp-tools). |
189
200
  | `streaming` | Overrides the card's streaming capability. |
190
201
  | `auth` | Defaults to `{ "type": "oauth" }` (discovery + dynamic client registration). Options: `oauth` with optional `clientId`/`clientSecretEnv` (pre-registered client), `authorizationEndpoint` + `tokenEndpoint` (skips discovery), `scopes`, `issuer`, `resource`, `authorizeParams`, `redirectUri` (see [Callback URLs](#callback-urls)); `header` (`name` + `valueEnv`); `none`. |
191
202
  | `quirks.streamDeltasWithoutAppend` | For agents that stream text deltas with `append: false` while the artifact is still open. The A2A spec says such chunks replace the text, so without this flag only the last chunk would remain. It's on for Rovo (its preset, or any profile whose endpoint host is `a2a.atlassian.com`) and off for everyone else. When a stream looks like this but the flag is off, the bridge logs a hint and keeps following the spec. |
@@ -224,6 +235,24 @@ Forge app REST APIs are called with a pre-registered 3LO client (there is no dyn
224
235
 
225
236
  `audience=api.atlassian.com` and `prompt=consent` in `authorizeParams` are required by Atlassian's 3LO. Not yet verified against a live Forge app: which callback forms the developer console accepts, and whether these tokens name their site the way Rovo's do (if not, the configured site is shown as a label but not checked against the token).
226
237
 
238
+ #### A2A over MCP tools
239
+
240
+ Some agents can't be reached with A2A JSON-RPC over HTTP, but sit behind a remote MCP server whose tools implement the A2A methods. A Forge app, for example, can expose A2A methods as `rovo:mcp` tools at `https://mcp.atlassian.com/forge/<app-id>`; that needs no developer-console app or client secret, only standard MCP authorization. With `mcpTools` in a profile, the bridge runs its usual A2A flow (send, poll, answer an input-required task, cancel, read the card) by calling those tools:
241
+
242
+ | A2A method | Default tool name | Arguments | Tool result |
243
+ | --- | --- | --- | --- |
244
+ | `SendMessage` | `<toolPrefix>send-message<toolSuffix>` | `message` (text), `contextId`, `taskId` (to answer a task that needs input) | `{ "task": <Task> }` (or `{ "message": <Message> }`) |
245
+ | `GetTask` | `<toolPrefix>get-task<toolSuffix>` | `taskId` | the Task |
246
+ | `CancelTask` | `<toolPrefix>cancel-task<toolSuffix>` | `taskId` | the Task |
247
+ | `GetExtendedAgentCard` | `<toolPrefix>describe<toolSuffix>` | none | the AgentCard |
248
+
249
+ - **Tool names.** Gateways often add an app prefix and an environment suffix (`_development`). `toolPrefix` and `toolSuffix` (letters, digits, `_`, `-`, `.`) build the defaults above; `tools` names any of them explicitly, e.g. `"tools": { "GetExtendedAgentCard": "my-app-agent-card" }`. When a tool is missing, the error lists the tools the server does offer.
250
+ - **Results.** A tool returns its A2A object (v1.0 by default; `"version": "1.1"` for 1.1 objects) as JSON text or as `structuredContent`. A gateway's wrapping as `{"content": "<the object as a JSON string>"}` is unwrapped, as Atlassian's Forge gateway adds it. Errors come back as `{ "error": { "code": "TASK_NOT_FOUND", "message": "…" } }`; A2A's error names (`TASK_NOT_FOUND`, `TASK_NOT_CANCELABLE`, `UNSUPPORTED_OPERATION`, …) are treated like the matching JSON-RPC errors, so a task the agent no longer knows is marked lost in [saved conversations](#conversations-and-task-lifecycle). Other codes (an agent's own, such as `TASK_ENDED`) are shown as they are.
251
+ - **Polling only.** A tool call is one request and one response, so there is no streaming (`streaming: true` is rejected) and no MCP task to wait on: the send tool should return the task at once and do the work in the background.
252
+ - **Only text and ids reach the agent.** Tool arguments carry no `tenant`, `A2A-Extensions` header or data part, so [targets](#addressing-agents-behind-an-endpoint) fall back to their text instruction, typed skill input is sent as text, and `metadata` is sent only when the send tool's input schema declares a `metadata` argument (tools usually refuse unknown arguments). The bridge logs each of these once. If the send tool declares `messageId`, each message gets a random one, kept when the message is re-sent after the server drops the MCP session.
253
+ - **Sign-in.** `auth` defaults to OAuth with discovery: the MCP server answers `401` with `WWW-Authenticate: Bearer resource_metadata=…`, its protected-resource metadata names the authorization server, and the bridge registers a client dynamically. `a2a-bridge login forge-tools --site abc.atlassian.net` signs in; pick the site on the consent screen. The scopes requested are the ones the protected-resource metadata lists, unless `auth.scopes` names others.
254
+ - **MCP.** The bridge speaks MCP over Streamable HTTP (JSON or SSE responses), keeps one MCP session per connection and starts a new one when the server drops it. Requests never follow redirects, responses are size-limited, and a 401 renews the token once, as for A2A endpoints.
255
+
227
256
  #### Callback URLs
228
257
 
229
258
  The callback URL registered with the provider and the profile's `auth.redirectUri` must match. The bridge supports:
@@ -320,7 +349,7 @@ An instruction is only a request to the receiving agent's model; whether Rovo ha
320
349
 
321
350
  ## How it works
322
351
 
323
- 1. **Endpoint.** Reads the agent card, or the profile's `endpoint`, to pick the JSON-RPC endpoint and the protocol version (v0.3, v1.0 or v1.1; later 1.x minors are spoken as 1.1). For v1.1 it sends `A2A-Version: 1.1`, reads the task `timeline` when there is no `history`, uses `generation` to tell task snapshots apart, records `messageUpdate` events, reports a `StreamError` as a failure, and skips stream payloads it does not know.
352
+ 1. **Endpoint.** Reads the agent card, or the profile's `endpoint`, to pick the JSON-RPC endpoint and the protocol version (or, with `mcpTools`, calls an MCP server's tools instead; see [A2A over MCP tools](#a2a-over-mcp-tools)) (v0.3, v1.0 or v1.1; later 1.x minors are spoken as 1.1). For v1.1 it sends `A2A-Version: 1.1`, reads the task `timeline` when there is no `history`, uses `generation` to tell task snapshots apart, records `messageUpdate` events, reports a `StreamError` as a failure, and skips stream payloads it does not know.
324
353
  2. **OAuth discovery.** For OAuth agents, it reads RFC 9728 protected-resource metadata, then RFC 8414 authorization-server metadata, checking the issuer and resource. If that metadata is missing, it falls back to the card's `securitySchemes` and its DCR extension. A profile can also set the OAuth endpoints directly.
325
354
  3. **Sign-in.** Registers a public client via dynamic client registration, unless the profile names a pre-registered client. Then it runs authorization code + PKCE (S256), with a loopback redirect to `http://127.0.0.1:33418/callback`.
326
355
  4. **Streaming.** Uses `message/stream` (SSE) when the agent supports it. Streaming keeps each exchange in one request, which avoids per-conversation limits on asynchronous tasks (Rovo has one) and proxy timeouts. If the stream drops before the task settles, the bridge re-attaches with `SubscribeToTask` (`tasks/resubscribe` in v0.3) up to twice, then follows the task with `GetTask`. Otherwise it sends a non-blocking `message/send` and polls.
@@ -348,7 +377,7 @@ Agents may create, edit and delete content with your permissions, and their answ
348
377
  | `A2A_BRIDGE_CARD_TTL_MS` | `3600000` (how long an agent card, and the endpoint and OAuth settings from it, is reused) |
349
378
  | `A2A_BRIDGE_SESSIONS_FILE` | `<credentials dir>/_sessions.json` (saved conversations) |
350
379
  | `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) |
380
+ | `A2A_BRIDGE_LOG_PAYLOADS` | off. `1` logs every JSON-RPC request (or MCP tool call) sent to an agent; see [Inspecting what is sent](#inspecting-what-is-sent) |
352
381
  | `A2A_BRIDGE_SECRET_*` | Secrets referenced by profiles |
353
382
 
354
383
  ### Inspecting what is sent
package/dist/a2a.js CHANGED
@@ -206,7 +206,7 @@ export function normaliseSendResult(raw) {
206
206
  return { kind: 'task', task: normaliseTask(raw) };
207
207
  }
208
208
  /** GetTask/CancelTask return a bare Task, but tolerate a `{task}` wrapper too. */
209
- function unwrapTask(raw) {
209
+ export function unwrapTask(raw) {
210
210
  return normaliseTask(isObject(raw) && isObject(raw['task']) ? raw['task'] : raw);
211
211
  }
212
212
  /** The best human-readable answer a task currently has. */
@@ -121,6 +121,14 @@ export function planRoute(addressed, { card, endpoint, site }) {
121
121
  // 1. own card/URL: already resolved to another profile.
122
122
  if (target.agent)
123
123
  return finish({ route: 'agent', routing: {}, text });
124
+ // Tool calls carry only the message text and ids: no tenant, no extension headers.
125
+ if (endpoint.transport === 'mcp-tools') {
126
+ if (target.tenant)
127
+ notes.push('tenant routing cannot be carried over MCP tools');
128
+ if (target.extension)
129
+ notes.push(`extension ${target.extension.uri} cannot be activated over MCP tools`);
130
+ return finish({ route: 'instruction', routing: {}, text: renderInstruction(target.instruction ?? DEFAULT_INSTRUCTION, target.name, text) });
131
+ }
124
132
  // 2. tenant: declared on the card, by the configured value or the target's name.
125
133
  if (isV1(endpoint.version)) {
126
134
  const wanted = target.tenant ?? target.name;
package/dist/bridge.js CHANGED
@@ -1,4 +1,4 @@
1
- /** Wires one agent profile (and site) to card discovery, authentication and an A2A client. */
1
+ /** Wires one agent profile (and site) to card discovery, authentication and an A2A client (or MCP tools). */
2
2
  import { readdir } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
4
  import { A2AClient, JsonRpcError } from './a2a.js';
@@ -6,6 +6,7 @@ import { advertisesExtendedCard, fetchAgentCard, mergeCards, oauthHints, selectE
6
6
  import { credentialsFile } from './config.js';
7
7
  import { assertNoDowngrade, assertSecureUrl, errorMessage, HttpError } from './http.js';
8
8
  import { log } from './log.js';
9
+ import { McpProtocolError, McpToolError, McpToolsClient } from './mcp-tools.js';
9
10
  import { configuredAuthServer, discoverAuthServer, OAuthSession } from './oauth.js';
10
11
  import { readSecret, ROVO_HOST } from './profiles.js';
11
12
  import { atlassianTokenSites, fillEndpoint, identifySite, isAtlassianIssuer, lookupCloudId, normaliseSite, SiteMismatchError } from './sites.js';
@@ -167,13 +168,20 @@ export async function connect(profile, config, fetchFn = fetch, env = process.en
167
168
  if (site && !profile.sites.includes(site))
168
169
  throw new Error(`Agent "${profile.name}" has no site ${site}`);
169
170
  const card = profile.cardUrl ? await fetchAgentCard(profile.cardUrl, fetchFn) : {};
170
- // A per-site endpoint ({site}/{cloudId}) is filled for this site.
171
- const endpoint = profile.endpoint ? { ...profile.endpoint, url: await fillEndpoint(profile.endpoint.url, site, fetchFn) } : selectEndpoint(card);
172
- assertSecureUrl(endpoint.url, `A2A endpoint of "${profile.name}"`);
171
+ const { mcpTools } = profile;
172
+ // A per-site endpoint ({site}/{cloudId}) is filled for this site. Over MCP tools, the endpoint is the MCP server.
173
+ const endpoint = mcpTools
174
+ ? { url: mcpTools.url, version: mcpTools.version, transport: 'mcp-tools' }
175
+ : profile.endpoint
176
+ ? { ...profile.endpoint, url: await fillEndpoint(profile.endpoint.url, site, fetchFn) }
177
+ : selectEndpoint(card);
178
+ assertSecureUrl(endpoint.url, `${mcpTools ? 'MCP server' : 'A2A endpoint'} of "${profile.name}"`);
173
179
  // An endpoint from an HTTPS card must be HTTPS too (no cleartext loopback).
174
180
  if (!profile.endpoint && profile.cardUrl)
175
181
  assertNoDowngrade(endpoint.url, profile.cardUrl, `A2A endpoint of "${profile.name}"`);
176
- const streaming = profile.streaming ?? card.capabilities?.streaming === true;
182
+ // Tool calls are request/response: nothing to stream.
183
+ const canStream = !mcpTools;
184
+ const streaming = canStream && (profile.streaming ?? card.capabilities?.streaming === true);
177
185
  const quirks = resolveQuirks(profile, endpoint);
178
186
  let oauth;
179
187
  let headers;
@@ -213,25 +221,29 @@ export async function connect(profile, config, fetchFn = fetch, env = process.en
213
221
  else if (auth.type === 'header') {
214
222
  headers = { [auth.name]: readSecret(auth.valueEnv, env) };
215
223
  }
216
- const client = new A2AClient(endpoint, oauth, {
224
+ const clientOptions = {
217
225
  fetchFn,
218
226
  requestTimeoutMs: config.requestTimeoutMs,
219
- quirks,
220
227
  label: site ? `${profile.name}@${site}` : profile.name,
221
228
  ...(headers ? { headers } : {}),
222
229
  ...(config.logPayloads ? { logPayloads: true } : {}),
223
- });
224
- log(`${profile.name}${site ? `@${site}` : ''}: ${card.name ?? 'agent'} at ${endpoint.url} (A2A ${endpoint.version}, ` +
225
- `${streaming ? 'streaming' : 'polling'}, auth ${auth.type}${quirks.streamDeltasWithoutAppend ? ', delta quirk' : ''})`);
230
+ };
231
+ const client = mcpTools
232
+ ? new McpToolsClient(endpoint, mcpTools.tools, oauth, clientOptions)
233
+ : new A2AClient(endpoint, oauth, { ...clientOptions, quirks });
234
+ log(`${profile.name}${site ? `@${site}` : ''}: ${card.name ?? 'agent'} at ${endpoint.url} (A2A ${endpoint.version}` +
235
+ `${mcpTools ? ' over MCP tools' : ''}, ${streaming ? 'streaming' : 'polling'}, auth ${auth.type}` +
236
+ `${quirks.streamDeltasWithoutAppend && !mcpTools ? ', delta quirk' : ''})`);
226
237
  /**
227
238
  * The card to work with, resolved once per connection (lazily, after
228
239
  * sign-in) along a fallback chain:
229
240
  * 1. the profile's `cardUrl`, fetched publicly (already in `card`);
230
241
  * 2. without one, `<endpoint>/.well-known/agent-card.json` with the
231
242
  * agent's credentials (e.g. a Forge apiRoute GET route, which always
232
- * needs a token);
243
+ * needs a token); not over MCP tools;
233
244
  * 3. the authenticated extended card (`GetExtendedAgentCard`), when the
234
- * card so far advertises it, or when there is no card at all.
245
+ * card so far advertises it, or when there is no card at all (over
246
+ * MCP tools: always, from the card tool).
235
247
  * Cards from 2 and 3 contribute skills, capabilities and descriptions only:
236
248
  * endpoints and security schemes come from the profile or the public card.
237
249
  * An HTTP or JSON-RPC error answer means that card does not exist; any
@@ -240,12 +252,13 @@ export async function connect(profile, config, fetchFn = fetch, env = process.en
240
252
  */
241
253
  let resolving;
242
254
  let fetchedValue;
243
- const isNoCard = (err) => err instanceof HttpError || err instanceof JsonRpcError;
255
+ // A JSON-RPC error includes A2A and MCP errors from tools; a failed card tool means no card either.
256
+ const isNoCard = (err) => err instanceof HttpError || err instanceof JsonRpcError || err instanceof McpProtocolError || err instanceof McpToolError;
244
257
  const fetchCards = () => {
245
258
  resolving ??= (async () => {
246
259
  const asCard = (raw) => typeof raw === 'object' && raw !== null && !Array.isArray(raw) ? raw : undefined;
247
260
  let fetched;
248
- if (!profile.cardUrl) {
261
+ if (!profile.cardUrl && client.getEndpointCard) {
249
262
  try {
250
263
  fetched = asCard(await client.getEndpointCard());
251
264
  }
@@ -256,7 +269,7 @@ export async function connect(profile, config, fetchFn = fetch, env = process.en
256
269
  }
257
270
  }
258
271
  const known = mergeCards(card, fetched);
259
- const wanted = advertisesExtendedCard(known) || (!profile.cardUrl && !fetched && auth.type !== 'none');
272
+ const wanted = advertisesExtendedCard(known) || (!profile.cardUrl && !fetched && (auth.type !== 'none' || Boolean(mcpTools)));
260
273
  if (wanted) {
261
274
  try {
262
275
  const extended = asCard(await client.getExtendedCard());
@@ -282,7 +295,7 @@ export async function connect(profile, config, fetchFn = fetch, env = process.en
282
295
  return {
283
296
  card: effective,
284
297
  hasCard: Boolean(profile.cardUrl) || fetched !== undefined,
285
- streaming: profile.streaming ?? (fetched ? effective.capabilities?.streaming === true : streaming),
298
+ streaming: canStream && (profile.streaming ?? (fetched ? effective.capabilities?.streaming === true : streaming)),
286
299
  };
287
300
  };
288
301
  const session = oauth;
@@ -0,0 +1,466 @@
1
+ /**
2
+ * A2A carried over MCP tools. Some agents are reachable only as a remote MCP
3
+ * server whose tools implement the A2A methods (for example a Forge app that
4
+ * exposes them as `rovo:mcp` tools). This client speaks MCP (Streamable HTTP,
5
+ * tools only) and maps the bridge's A2A calls onto those tools:
6
+ *
7
+ * SendMessage -> <send tool>({ message, contextId?, taskId? }) -> { task } or { message }
8
+ * GetTask -> <get tool>({ taskId }) -> Task
9
+ * CancelTask -> <cancel tool>({ taskId }) -> Task
10
+ * GetExtendedAgentCard -> <card tool>({}) -> AgentCard
11
+ *
12
+ * A tool returns its A2A object as JSON text (or `structuredContent`); errors
13
+ * come back as `{ "error": { "code": "TASK_NOT_FOUND", "message": ... } }`.
14
+ * Polling only: there is no stream to follow and no MCP task to wait on.
15
+ */
16
+ import { randomUUID } from 'node:crypto';
17
+ import { CallToolResultSchema, InitializeResultSchema, LATEST_PROTOCOL_VERSION, ListToolsResultSchema, SUPPORTED_PROTOCOL_VERSIONS, } from '@modelcontextprotocol/sdk/types.js';
18
+ import { JsonRpcError, normaliseSendResult, payloadLine, unwrapTask, } from './a2a.js';
19
+ import { assertSecureUrl, HttpError, MAX_RESPONSE_BYTES, parseJson, readTextLimited } from './http.js';
20
+ import { log } from './log.js';
21
+ import { APP_NAME, VERSION } from './meta.js';
22
+ import { DEFAULT_RETRY, withRetries } from './retry.js';
23
+ import { sseData } from './sse.js';
24
+ import { oneLine } from './text.js';
25
+ import { currentTrace, traceparent } from './trace.js';
26
+ // ---------------------------------------------------------------- Tool names
27
+ export const A2A_METHODS = ['SendMessage', 'GetTask', 'CancelTask', 'GetExtendedAgentCard'];
28
+ /** Default tool names, between the profile's prefix and suffix: `<prefix>send-message<suffix>`. */
29
+ export const DEFAULT_TOOL_STEMS = {
30
+ SendMessage: 'send-message',
31
+ GetTask: 'get-task',
32
+ CancelTask: 'cancel-task',
33
+ GetExtendedAgentCard: 'describe',
34
+ };
35
+ /** MCP tool names: 1–128 of letters, digits, `_`, `-` and `.`. */
36
+ export const TOOL_NAME = /^[A-Za-z0-9_.-]{1,128}$/;
37
+ /** The tool for each A2A method: an explicit name, else prefix + default stem + suffix. */
38
+ export function toolNames(prefix = '', suffix = '', overrides = {}) {
39
+ const names = {};
40
+ for (const method of A2A_METHODS) {
41
+ const name = overrides[method] ?? `${prefix}${DEFAULT_TOOL_STEMS[method]}${suffix}`;
42
+ if (!TOOL_NAME.test(name))
43
+ throw new Error(`Tool name for ${method} is not a valid MCP tool name: ${name}`);
44
+ names[method] = name;
45
+ }
46
+ return names;
47
+ }
48
+ const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
49
+ /** A2A error names (proto/REST `reason`s) and their JSON-RPC codes, so callers can tell them apart. */
50
+ const A2A_ERROR_CODES = {
51
+ TASK_NOT_FOUND: -32001,
52
+ TASK_NOT_CANCELABLE: -32002,
53
+ PUSH_NOTIFICATION_NOT_SUPPORTED: -32003,
54
+ UNSUPPORTED_OPERATION: -32004,
55
+ CONTENT_TYPE_NOT_SUPPORTED: -32005,
56
+ INVALID_AGENT_RESPONSE: -32006,
57
+ EXTENDED_AGENT_CARD_NOT_CONFIGURED: -32007,
58
+ EXTENSION_SUPPORT_REQUIRED: -32008,
59
+ VERSION_NOT_SUPPORTED: -32009,
60
+ INVALID_REQUEST: -32600,
61
+ METHOD_NOT_FOUND: -32601,
62
+ INVALID_PARAMS: -32602,
63
+ INTERNAL: -32603,
64
+ };
65
+ /** For agent-specific reasons the spec does not name (e.g. `TASK_ENDED`). */
66
+ const UNKNOWN_REASON_CODE = -32603;
67
+ /** `TaskNotFoundError` or `taskNotFound` -> `TASK_NOT_FOUND`; `TASK_NOT_FOUND` stays as it is. */
68
+ export function errorReason(code) {
69
+ return code
70
+ .replace(/Error$/, '')
71
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
72
+ .toUpperCase();
73
+ }
74
+ /** An A2A error an agent returned from a tool; `code` is the matching JSON-RPC code. */
75
+ export class A2AToolError extends JsonRpcError {
76
+ reason;
77
+ constructor(reason, code, message) {
78
+ super(code, message);
79
+ this.name = 'A2AToolError';
80
+ this.reason = reason;
81
+ this.message = `A2A error ${oneLine(reason, 60)}: ${oneLine(message, 300)}`;
82
+ }
83
+ }
84
+ function a2aToolError(error) {
85
+ const message = typeof error['message'] === 'string' ? error['message'] : 'Unknown error';
86
+ if (typeof error['code'] === 'number') {
87
+ const known = Object.entries(A2A_ERROR_CODES).find(([, code]) => code === error['code'])?.[0];
88
+ return new A2AToolError(known ?? String(error['code']), error['code'], message);
89
+ }
90
+ const reason = errorReason(String(error['code']));
91
+ return new A2AToolError(reason, A2A_ERROR_CODES[reason] ?? UNKNOWN_REASON_CODE, message);
92
+ }
93
+ /** The tool itself failed (MCP `isError`): the text is the server's or agent's explanation. */
94
+ export class McpToolError extends Error {
95
+ tool;
96
+ constructor(tool, text) {
97
+ super(`The ${oneLine(tool, 128)} tool failed${text ? `: ${oneLine(text, 300)}` : ''}`);
98
+ this.name = 'McpToolError';
99
+ this.tool = tool;
100
+ }
101
+ }
102
+ /**
103
+ * MCP-level JSON-RPC errors (unknown tool, invalid arguments, ...). Not a
104
+ * `JsonRpcError`: MCP and A2A reuse the same codes for different things
105
+ * (-32001 is a request timeout in MCP but TaskNotFound in A2A).
106
+ */
107
+ export class McpProtocolError extends Error {
108
+ code;
109
+ data;
110
+ constructor(code, message, data) {
111
+ super(`MCP error ${code}: ${oneLine(message, 300)}`);
112
+ this.name = 'McpProtocolError';
113
+ this.code = code;
114
+ this.data = data;
115
+ }
116
+ }
117
+ /** How many `{"content": "<JSON>"}` layers are unwrapped. */
118
+ const MAX_WRAPPING = 2;
119
+ /**
120
+ * A gateway may wrap a tool's return value as `{"content": "<the value as a
121
+ * JSON string>"}` (Atlassian's Forge MCP gateway does), so the text content is
122
+ * JSON whose only field holds more JSON. An object with exactly that one string
123
+ * field is unwrapped; no A2A object has that shape.
124
+ */
125
+ export function unwrapContent(value, tool) {
126
+ let current = value;
127
+ for (let i = 0; i < MAX_WRAPPING; i++) {
128
+ if (!isObject(current) || typeof current['content'] !== 'string' || Object.keys(current).length !== 1)
129
+ return current;
130
+ current = parseToolJson(current['content'], tool);
131
+ }
132
+ return current;
133
+ }
134
+ function parseToolJson(text, tool) {
135
+ try {
136
+ return JSON.parse(text);
137
+ }
138
+ catch {
139
+ throw new Error(`The ${oneLine(tool, 128)} tool returned text, not an A2A object: ${oneLine(text, 200)}`);
140
+ }
141
+ }
142
+ /**
143
+ * The A2A object a tool returned: `structuredContent`, else the text content
144
+ * parsed as JSON, unwrapped from a gateway's `{"content": ...}`. Throws for
145
+ * tool failures and for A2A errors (`{"error": {"code", "message"}}`).
146
+ */
147
+ export function toolPayload(result, tool) {
148
+ const text = result.content
149
+ .filter((c) => c.type === 'text')
150
+ .map((c) => c.text)
151
+ .join('');
152
+ if (result.isError)
153
+ throw new McpToolError(tool, text);
154
+ const raw = result.structuredContent ?? (text ? parseToolJson(text, tool) : undefined);
155
+ const value = unwrapContent(raw, tool);
156
+ if (isObject(value) && isObject(value['error']) && ['string', 'number'].includes(typeof value['error']['code'])) {
157
+ throw a2aToolError(value['error']);
158
+ }
159
+ if (!isObject(value))
160
+ throw new Error(`The ${oneLine(tool, 128)} tool did not return an A2A object`);
161
+ return value;
162
+ }
163
+ // ---------------------------------------------------------------- MCP over Streamable HTTP
164
+ /** Bounds on one SSE response, so a misbehaving server cannot exhaust memory. */
165
+ const SSE_LIMITS = { maxEventBytes: MAX_RESPONSE_BYTES, maxTotalBytes: 2 * MAX_RESPONSE_BYTES };
166
+ /** Pages of tools/list read at most. */
167
+ const MAX_TOOL_PAGES = 20;
168
+ /** Names of other tools kept for the "no such tool" error message. */
169
+ const MAX_OTHER_TOOLS = 30;
170
+ /** A session id must be visible ASCII (MCP Streamable HTTP). */
171
+ const SESSION_ID = /^[\x21-\x7e]{1,512}$/;
172
+ /** The server dropped our session (HTTP 404 with a session id): start a new one. */
173
+ class SessionExpired extends Error {
174
+ constructor(url) {
175
+ super(`The MCP server at ${url} ended the session`);
176
+ this.name = 'SessionExpired';
177
+ }
178
+ }
179
+ /** Rejects with a `TimeoutError` (like `AbortSignal.timeout`) if `promise` takes longer than `ms`. */
180
+ function within(promise, ms, what) {
181
+ if (ms === undefined)
182
+ return promise;
183
+ let timer;
184
+ const timeout = new Promise((_, reject) => {
185
+ timer = setTimeout(() => reject(new DOMException(`${what} took longer than ${ms} ms`, 'TimeoutError')), Math.max(0, ms));
186
+ });
187
+ return Promise.race([promise, timeout]).finally(() => clearTimeout(timer));
188
+ }
189
+ export class McpToolsClient {
190
+ endpoint;
191
+ tools;
192
+ #auth;
193
+ #headers;
194
+ #fetch;
195
+ #timeoutMs;
196
+ #label;
197
+ #retry;
198
+ #logPayloads;
199
+ #warned = new Set();
200
+ #session;
201
+ #nextId = 1;
202
+ /** `endpoint.url` is the MCP server; `endpoint.version` the A2A version of the objects its tools return. */
203
+ constructor(endpoint, tools, auth, opts = {}) {
204
+ // Credentials are only ever sent to this URL.
205
+ assertSecureUrl(endpoint.url, 'MCP server');
206
+ this.endpoint = endpoint;
207
+ this.tools = tools;
208
+ this.#auth = auth;
209
+ this.#headers = auth ? {} : { ...opts.headers };
210
+ this.#fetch = opts.fetchFn ?? fetch;
211
+ this.#timeoutMs = opts.requestTimeoutMs ?? 120_000;
212
+ this.#label = opts.label ?? endpoint.url;
213
+ this.#retry = { ...DEFAULT_RETRY, ...opts.retry };
214
+ this.#logPayloads = opts.logPayloads ?? false;
215
+ }
216
+ async sendMessage(msg, routing = {}) {
217
+ if (msg.data)
218
+ throw new Error('Typed (data part) input cannot be sent over MCP tools; send text instead');
219
+ this.#ignoreRouting(routing);
220
+ // One id for every attempt, so an agent that deduplicates by messageId sees a re-sent message once.
221
+ const messageId = randomUUID();
222
+ const args = (session) => {
223
+ const args = {
224
+ message: msg.text,
225
+ ...(msg.contextId ? { contextId: msg.contextId } : {}),
226
+ ...(msg.taskId ? { taskId: msg.taskId } : {}),
227
+ };
228
+ // Tools often refuse unknown arguments, so optional ones go only where the tool declares them.
229
+ if (session.sendArgs.has('messageId'))
230
+ args['messageId'] = messageId;
231
+ if (msg.metadata && Object.keys(msg.metadata).length) {
232
+ if (session.sendArgs.has('metadata'))
233
+ args['metadata'] = msg.metadata;
234
+ else
235
+ this.#warnOnce('metadata', `${this.#label}: the ${this.tools.SendMessage} tool takes no metadata, so message metadata is not sent`);
236
+ }
237
+ return args;
238
+ };
239
+ // A send is repeated only on 429 (like A2A's SendMessage) or when the server says it dropped the session.
240
+ return normaliseSendResult(await this.#callTool('SendMessage', args, { idempotent: false }));
241
+ }
242
+ streamMessage() {
243
+ return Promise.reject(new Error('Streaming is not available over MCP tools'));
244
+ }
245
+ async getTask(id, routing = {}, { timeoutMs } = {}) {
246
+ this.#ignoreRouting(routing);
247
+ return unwrapTask(await this.#callTool('GetTask', { taskId: id }, { idempotent: true, ...(timeoutMs !== undefined ? { timeoutMs } : {}) }));
248
+ }
249
+ async cancelTask(id, routing = {}) {
250
+ this.#ignoreRouting(routing);
251
+ return unwrapTask(await this.#callTool('CancelTask', { taskId: id }, { idempotent: true }));
252
+ }
253
+ async getExtendedCard() {
254
+ return this.#callTool('GetExtendedAgentCard', {}, { idempotent: true });
255
+ }
256
+ /**
257
+ * Calls the tool for `method`, starting a new MCP session once if the server
258
+ * dropped ours. `timeoutMs` bounds the whole call, session setup included.
259
+ */
260
+ async #callTool(method, argsFor, { idempotent, timeoutMs }) {
261
+ const name = this.tools[method];
262
+ const deadline = timeoutMs === undefined ? undefined : Date.now() + timeoutMs;
263
+ const remaining = () => (deadline === undefined ? undefined : Math.max(1, deadline - Date.now()));
264
+ for (let attempt = 0;; attempt++) {
265
+ const current = this.#currentSession();
266
+ try {
267
+ const session = await within(current, remaining(), 'Starting the MCP session');
268
+ if (!session.tools.has(name)) {
269
+ const offered = [...session.tools, ...session.others].join(', ');
270
+ throw new McpProtocolError(-32601, `The MCP server has no tool ${name} (for A2A ${method}). Its tools: ${offered || 'none'}`);
271
+ }
272
+ const args = typeof argsFor === 'function' ? argsFor(session) : argsFor;
273
+ if (this.#logPayloads) {
274
+ log(payloadLine(this.#label, `tools/call ${name}`, { url: this.endpoint.url, params: args, headers: {} }));
275
+ }
276
+ const left = remaining();
277
+ const raw = await this.#rpc(session, 'tools/call', { name, arguments: args }, { idempotent, ...(left !== undefined ? { timeoutMs: left } : {}) });
278
+ const parsed = CallToolResultSchema.safeParse(raw);
279
+ if (!parsed.success)
280
+ throw new Error(`Malformed tools/call result from ${this.endpoint.url}`);
281
+ return toolPayload(parsed.data, name);
282
+ }
283
+ catch (err) {
284
+ if (!(err instanceof SessionExpired) || attempt > 0)
285
+ throw err;
286
+ if (this.#session === current)
287
+ this.#session = undefined;
288
+ log(`${this.#label}: the MCP server ended the session; starting a new one`);
289
+ }
290
+ }
291
+ }
292
+ /** The current MCP session, initialised on first use (and again after a failed attempt). */
293
+ #currentSession() {
294
+ if (!this.#session) {
295
+ const starting = this.#initialize();
296
+ this.#session = starting;
297
+ starting.catch(() => {
298
+ if (this.#session === starting)
299
+ this.#session = undefined;
300
+ });
301
+ }
302
+ return this.#session;
303
+ }
304
+ async #initialize() {
305
+ // One deadline for the whole setup, however many requests it takes.
306
+ const signal = AbortSignal.timeout(this.#timeoutMs);
307
+ const pending = { protocolVersion: LATEST_PROTOCOL_VERSION, tools: new Set(), sendArgs: new Set(), others: [] };
308
+ const { result, sessionId } = await this.#exchange(pending, 'initialize', { protocolVersion: LATEST_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: APP_NAME, version: VERSION } }, { idempotent: true, signal });
309
+ const init = InitializeResultSchema.safeParse(result);
310
+ if (!init.success)
311
+ throw new Error(`Malformed initialize result from ${this.endpoint.url}`);
312
+ if (!SUPPORTED_PROTOCOL_VERSIONS.includes(init.data.protocolVersion)) {
313
+ throw new Error(`The MCP server at ${this.endpoint.url} speaks MCP ${oneLine(init.data.protocolVersion, 40)}, which this bridge does not`);
314
+ }
315
+ if (!init.data.capabilities.tools)
316
+ throw new Error(`The MCP server at ${this.endpoint.url} offers no tools`);
317
+ const session = { protocolVersion: init.data.protocolVersion, tools: new Set(), sendArgs: new Set(), others: [] };
318
+ if (sessionId) {
319
+ if (!SESSION_ID.test(sessionId))
320
+ throw new Error(`The MCP server at ${this.endpoint.url} sent an invalid session id`);
321
+ session.id = sessionId;
322
+ }
323
+ await this.#notify(session, 'notifications/initialized', signal);
324
+ // Only what the bridge uses is kept, and listing stops once every configured tool is found.
325
+ const wanted = new Set(Object.values(this.tools));
326
+ let cursor;
327
+ for (let page = 0; page < MAX_TOOL_PAGES && session.tools.size < wanted.size; page++) {
328
+ const list = ListToolsResultSchema.safeParse(await this.#rpc(session, 'tools/list', cursor ? { cursor } : {}, { idempotent: true, signal }));
329
+ if (!list.success)
330
+ throw new Error(`Malformed tools/list result from ${this.endpoint.url}`);
331
+ for (const tool of list.data.tools) {
332
+ if (wanted.has(tool.name)) {
333
+ session.tools.add(tool.name);
334
+ if (tool.name === this.tools.SendMessage)
335
+ session.sendArgs = new Set(Object.keys(tool.inputSchema.properties ?? {}));
336
+ }
337
+ else if (session.others.length < MAX_OTHER_TOOLS) {
338
+ session.others.push(oneLine(tool.name, 128));
339
+ }
340
+ }
341
+ cursor = list.data.nextCursor;
342
+ if (!cursor)
343
+ break;
344
+ }
345
+ const missing = A2A_METHODS.filter((m) => !session.tools.has(this.tools[m]));
346
+ if (missing.length)
347
+ log(`${this.#label}: the MCP server has no tool for ${missing.map((m) => `${m} (${this.tools[m]})`).join(', ')}`);
348
+ return session;
349
+ }
350
+ /** One JSON-RPC request; returns its `result`. */
351
+ async #rpc(session, method, params, opts) {
352
+ return (await this.#exchange(session, method, params, opts)).result;
353
+ }
354
+ /** `signal` (a shared deadline) or else `timeoutMs` bounds the request, never beyond the client's request timeout. */
355
+ async #exchange(session, method, params, { idempotent, timeoutMs, signal: shared }) {
356
+ const id = this.#nextId++;
357
+ const own = AbortSignal.timeout(Math.min(this.#timeoutMs, timeoutMs ?? Infinity));
358
+ const signal = shared ? AbortSignal.any([shared, own]) : own;
359
+ const res = await this.#post(session, { jsonrpc: '2.0', id, method, params }, signal, idempotent, method);
360
+ const sessionId = res.headers.get('mcp-session-id') ?? undefined;
361
+ if (res.status === 404 && session.id) {
362
+ await res.body?.cancel();
363
+ throw new SessionExpired(this.endpoint.url);
364
+ }
365
+ const response = await this.#readResponse(res, id);
366
+ if (response.error) {
367
+ const { code, message, data } = response.error;
368
+ throw new McpProtocolError(typeof code === 'number' ? code : -32603, typeof message === 'string' ? message : 'Unknown error', data);
369
+ }
370
+ if (!('result' in response))
371
+ throw new Error(`Malformed JSON-RPC response from ${this.endpoint.url}`);
372
+ return { result: response.result, ...(sessionId ? { sessionId } : {}) };
373
+ }
374
+ async #notify(session, method, signal) {
375
+ const res = await this.#post(session, { jsonrpc: '2.0', method }, signal, true, method);
376
+ const text = await readTextLimited(res);
377
+ if (!res.ok)
378
+ throw new HttpError(this.endpoint.url, res.status, text);
379
+ }
380
+ /** Reads the response to request `id`: one JSON body, or the SSE event that carries it. */
381
+ async #readResponse(res, id) {
382
+ const matching = (body) => {
383
+ const messages = Array.isArray(body) ? body : [body];
384
+ return messages.find((m) => isObject(m) && m['id'] === id && ('result' in m || 'error' in m));
385
+ };
386
+ if (res.ok && res.body && res.headers.get('content-type')?.includes('text/event-stream')) {
387
+ for await (const data of sseData(res.body, SSE_LIMITS)) {
388
+ let body;
389
+ try {
390
+ body = JSON.parse(data);
391
+ }
392
+ catch {
393
+ continue;
394
+ }
395
+ // Server notifications and requests (logging, progress) are not needed for tools-only polling.
396
+ const found = matching(body);
397
+ if (found)
398
+ return found;
399
+ }
400
+ throw new Error(`The MCP server at ${this.endpoint.url} closed the stream without answering`);
401
+ }
402
+ const text = await readTextLimited(res);
403
+ let body;
404
+ try {
405
+ body = text ? parseJson(text, this.endpoint.url) : undefined;
406
+ }
407
+ catch (err) {
408
+ if (!res.ok)
409
+ throw new HttpError(this.endpoint.url, res.status, text);
410
+ throw err;
411
+ }
412
+ const found = matching(body);
413
+ if (found?.error)
414
+ return found;
415
+ if (!res.ok)
416
+ throw new HttpError(this.endpoint.url, res.status, text);
417
+ if (!found)
418
+ throw new Error(`Malformed JSON-RPC response from ${this.endpoint.url}`);
419
+ return found;
420
+ }
421
+ /** POSTs one message; with OAuth, on 401 renews the token and retries once. */
422
+ async #post(session, body, signal, idempotent, what) {
423
+ const post = (credentials) => withRetries(() => this.#send(session, body, signal, credentials), { idempotent, signal, label: `${this.#label} ${what}`, policy: this.#retry });
424
+ if (!this.#auth)
425
+ return post(this.#headers);
426
+ const token = await this.#auth.accessToken();
427
+ const res = await post({ authorization: `Bearer ${token}` });
428
+ if (res.status !== 401)
429
+ return res;
430
+ await res.body?.cancel();
431
+ const renewed = (await this.#auth.renew(token)).accessToken;
432
+ return post({ authorization: `Bearer ${renewed}` });
433
+ }
434
+ #send(session, body, signal, credentials) {
435
+ const trace = currentTrace();
436
+ const initializing = body['method'] === 'initialize';
437
+ return this.#fetch(this.endpoint.url, {
438
+ method: 'POST',
439
+ headers: {
440
+ ...(trace ? { traceparent: traceparent(trace) } : {}),
441
+ ...credentials,
442
+ 'content-type': 'application/json',
443
+ accept: 'application/json, text/event-stream',
444
+ ...(initializing ? {} : { 'mcp-protocol-version': session.protocolVersion }),
445
+ ...(session.id ? { 'mcp-session-id': session.id } : {}),
446
+ },
447
+ body: JSON.stringify(body),
448
+ // A redirect must never carry the bearer token or replay the request elsewhere.
449
+ redirect: 'error',
450
+ signal,
451
+ });
452
+ }
453
+ /** Tenants and extensions travel in A2A request fields and headers, which tool calls do not have. */
454
+ #ignoreRouting(routing) {
455
+ if (routing.tenant || routing.url || routing.extensions?.length) {
456
+ this.#warnOnce('routing', `${this.#label}: tenant and extension routing cannot be carried over MCP tools, so it is not sent`);
457
+ }
458
+ }
459
+ #warnOnce(key, message) {
460
+ if (this.#warned.has(key))
461
+ return;
462
+ this.#warned.add(key);
463
+ log(message);
464
+ }
465
+ }
466
+ //# sourceMappingURL=mcp-tools.js.map
package/dist/profiles.js CHANGED
@@ -7,6 +7,7 @@
7
7
  import { readFile } from 'node:fs/promises';
8
8
  import { z } from 'zod';
9
9
  import { assertSecureUrl } from './http.js';
10
+ import { A2A_METHODS, TOOL_NAME, toolNames } from './mcp-tools.js';
10
11
  import { normaliseSite, sampleEndpoint } from './sites.js';
11
12
  export const DEFAULT_AGENT = 'rovo';
12
13
  const secureUrl = z.string().refine((u) => {
@@ -91,13 +92,15 @@ const OAuthAuth = z
91
92
  .refine((a) => !a.authorizationEndpoint === !a.tokenEndpoint, {
92
93
  message: 'set both authorizationEndpoint and tokenEndpoint, or neither',
93
94
  });
95
+ /** Headers the bridge sets itself (A2A and MCP), which a header credential must not replace. */
96
+ const PROTOCOL_HEADERS = ['content-type', 'accept', 'a2a-version', 'host', 'content-length', 'traceparent', 'mcp-session-id', 'mcp-protocol-version'];
94
97
  const HeaderAuth = z
95
98
  .object({
96
99
  type: z.literal('header'),
97
100
  name: z
98
101
  .string()
99
102
  .regex(/^[A-Za-z0-9-]{1,64}$/)
100
- .refine((n) => !['content-type', 'accept', 'a2a-version', 'host', 'content-length'].includes(n.toLowerCase()), {
103
+ .refine((n) => !PROTOCOL_HEADERS.includes(n.toLowerCase()), {
101
104
  message: 'cannot replace a protocol header',
102
105
  }),
103
106
  valueEnv: secretEnv,
@@ -174,6 +177,28 @@ const TargetSchema = z
174
177
  keepAlias: z.boolean().optional(),
175
178
  })
176
179
  .strict();
180
+ /** Tool name fragments: letters, digits, `_`, `-` and `.`, as in MCP tool names. */
181
+ const toolAffix = z.string().regex(/^[A-Za-z0-9_.-]{0,100}$/, 'may contain only letters, digits, _, - and .');
182
+ /**
183
+ * A2A carried over MCP tools: a remote MCP server whose tools implement the A2A
184
+ * methods (e.g. a Forge app exposing them as `rovo:mcp` tools). Polling only.
185
+ */
186
+ const McpToolsSchema = z
187
+ .object({
188
+ /** The MCP server (Streamable HTTP). */
189
+ url: secureUrl,
190
+ /** A2A version of the objects the tools return. */
191
+ version: z.enum(['1.0', '1.1']).optional(),
192
+ /** Default tool names are `<toolPrefix><stem><toolSuffix>`, e.g. `my-app-send-message_development`. */
193
+ toolPrefix: toolAffix.optional(),
194
+ toolSuffix: toolAffix.optional(),
195
+ /** Explicit tool names per A2A method, overriding the defaults. */
196
+ tools: z
197
+ .object(Object.fromEntries(A2A_METHODS.map((m) => [m, z.string().regex(TOOL_NAME, 'must be an MCP tool name').optional()])))
198
+ .strict()
199
+ .optional(),
200
+ })
201
+ .strict();
177
202
  const ProfileSchema = z
178
203
  .object({
179
204
  preset: z.enum(['rovo']).optional(),
@@ -185,6 +210,8 @@ const ProfileSchema = z
185
210
  .object({ url: z.string().refine((u) => secureUrl.safeParse(sampleEndpoint(u)).success, 'must be an https URL (http only for loopback hosts); {site} and {cloudId} may be used'), version: z.enum(['0.3', '1.0', '1.1']) })
186
211
  .strict()
187
212
  .optional(),
213
+ /** Instead of `cardUrl`/`endpoint`: reach the agent through an MCP server's tools. */
214
+ mcpTools: McpToolsSchema.optional(),
188
215
  /** Overrides the card's `capabilities.streaming`. */
189
216
  streaming: z.boolean().optional(),
190
217
  auth: Auth.optional(),
@@ -241,14 +268,24 @@ export function resolveProfile(name, input) {
241
268
  quirks: { ...preset.quirks, ...input.quirks },
242
269
  auth: input.auth ?? preset.auth,
243
270
  };
244
- if (!merged.cardUrl && !merged.endpoint) {
245
- throw new Error(`Agent "${name}": set cardUrl, endpoint or a preset`);
271
+ if (merged.mcpTools) {
272
+ if (merged.cardUrl || merged.endpoint)
273
+ throw new Error(`Agent "${name}": mcpTools replaces cardUrl and endpoint; set only one of them`);
274
+ if (merged.streaming)
275
+ throw new Error(`Agent "${name}": streaming is not available over MCP tools`);
276
+ }
277
+ else if (!merged.cardUrl && !merged.endpoint) {
278
+ throw new Error(`Agent "${name}": set cardUrl, endpoint, mcpTools or a preset`);
246
279
  }
280
+ const mcp = merged.mcpTools;
247
281
  return {
248
282
  name,
249
283
  description: merged.description,
250
284
  cardUrl: merged.cardUrl,
251
285
  endpoint: merged.endpoint,
286
+ ...(mcp
287
+ ? { mcpTools: { url: mcp.url, version: mcp.version ?? '1.0', tools: toolNames(mcp.toolPrefix, mcp.toolSuffix, mcp.tools) } }
288
+ : {}),
252
289
  streaming: merged.streaming,
253
290
  auth: merged.auth ?? { type: 'oauth' },
254
291
  quirks: merged.quirks ?? {},
package/dist/server.js CHANGED
@@ -688,7 +688,7 @@ export function createServer(config, profiles, { now = Date.now } = {}) {
688
688
  answer: wrapUntrusted(describeSkills(catalog), SKILLS_NOTE),
689
689
  meta: [
690
690
  `agent: ${profile.name}`,
691
- `protocol: A2A ${endpoint.version}`,
691
+ `protocol: A2A ${endpoint.version}${endpoint.transport === 'mcp-tools' ? ' over MCP tools' : ''}`,
692
692
  `skills: ${catalog.length}`,
693
693
  `structured input: ${typed ? `yes (${MEDIA_TYPE_SCHEMAS})` : 'no'}`,
694
694
  ].join('\n'),
package/dist/skills.js CHANGED
@@ -137,7 +137,10 @@ export function planSkill({ skill, input }, { card, endpoint, text }) {
137
137
  }
138
138
  const id = info?.id ?? skill;
139
139
  if (info?.input && input !== undefined) {
140
- if (isV1(endpoint.version)) {
140
+ if (endpoint.transport === 'mcp-tools') {
141
+ notes.push('typed input cannot be sent over MCP tools, so it is sent as text');
142
+ }
143
+ else if (isV1(endpoint.version)) {
141
144
  return {
142
145
  mode: 'typed',
143
146
  skill: id,
@@ -150,7 +153,9 @@ export function planSkill({ skill, input }, { card, endpoint, text }) {
150
153
  notes,
151
154
  };
152
155
  }
153
- notes.push(`typed input needs A2A v1.0 or later, but the agent speaks v${endpoint.version}`);
156
+ else {
157
+ notes.push(`typed input needs A2A v1.0 or later, but the agent speaks v${endpoint.version}`);
158
+ }
154
159
  }
155
160
  else if (info?.input) {
156
161
  notes.push(`skill "${id}" accepts structured input (${info.input.mediaType}); pass input to send it typed`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a2a-bridge-for-mcp-clients",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
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": [