Skip to content

Commit 0c05adf

Browse files
committed
chore(mcp): trim comments to match codebase density
1 parent cf68df9 commit 0c05adf

3 files changed

Lines changed: 6 additions & 31 deletions

File tree

apps/sim/lib/mcp/client.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ export class McpClient {
105105
}
106106
)
107107

108-
// The SDK invokes onerror for out-of-band transport failures (SSE
109-
// disconnects, exhausted reconnects) that are not tied to an in-flight
110-
// request. Without a handler these are silently dropped, so wire one for
111-
// observability. See @modelcontextprotocol/sdk Protocol.onerror.
108+
// Observe out-of-band transport errors the SDK would otherwise drop silently.
112109
this.client.onerror = (error) => {
113110
logger.warn(`MCP transport error for ${this.config.name}`, {
114111
serverId: this.config.id,
@@ -242,10 +239,7 @@ export class McpClient {
242239

243240
try {
244241
const result: ListToolsResult = await this.client.listTools(undefined, {
245-
// `timeout` bounds silence between progress notifications; `maxTotalTimeout`
246-
// is the hard ceiling regardless of progress. `resetTimeoutOnProgress` only
247-
// takes effect when an `onprogress` callback is supplied (the SDK sets the
248-
// request progressToken only then), so both are passed together.
242+
// resetTimeoutOnProgress only takes effect when onprogress is supplied.
249243
timeout: idleTimeoutMs,
250244
maxTotalTimeout: maxTotalTimeoutMs,
251245
resetTimeoutOnProgress: true,

apps/sim/lib/mcp/service.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,14 @@ function isTimeoutError(error: unknown): boolean {
100100
return getErrorMessage(error, '').toLowerCase().includes('timed out')
101101
}
102102

103-
/**
104-
* Transient transport failures that a read-only `tools/list` may safely retry.
105-
* `tools/list` is idempotent, so re-issuing it after a timeout, dropped
106-
* connection, or 5xx/429 cannot double-apply side effects — unlike `tools/call`,
107-
* which is never retried on these. OAuth-authorization and terminal 4xx errors
108-
* are intentionally excluded: they need re-auth or a config fix, not a retry.
109-
* The MCP TypeScript SDK does not retry POST requests itself (only SSE streams),
110-
* so the app owns this.
111-
*/
103+
/** Transient failures a read-only `tools/list` may safely retry (idempotent, unlike `tools/call`); excludes OAuth and terminal 4xx. */
112104
function isRetryableDiscoveryError(error: unknown): boolean {
113105
if (isTimeoutError(error)) return true
114106
if (error instanceof McpError) {
115107
return error.code === ErrorCode.ConnectionClosed
116108
}
117109
if (error instanceof StreamableHTTPError) {
118-
// 404/400 = stale/malformed session id: retrying rebuilds the client with no
119-
// session id, which re-initializes per MCP spec. 429/5xx = transient upstream.
110+
// 404/400 = stale session (retry re-initializes); 429/5xx = transient upstream.
120111
const code = error.code
121112
return (
122113
code === 404 ||

apps/sim/lib/mcp/utils.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,9 @@ export function sanitizeHeaders(
5151
export const MCP_CLIENT_CONSTANTS = {
5252
CLIENT_TIMEOUT: DEFAULT_EXECUTION_TIMEOUT_MS,
5353
AUTO_REFRESH_INTERVAL: 5 * 60 * 1000,
54-
/**
55-
* Idle timeout for a `tools/list` request. Raised from the former aggressive
56-
* 10s toward the MCP TypeScript SDK's 60s default (`DEFAULT_REQUEST_TIMEOUT_MSEC`)
57-
* so a legitimately slow-to-enumerate server is not spuriously failed with
58-
* `McpError -32001`. Combined with `resetTimeoutOnProgress`, this is the gap
59-
* allowed between progress notifications, not the absolute ceiling.
60-
*/
54+
/** Idle timeout for tools/list (gap between progress events); raised from 10s toward the SDK's 60s default. */
6155
LIST_TOOLS_TIMEOUT_MS: 30_000,
62-
/**
63-
* Absolute ceiling for a `tools/list` request regardless of progress, mirroring
64-
* the SDK's `maxTotalTimeout` safeguard. Matches the SDK's 60s default so a
65-
* server emitting continuous progress still cannot hang discovery indefinitely.
66-
*/
56+
/** Hard ceiling for tools/list regardless of progress (SDK maxTotalTimeout safeguard). */
6757
LIST_TOOLS_MAX_TOTAL_TIMEOUT_MS: 60_000,
6858
FAILURE_CACHE_TTL_MS: 120_000,
6959
} as const

0 commit comments

Comments
 (0)