Skip to content

Commit 2c92e7f

Browse files
committed
fix(sdk): guard mcp_restart and fix agent update field validation
- Add allowGlobalScope guard to workspace_mcp_restart (consistent with workspace_tool_toggle — restarting MCP servers is equally disruptive) - Remove scope from hasField check in handleAgentUpdate (scope is a routing parameter, not an update field — passing only scope would POST an empty body to the daemon)
1 parent de6e85d commit 2c92e7f

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

packages/sdk-typescript/src/daemon-mcp/serve-bridge/tools/workspaceWrite.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,16 @@ export function workspaceWriteTools(state: BridgeState): any[] {
130130
{
131131
server_name: z.string().describe('Name of the MCP server to restart.'),
132132
},
133-
handler(async (args) =>
134-
formatJsonResult(
133+
handler(async (args) => {
134+
if (!state.allowGlobalScope) {
135+
return formatToolError(
136+
'MCP server restart is restricted for security. Set QWEN_BRIDGE_ALLOW_GLOBAL_SCOPE=true to enable.',
137+
);
138+
}
139+
return formatJsonResult(
135140
await state.client.restartMcpServer(args.server_name),
136-
),
137-
),
141+
);
142+
}),
138143
),
139144

140145
tool(
@@ -260,11 +265,10 @@ async function handleAgentUpdate(state: BridgeState, args: any): Promise<any> {
260265
args.system_prompt !== undefined ||
261266
args.tools !== undefined ||
262267
args.disallowed_tools !== undefined ||
263-
args.model !== undefined ||
264-
args.scope !== undefined;
268+
args.model !== undefined;
265269
if (!hasField) {
266270
return formatToolError(
267-
'At least one field to update must be provided (description, system_prompt, tools, disallowed_tools, model, or scope).',
271+
'At least one field to update must be provided (description, system_prompt, tools, disallowed_tools, or model).',
268272
);
269273
}
270274
return formatJsonResult(

0 commit comments

Comments
 (0)