Skip to content

Allow user to choose only certain MCP tools #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bmacer
Copy link

@bmacer bmacer commented Mar 11, 2025

Attempted implementation to address #71

@tedjames
Copy link
Contributor

Nice! And what would the command look like when you go to set this up in Cursor?

@bmacer
Copy link
Author

bmacer commented Mar 11, 2025

Hi @tedjames

Case 1 (default, all tools -- notice, no change):
npx @agentdeskai/browser-tools-mcp@1.2.0

Case 2 (one tool, in this case, takeScreenshot):
npx @agentdeskai/browser-tools-mcp@1.2.0 takeScreenshot

Case 3 (multiple tools, in this case, takeScreenshot and getConsoleLogs)
npx @agentdeskai/browser-tools-mcp@1.2.0 takeScreenshot getConsoleLogs

This does add a slight burden to development, because you'd need to add any additional tools to the toolsToUse array, as well as to wrap additional tools in a conditional.

Note: I only tested this locally with npm --prefix /Users/bmacer/Desktop/home/cursor/browser-tools-mcp/browser-tools-mcp start takeScreenshot getConsoleLogs, but presumably it'd work the same with npx?

Screenshot:

image

@tedjames
Copy link
Contributor

Awesome.. let's think about this a bit more. I'd like to explore a different syntax for the args that allows for easier enabling/disabling of tools. Like:

--audit-only
--logs-only
--screenshot-only
--no-audit
--no-nextjs
--no-screenshot
--no-logs

Flags like that maybe?

@bmacer
Copy link
Author

bmacer commented Mar 13, 2025

That would work, though i'd probably start them all with only or no:

--no-console-logs
--no-console-errors
--no-audit
--only-audit
--only-nextjs
--only-console-errors
...etc

You could stack no's, and you could stack only's, but you couldn't combine them (basically if you have a no it means you're subtracting from ALL, and if you have an only than you're adding from NONE.

Does this sound good?

@tedjames
Copy link
Contributor

I like it! Makes sense to me 👍

@tedjames
Copy link
Contributor

Just created a new project for us btw!
BrowserTools Development (view)

Should help us keep track of our backlog and ongoing development :)

@bmacer
Copy link
Author

bmacer commented Mar 13, 2025

Considerations:

  1. In the event of mixture of 'only' and 'no' args, process.exit, or just console.error and proceed without a filter? I think I'd argue for the latter.
  2. In the event of incorrect arg, like no-nonexistent-tool or only-nonexistent-tool, similarly just ignore it (with a console.error)?
  3. One thing is only-nonexistent-tool will trigger the only- buildup from zero, so if it's incorrect like only-getConsoleLogs instead of only-console-logs, it won't show an error but will load no tools.
  4. Need to review the mapping of arg-formatting key to tool-name value:
const toolMapping: Record<ArgName, ToolName> = {
  "console-logs": "getConsoleLogs",
  "console-errors": "getConsoleErrors",
  "network-errors": "getNetworkErrors",
  "network-logs": "getNetworkLogs",
  screenshot: "takeScreenshot",
  "selected-element": "getSelectedElement",
  "wipe-logs": "wipeLogs",
  "accessibility-audit": "runAccessibilityAudit",
  "performance-audit": "runPerformanceAudit",
  "seo-audit": "runSEOAudit",
  "nextjs-audit": "runNextJSAudit",
  "debugger-mode": "runDebuggerMode",
  "audit-mode": "runAuditMode",
  "best-practices-audit": "runBestPracticesAudit",
};
  1. Also possible to group the settings, like only-console (to encompass both getConsoleErrors and getConsoleLogs). Would probably change this mapping to be key -> array, but that should be doable with a single prompt. If that's worth it, please suggest groupings.

@bmacer
Copy link
Author

bmacer commented Mar 13, 2025

Pushed the changes, seems to work fine.

Here's my .cursor/mcp.json file for testing:

{
  "mcpServers": {
    "Browser Tool": {
      "command": "npx",
      "args": ["@agentdeskai/browser-tools-mcp@1.2.0"]
    },
    "Local Browser Tool (testing ONLY)": {
      "command": "npx",
      "args": [
        "--prefix",
        "~/Desktop/home/cursor/browser-tools-mcp/browser-tools-mcp",
        "@agentdeskai/browser-tools-mcp",
        "--only-console-logs",
        "--only-console-errors"
      ]
    },
    "Local Browser Tool (testing NO)": {
      "command": "npx",
      "args": [
        "--prefix",
        "~/Desktop/home/cursor/browser-tools-mcp/browser-tools-mcp",
        "@agentdeskai/browser-tools-mcp",
        "--no-network-logs",
        "--no-network-errors"
      ]
    },
    "Local Browser Tool (testing ERROR MIX)": {
      "command": "npx",
      "args": [
        "--prefix",
        "~/Desktop/home/cursor/browser-tools-mcp/browser-tools-mcp",
        "@agentdeskai/browser-tools-mcp",
        "--no-network-logs",
        "--only-network-errors"
      ]
    },
    "Local Browser Tool (testing NONEXISTENT)": {
      "command": "npx",
      "args": [
        "--prefix",
        "~/Desktop/home/cursor/browser-tools-mcp/browser-tools-mcp",
        "@agentdeskai/browser-tools-mcp",
        "--only-console-logs",
        "--only-nonexistent-tool"
      ]
    },
    "Local Browser Tool (testing ALL)": {
      "command": "npx",
      "args": [
        "--prefix",
        "~/Desktop/home/cursor/browser-tools-mcp/browser-tools-mcp",
        "@agentdeskai/browser-tools-mcp"
      ]
    }
  }
}

Testing only works great:
image

no works great (notice network logs and errors missing)
image

FAILS with mixture of no and only:
image

only-console-logs and only-nonexistent just ignores the latter:
image

And the control (no arg) case works fine too:
image

@bmacer
Copy link
Author

bmacer commented Mar 13, 2025

fwiw i had to npm run build and npm link to get that npx to work locally.

@tedjames
Copy link
Contributor

nice!! will test this weekend :)

thank you 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants