Skip to content

Commit f14542d

Browse files
committed
Revert "Everyone Gets a Timeout (RooCodeInc#1889)"
This reverts commit 87670a3.
1 parent 131b245 commit f14542d

File tree

8 files changed

+31
-135
lines changed

8 files changed

+31
-135
lines changed

.changeset/dull-planets-battle.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/core/prompts/system.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,8 @@ IMPORTANT: Regardless of what else you see in the MCP settings file, you must de
759759
"args": ["/path/to/weather-server/build/index.js"],
760760
"env": {
761761
"OPENWEATHER_API_KEY": "user-provided-api-key"
762-
},
763-
"timeout": 60, // 60 seconds should be set as the default timeout for all MCP servers
764-
}
762+
}
763+
},
765764
}
766765
}
767766
\`\`\`

src/core/webview/ClineProvider.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,6 @@ export class ClineProvider implements vscode.WebviewViewProvider {
821821
}
822822
break
823823
}
824-
case "updateMcpTimeout": {
825-
try {
826-
if (message.serverName && message.timeout) {
827-
await this.mcpHub?.updateServerTimeout(message.serverName, message.timeout)
828-
}
829-
} catch (error) {
830-
console.error(`Failed to update timeout for server ${message.serverName}:`, error)
831-
}
832-
break
833-
}
834824
case "openExtensionSettings": {
835825
const settingsFilter = message.text || ""
836826
await vscode.commands.executeCommand(

src/services/mcp/McpHub.ts

Lines changed: 27 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import * as vscode from "vscode"
1616
import { z } from "zod"
1717
import { ClineProvider, GlobalFileNames } from "../../core/webview/ClineProvider"
1818
import {
19-
DEFAULT_MCP_TIMEOUT_SECONDS,
2019
McpMode,
2120
McpResource,
2221
McpResourceResponse,
@@ -27,7 +26,7 @@ import {
2726
} from "../../shared/mcp"
2827
import { fileExistsAtPath } from "../../utils/fs"
2928
import { arePathsEqual } from "../../utils/path"
30-
import { secondsToMs } from "../../utils/time"
29+
3130
export type McpConnection = {
3231
server: McpServer
3332
client: Client
@@ -43,7 +42,6 @@ const StdioConfigSchema = z.object({
4342
env: z.record(z.string()).optional(),
4443
autoApprove: AutoApproveSchema.optional(),
4544
disabled: z.boolean().optional(),
46-
timeout: z.number().min(1).max(3600).optional().default(DEFAULT_MCP_TIMEOUT_SECONDS),
4745
})
4846

4947
const McpSettingsSchema = z.object({
@@ -244,6 +242,28 @@ export class McpHub {
244242
}
245243
transport.start = async () => {} // No-op now, .connect() won't fail
246244

245+
// // Set up notification handlers
246+
// client.setNotificationHandler(
247+
// // @ts-ignore-next-line
248+
// { method: "notifications/tools/list_changed" },
249+
// async () => {
250+
// console.log(`Tools changed for server: ${name}`)
251+
// connection.server.tools = await this.fetchTools(name)
252+
// await this.notifyWebviewOfServerChanges()
253+
// },
254+
// )
255+
256+
// client.setNotificationHandler(
257+
// // @ts-ignore-next-line
258+
// { method: "notifications/resources/list_changed" },
259+
// async () => {
260+
// console.log(`Resources changed for server: ${name}`)
261+
// connection.server.resources = await this.fetchResources(name)
262+
// connection.server.resourceTemplates = await this.fetchResourceTemplates(name)
263+
// await this.notifyWebviewOfServerChanges()
264+
// },
265+
// )
266+
247267
// Connect
248268
await client.connect(transport)
249269
connection.server.status = "connected"
@@ -323,6 +343,10 @@ export class McpHub {
323343
const connection = this.connections.find((conn) => conn.server.name === name)
324344
if (connection) {
325345
try {
346+
// connection.client.removeNotificationHandler("notifications/tools/list_changed")
347+
// connection.client.removeNotificationHandler("notifications/resources/list_changed")
348+
// connection.client.removeNotificationHandler("notifications/stderr")
349+
// connection.client.removeNotificationHandler("notifications/stderr")
326350
await connection.transport.close()
327351
await connection.client.close()
328352
} catch (error) {
@@ -539,7 +563,6 @@ export class McpHub {
539563
if (connection.server.disabled) {
540564
throw new Error(`Server "${serverName}" is disabled`)
541565
}
542-
543566
return await connection.client.request(
544567
{
545568
method: "resources/read",
@@ -563,17 +586,6 @@ export class McpHub {
563586
throw new Error(`Server "${serverName}" is disabled and cannot be used`)
564587
}
565588

566-
let timeout = secondsToMs(DEFAULT_MCP_TIMEOUT_SECONDS) // sdk expects ms
567-
568-
try {
569-
const config = JSON.parse(connection.server.config)
570-
const parsedConfig = StdioConfigSchema.parse(config)
571-
timeout = secondsToMs(parsedConfig.timeout)
572-
} catch (error) {
573-
console.error(`Failed to parse timeout configuration for server ${serverName}: ${error}`)
574-
// Continue with default timeout
575-
}
576-
577589
return await connection.client.request(
578590
{
579591
method: "tools/call",
@@ -583,9 +595,6 @@ export class McpHub {
583595
},
584596
},
585597
CallToolResultSchema,
586-
{
587-
timeout,
588-
},
589598
)
590599
}
591600

@@ -654,47 +663,6 @@ export class McpHub {
654663
}
655664
}
656665

657-
public async updateServerTimeout(serverName: string, timeout: number): Promise<void> {
658-
try {
659-
// Validate timeout against schema
660-
const setConfigResult = StdioConfigSchema.shape.timeout.safeParse(timeout)
661-
if (!setConfigResult.success) {
662-
throw new Error(`Invalid timeout value: ${timeout}. Must be between 1 and 3600 seconds.`)
663-
}
664-
665-
const settingsPath = await this.getMcpSettingsFilePath()
666-
const content = await fs.readFile(settingsPath, "utf-8")
667-
const config = JSON.parse(content)
668-
669-
if (!config.mcpServers?.[serverName]) {
670-
throw new Error(`Server "${serverName}" not found in settings`)
671-
}
672-
673-
// Update the timeout in the config
674-
config.mcpServers[serverName] = {
675-
...config.mcpServers[serverName],
676-
timeout,
677-
}
678-
679-
// Write updated config back to file
680-
await fs.writeFile(settingsPath, JSON.stringify(config, null, 2))
681-
682-
// Update server connections to apply the new timeout
683-
await this.updateServerConnections(config.mcpServers)
684-
685-
vscode.window.showInformationMessage(`Updated timeout to ${timeout} seconds`)
686-
} catch (error) {
687-
console.error("Failed to update server timeout:", error)
688-
if (error instanceof Error) {
689-
console.error("Error details:", error.message, error.stack)
690-
}
691-
vscode.window.showErrorMessage(
692-
`Failed to update server timeout: ${error instanceof Error ? error.message : String(error)}`,
693-
)
694-
throw error
695-
}
696-
}
697-
698666
async dispose(): Promise<void> {
699667
this.removeAllFileWatchers()
700668
for (const connection of this.connections) {

src/shared/WebviewMessage.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export interface WebviewMessage {
5050
| "searchCommits"
5151
| "showMcpView"
5252
| "fetchLatestMcpServersFromHub"
53-
| "updateMcpTimeout"
5453
// | "relaunchChromeDebugMode"
5554
text?: string
5655
disabled?: boolean
@@ -64,7 +63,6 @@ export interface WebviewMessage {
6463
chatSettings?: ChatSettings
6564
chatContent?: ChatContent
6665
mcpId?: string
67-
timeout?: number // For updateMcpTimeout
6866

6967
// For toggleToolAutoApprove
7068
serverName?: string

src/shared/mcp.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export const DEFAULT_MCP_TIMEOUT_SECONDS = 60 // matches Anthropic's default timeout in their MCP SDK
2-
31
export type McpMode = "full" | "server-use-only" | "off"
42

53
export type McpServer = {
@@ -11,7 +9,6 @@ export type McpServer = {
119
resources?: McpResource[]
1210
resourceTemplates?: McpResourceTemplate[]
1311
disabled?: boolean
14-
timeout?: number
1512
}
1613

1714
export type McpTool = {

src/utils/time.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

webview-ui/src/components/mcp/McpView.tsx

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
import {
2-
VSCodeButton,
3-
VSCodeLink,
4-
VSCodePanels,
5-
VSCodePanelTab,
6-
VSCodePanelView,
7-
VSCodeDropdown,
8-
VSCodeOption,
9-
} from "@vscode/webview-ui-toolkit/react"
1+
import { VSCodeButton, VSCodeLink, VSCodePanels, VSCodePanelTab, VSCodePanelView } from "@vscode/webview-ui-toolkit/react"
102
import { useEffect, useState } from "react"
113
import styled from "styled-components"
12-
import { DEFAULT_MCP_TIMEOUT_SECONDS, McpServer } from "../../../../src/shared/mcp"
4+
import { McpServer } from "../../../../src/shared/mcp"
135
import { useExtensionState } from "../../context/ExtensionStateContext"
146
import { getMcpServerDisplayName } from "../../utils/mcp"
157
import { vscode } from "../../utils/vscode"
@@ -218,36 +210,6 @@ const ServerRow = ({ server }: { server: McpServer }) => {
218210
}
219211
}
220212

221-
const [timeout, setTimeout] = useState<string>(() => {
222-
try {
223-
const config = JSON.parse(server.config)
224-
return config.timeout?.toString() || DEFAULT_MCP_TIMEOUT_SECONDS.toString()
225-
} catch {
226-
return DEFAULT_MCP_TIMEOUT_SECONDS.toString()
227-
}
228-
})
229-
230-
const timeoutOptions = [
231-
{ value: "30", label: "30 seconds" },
232-
{ value: "60", label: "1 minute" },
233-
{ value: "300", label: "5 minutes" },
234-
{ value: "600", label: "10 minutes" },
235-
{ value: "1800", label: "30 minutes" },
236-
{ value: "3600", label: "1 hour" },
237-
]
238-
239-
const handleTimeoutChange = (e: any) => {
240-
const select = e.target as HTMLSelectElement
241-
const value = select.value
242-
const num = parseInt(value)
243-
setTimeout(value)
244-
vscode.postMessage({
245-
type: "updateMcpTimeout",
246-
serverName: server.name,
247-
timeout: num,
248-
})
249-
}
250-
251213
const handleRestart = () => {
252214
vscode.postMessage({
253215
type: "restartMcpServer",
@@ -448,16 +410,6 @@ const ServerRow = ({ server }: { server: McpServer }) => {
448410
</VSCodePanelView>
449411
</VSCodePanels>
450412

451-
<div style={{ margin: "10px 7px" }}>
452-
<label style={{ display: "block", marginBottom: "4px", fontSize: "13px" }}>Request Timeout</label>
453-
<VSCodeDropdown style={{ width: "100%" }} value={timeout} onChange={handleTimeoutChange}>
454-
{timeoutOptions.map((option) => (
455-
<VSCodeOption key={option.value} value={option.value}>
456-
{option.label}
457-
</VSCodeOption>
458-
))}
459-
</VSCodeDropdown>
460-
</div>
461413
<VSCodeButton
462414
appearance="secondary"
463415
onClick={handleRestart}

0 commit comments

Comments
 (0)