MCPcopy Create free account
hub / github.com/codeaashu/claude-code / createSandboxAskCallback

Method createSandboxAskCallback

src/cli/structuredIO.ts:731–753  ·  view source on GitHub ↗

* Creates a SandboxAskCallback that forwards sandbox network permission * requests to the SDK host as can_use_tool control_requests. * * This piggybacks on the existing can_use_tool protocol with a synthetic * tool name so that SDK hosts (VS Code, CCR, etc.) can prompt the user * for

()

Source from the content-addressed store, hash-verified

729 * for network access without requiring a new protocol subtype.
730 */
731 createSandboxAskCallback(): (hostPattern: {
732 host: string
733 port?: number
734 }) => Promise<boolean> {
735 return async (hostPattern): Promise<boolean> => {
736 try {
737 const result = await this.sendRequest<PermissionToolOutput>(
738 {
739 subtype: 'can_use_tool',
740 tool_name: SANDBOX_NETWORK_ACCESS_TOOL_NAME,
741 input: { host: hostPattern.host },
742 tool_use_id: randomUUID(),
743 description: `Allow network connection to ${hostPattern.host}?`,
744 },
745 permissionToolOutputSchema(),
746 )
747 return result.behavior === 'allow'
748 } catch {
749 // If the request fails (stream closed, abort, etc.), deny the connection
750 return false
751 }
752 }
753 }
754
755 /**
756 * Sends an MCP message to an SDK server and waits for the response

Callers 1

runHeadlessFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected