Skip to content

add a mechanism to disable tools from the config #63

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

Merged
merged 8 commits into from
Apr 16, 2025
Merged

Conversation

nirinchev
Copy link
Collaborator

Allows disabling of tools by category, operation type, or name. Example config:

env: {
  "MDB_MCP_DISABLED_TOOLS": "atlas, write, list-indexes"
}

or as command line args:

--disableTools atlas write list-indexes

Fixes #54

@nirinchev nirinchev requested review from gagik and fmenezes April 11, 2025 12:55

const DEFAULT_COMMENT = "Added by Atlas MCP";

export class CreateAccessListTool extends AtlasToolBase {
protected name = "atlas-create-access-list";
protected description = "Allow Ip/CIDR ranges to access your MongoDB Atlas clusters.";
protected operationType: OperationType = "create";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmenezes @blva I've tried to map the atlas tools to operation types, but feel free to suggest more appropriate ones (or we can introduce new types if that'd make sense).

@@ -74,6 +76,12 @@ function getEnvConfig(): Partial<UserConfig> {
return;
}

// Try to parse an array of values
if (value.indexOf(",") !== -1) {
obj[currentField] = value.split(",").map((v) => v.trim());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this supports an array anyways we could just always do the split without the indexOf check

@fmenezes
Copy link
Collaborator

have we seen this pattern before? are there other MCP servers that allow disabling tools?

@nirinchev
Copy link
Collaborator Author

Yes, there's a handful of database-focused servers I've seen implement some form of protection against destructive operations. E.g. mcp-server-mysql has env variables such as ALLOW_INSERT_OPERATION, ALLOW_DELETE_OPERATION, etc. to control what tools are allowed. Alternatively, mongodb-lens has a 2-step confirmation, where it responds with a code and then verifies that the user has input it to go through with the operation. supabase-mcp-server similarly implements a 3-tier safety system.

I think this is ultimately important to instil confidence in users, especially with some agents being fairly opaque with what they're doing. I know most allow you to disable tools one-by-one, but with server updates, you run the risk of letting a destructive tool sneak in and wreak havoc on your data.

* main:
  chore: auto generate apiClient (#64)
  refactor: rename state to session, combine tool registration, and clearer dependencies (#55)
  chore: add type-powered eslint rules (#62)
@fmenezes
Copy link
Collaborator

fmenezes commented Apr 11, 2025

@nirinchev I was thinking here, what if all tools declared a list of tags instead of one category? this way we could have something like disableTools write and keep everything readonly but also we could disable atlas,destroy, allowing you to do writes without destroys but no access to atlas.

@nirinchev
Copy link
Collaborator Author

nirinchev commented Apr 11, 2025

Right now we're kind of there, but with the caveat that all tools have exactly 2 "tags" - the category and the operation type. Therefore if a user specifies atlas, write, delete, they're disabling all tools in the atlas category, as well as all tools that have operation type write or delete. We can definitely make it even more flexible/generic by allowing arbitrary number of tags, but I wonder if that wouldn't overcomplicate things.

@fmenezes
Copy link
Collaborator

Rigth now we're kind of there, but with the caveat that all tools have exactly 2 "tags" - the category and the operation type. Therefore if a user specifies atlas, write, delete, they're disabling all tools in the atlas category, as well as all tools that have operation type write or delete. We can definitely make it even more flexible/generic by allowing arbitrary number of tags, but I wonder if that wouldn't overcomplicate things.

That works for me, just make sure to have a category for the main tools, could be 'tools', 'driver' or 'server'. At least we would be consistent.

@nirinchev
Copy link
Collaborator Author

What would be in the tools category? Right now I've used the same category names as the folder structure (that is atlas and mongodb) - happy to find better names, though driver is probably not what I'd go with.

@gagik
Copy link
Collaborator

gagik commented Apr 14, 2025

Maybe clusters-read / clusters-write + database-read database-write? We can also have read/write which combines the two.

Copy link
Collaborator

@fmenezes fmenezes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works for me, just make sure to leave documentation on README.md otherwise it will be difficult for people to find out how to use these values

@nirinchev nirinchev merged commit 6181ff4 into main Apr 16, 2025
4 checks passed
@nirinchev nirinchev deleted the ni/disable-tools branch April 16, 2025 08:00
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.

Implement tool disabling
3 participants