跳到主內容

【gemini cli】【mcp】mongodb

~/.gemini/settings.json
在 mcpServers 下,新增設定
{
  "theme": "Default",
    "selectedAuthType": "oauth-personal",
    "mcpServers": {
    	// => 加在這裡
  }
}
// mongodb-env 名稱可以自訂
"mongodb-env": {
    "command": "npx",
      "args": [
        "-y",
	"mongodb-mcp-server",
        "--connectionString",
        "mongodb://{username}:{password}@{ip}:27017/?authSource=admin&readPreference=primary&directConnection=true&ssl=false",
        "--readOnly"
      ]
    }

完整設定如下

{
  "theme": "Default",
    "selectedAuthType": "oauth-personal",
    "mcpServers": {
    "mongodb-env": {
    "command": "npx",
      "args": [
        "-y",
	"mongodb-mcp-server",
        "--connectionString",
        "mongodb://{username}:{password}@{ip}:27017/?authSource=admin&readPreference=primary&directConnection=true&ssl=false",
        "--readOnly"
      ]
    }
  }
}