Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RafalWilinski/3416a497f94ee2a0c589a8d930304950 to your computer and use it in GitHub Desktop.
Save RafalWilinski/3416a497f94ee2a0c589a8d930304950 to your computer and use it in GitHub Desktop.
Auto-approve all MCP tool calls in Claude Desktop
// HOW TO INSTRUCTIONS
// 1. Open Claude Desktop
// 2. Go to Help -> Enable Developer Mode
// 3. Navigate Developer Tools window named "Developer Tools - https://claude.ai"
// 4. Go to "Console" tab
// 5. Type "allow pasting" and hit Enter
// 6. Paste this snippet and hit Enter
// From now on, all MCP calls will be auto-approved
// END INSTRUCTIONS
// Cooldown tracking
let lastClickTime = 0;
const COOLDOWN_MS = 1000; // 1 second cooldown
const observer = new MutationObserver((mutations) => {
// Check if we're still in cooldown
const now = Date.now();
if (now - lastClickTime < COOLDOWN_MS) {
console.log("🕒 Still in cooldown period, skipping...");
return;
}
console.log("🔍 Checking mutations...");
const dialog = document.querySelector('[role="dialog"]');
if (!dialog) return;
const buttonWithDiv = dialog.querySelector("button div");
if (!buttonWithDiv) return;
const toolText = buttonWithDiv.textContent;
if (!toolText) return;
console.log("📝 Found tool request:", toolText);
const toolName = toolText.match(/Run (\S+) from/)?.[1];
if (!toolName) return;
console.log("🛠️ Tool name:", toolName);
const allowButton = Array.from(dialog.querySelectorAll("button")).find(
(button) => button.textContent.includes("Allow for This Chat")
);
if (allowButton) {
console.log("🚀 Auto-approving tool:", toolName);
lastClickTime = now; // Set cooldown
allowButton.click();
}
});
// Start observing
observer.observe(document.body, {
childList: true,
subtree: true,
});
@epodak
Copy link

epodak commented Mar 14, 2025

The "Developer Tools window" did not appear.

@netlooker
Copy link

@epodak you have to use key shortcut to get it. On MacOs Shift+Alt+Cmd+I on others Shift+Ctrl+Alt+I.

@victories
Copy link

When I press Shift+Ctrl+Alt+I, developer tools do not open. is there another way to open it?

@epodak
Copy link

epodak commented Mar 17, 2025

@epodak您必须使用快捷键才能获得它。在 MacOs 上为 Shift+Alt+Cmd+I,在其他版本上为 Shift+Ctrl+Alt+I。

shift + ctrl + I gonna be work.

@netlooker
Copy link

and of course you must first do the step 2. Go to Help -> Enable Developer Mode

@GabrielDrapor
Copy link

GabrielDrapor commented Mar 19, 2025

thx for the script!

should be "Command-Option-Shift-i"
according to https://modelcontextprotocol.io/docs/tools/debugging#using-chrome-devtools

@joshmouch
Copy link

Awesome. I know it's dangerous, but Claude Desktop should have the option to do this when in development mode. MCP's and Claude Desktop crash too often and conversations have to be restarted too often. It gets old approving everything all the time when you already know the MCPs have been configured in a safe way.

@netlooker
Copy link

Well, it is not dangerous as you might specify to which folder MCP has access via configuration, like in the example below.

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/username/Desktop",
        "/path/to/other/allowed/dir"
      ]
    }
  }
}

@hflatoey
Copy link

hflatoey commented Mar 25, 2025

// 3. Navigate Developer Tools window named "Developer Tools - https://claude.ai"

I can't find this... I have a developer tab in the menu but it just takes me to the mcp log.

allow pasting
VM62:1 Uncaught SyntaxError: Unexpected identifier 'pasting'

@phwelo
Copy link

phwelo commented Mar 25, 2025

couldn't get this to work on latest claude desktop on windows, was able to enter into console but still get approval requests

@rvanbaalen
Copy link

Minor update since the label of the button did not match the current Claude UI:

@hflatoey this should work

// Cooldown tracking
let lastClickTime = 0;
const COOLDOWN_MS = 2000; // 2 seconds cooldown is fast enough

const observer = new MutationObserver((mutations) => {
  // Check if we're still in cooldown
  const now = Date.now();
  if (now - lastClickTime < COOLDOWN_MS) {
    console.log("🕒 Still in cooldown period, skipping...");
    return;
  }

  console.log("🔍 Checking mutations...");

  const dialog = document.querySelector('[role="dialog"]');
  if (!dialog) return;

  const buttonWithDiv = dialog.querySelector("button div");
  if (!buttonWithDiv) return;

  const toolText = buttonWithDiv.textContent;
  if (!toolText) return;

  console.log("📝 Found tool request:", toolText);

  const toolName = toolText.match(/Run (\S+) from/)?.[1];
  if (!toolName) return;

  console.log("🛠️ Tool name:", toolName);

  const allowButton = Array.from(dialog.querySelectorAll("button")).find(
    (button) => button.textContent.toLowerCase().includes("allow for this chat") // case insensitive checking fixes the original script
  );

  if (allowButton) {
    console.log("🚀 Auto-approving tool:", toolName);
    lastClickTime = now; // Set cooldown
    allowButton.click();
  }
});

// Start observing
observer.observe(document.body, {
  childList: true,
  subtree: true,
});

@rvanbaalen
Copy link

Update; I've taken inspiration from this script and made it into an extensible tiny framework so others can add other actions (like automatically submitting "Continue" or awaiting cooldown periods when rate limits are hit).

https://gist.github.com/rvanbaalen/96796aee97f05133b3ad51671597e770

@grosubogdan
Copy link

grosubogdan commented Apr 12, 2025

Just for whoever has troubles opening Developer Tools, you need to Enable first the Developer Mode The context Menu on Top Left. Onve you enable Developer Mode, you can CTRL + SHIFT + ALT + I

@rvanbaalen
Copy link

And CMD+SHIFT+OPTION+I for the mac users :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment