Docs Home / VS Code Extension / Reference

Visual Studio Code Settings设置

This document lists the configurable settings for VS Code Extension.本文档列出了VS Code扩展的可配置设置。

Configure Settings配置设置

To configure VS Code Extension settings:要配置VS Code扩展设置,请执行以下操作:

1

Open the Settings View.打开设置视图。

Operating System操作系统Method方法Actions操作
AnyVisual Studio Code Menu菜单

File / Code > Preferences > Settings文件/代码>首选项>设置

MacOSKeyboard Shortcut键盘快捷键Press Command + ,
Windows and LinuxKeyboard Shortcut键盘快捷键Press Ctrl + ,
2

Search "MongoDB" in the Settings search bar.在设置搜索栏中搜索“MongoDB”。

VS Code Extension extension settings are displayed. Changes you make are saved automatically.显示VS Code扩展扩展设置。您所做的更改将自动保存。

Settings设置

The following table lists the available settings for VS Code Extension:下表列出了VS Code扩展的可用设置:

Setting设置Description描述Default默认
Shell

MongoDB shell to use. Choose either:使用MongoDB shell。选择其中之一:

  • mongo (the legacy MongoDB shell), or(旧版MongoDB shell),或
  • mongosh (the new MongoDB shell)(新的MongoDB shell)

To launch your selected MongoDB shell, you must:要启动所选的MongoDB shell,您必须:

  • Install the shell you want to use, and安装要使用的shell,然后
  • Configure your machine's PATH environment variable to include the filepath to your shell binary.配置计算机的PATH环境变量,以包含shell二进制文件的文件路径。

If you install a new version of your MongoDB shell, you will need to update your PATH variable to reference the new version.如果安装新版本的MongoDB shell,则需要更新PATH变量以引用新版本。

mongosh
ShowIf enabled, shows the MongoDB view in the Visual Studio Code left navigation panel.如果启用,将在Visual Studio Code左侧导航面板中显示MongoDB视图。Enabled
Max Number of Problems最大问题数The maximum number of problems VS Code Extension will generate in the Visual Studio Code Problems view.Visual Studio Code“问题”视图中VS Code扩展将生成的最大问题数。100
Trace: Server跟踪:服务器

MongoDB language server logging settings.MongoDB语言服务器日志记录设置。

Edit this setting through the mongodbLanguageServer.trace.server property in your project's settings.json file.通过项目的settings.json文件中的mongodbLanguageServer.trace.server属性编辑此设置。

Within the mongodbLanguageServer.trace.server object, you can specify:mongodbLanguageServer.trace.server对象中,您可以指定:

  • format, and
  • verbosity

Output logs are viewable by selecting MongoDB Language Server from the dropdown in the Output view, or with the Language Server Protocol Inspector.通过从输出视图的下拉列表中选择“MongoDB语言服务器”,或使用语言服务器协议检查器,可以查看“输出”日志。

{
"format": "json",
"verbosity": "verbose"
}
Confirm Run All确认全部运行If enabled, shows a confirmation message before running commands in a playground.如果启用,则在游乐场中运行命令之前显示确认消息。Enabled
Default Connection Saving Location默认连接保存位置

Sets if and where new connections are saved.设置是否以及在何处保存新连接。

You can select:您可以选择:

Setting设置Description描述
GlobalSave your connection globally in VS Code, so it can be accessed from any workspace.将连接全局保存在VS Code中,这样就可以从任何工作区访问它。
WorkspaceSave your connection in your workspace. You cannot access the connection from a different workspace.将连接保存在工作区中。您无法从其他工作区访问连接。
SessionSave the connection for only this VS Code session. The connection is lost when you close VS Code.仅保存此VS Code会话的连接。关闭VS Code时,连接丢失。
Global
Hide Option To Choose Where To Save New Connections隐藏选项以选择保存新连接的位置

If disabled, you are prompted to choose where to save each new connection.如果禁用,系统会提示您选择保存每个新连接的位置。

If enabled, new connections are automatically saved to the Default Connection Saving Location without prompt.如果启用,新连接将自动保存到默认连接保存位置,而不会出现提示。

Enabled
Default Limit默认限制Number of documents to fetch when viewing documents from a collection. Does not affect playground operations.查看集合中的文档时要提取的文档数。不会影响游乐场的运营。10
Preset Connections预设连接

Specifies a preset list of connections. Use this setting to share connection configurations in a workspace or global scope.指定预设的连接列表。使用此设置可在工作区或全局范围内共享连接配置。

Edit the mdb.presetConnection property in your project's settings.json file.在项目的settings.json文件中编辑mdb.presetConnection属性。

Within the mdb.presetConnections object, you can specify:mdb.presetConnections对象中,您可以指定:

  • A name for the connection.连接的name
  • A connectionString for your deployment.用于部署的connectionString

WARNING:警告: Do not store sensitive credentials in this setting. Connection strings are stored in plain text, so they can be easily accessed.不要在此设置中存储敏感凭据。连接字符串以纯文本形式存储,因此可以轻松访问。

[
{
"name": "Preset Connection",
"connectionString": "mongodb://localhost:27017"
}
]
Send Telemetry发送遥测数据If enabled, allows the collection of anonymous diagnostic and usage telemetry data to help improve VS Code Extension.如果启用,则允许集合匿名诊断和使用遥测数据,以帮助改进VS Code扩展。Enabled
Use Default Template For Playground使用游乐场默认模板

If enabled, playground files load with a template containing sample commands.如果启用,游乐场文件将与包含示例命令的模板一起加载。

If disabled, playground files load with an empty playground editor.如果禁用,游乐场文件将使用空的游乐场编辑器加载。

Enabled
Show Overview Page After Install安装后显示概述页面

If enabled, VS Code Extension displays an overview page after installation to help you get started.如果启用,VS Code扩展将在安装后显示一个概述页面,以帮助您入门。

If disabled, VS Code Extension does not show the overview page after installation. 如果禁用,VS Code扩展在安装后不会显示概述页面。This is useful in containerized environments, such as GitHub Codespaces, where your work environment is already set up. 这在容器化环境中很有用,例如GitHub Codespace,在那里你的工作环境已经设置好了。In these environments, you don't need to see the overview page every time you create a workspace.在这些环境中,您不需要每次创建工作区时都看到概述页面。

Enabled
Use Sample Docs in Copilot在Copilot中使用示例文档When enabled, MongoDB Extension for Github Copilot can send sample field values with the /query command.启用后,Github Copilot的MongoDB扩展可以使用/query命令发送示例字段值。Disabled
MCP: Server

Controls whether the MongoDB MCP server starts automatically when VS Code opens and connects to an active connection.控制当VS Code打开并连接到活动连接时,MongoDB MCP服务器是否自动启动。

  • If set to prompt, the extension requests permission every time a connection succeeds in VS Code.如果设置为prompt,则每次在VS Code中连接成功时,扩展都会请求权限。
  • If set to autoStartEnabled, the server starts automatically when VS Code opens. No notification appears.如果设置为autoStartEnabled,服务器将在VS Code打开时自动启动。没有出现通知。
  • If set to autoStartDisabled, the server does not start automatically. 如果设置为autoStartDisabled,则服务器不会自动启动。No notification appears. You must start the server manually by using the Start MCP Server command.没有出现通知。您必须使用“启动MCP服务器”命令手动启动服务器。

The first time the server starts, VS Code displays a notification asking if you want to enable or disable auto-start. Your choice updates this setting.服务器首次启动时,VS Code会显示一条通知,询问您是要启用还是禁用自动启动。选择将更新此设置。

When the MCP server is not running, use the MongoDB: Start MCP Server command to start the MCP server immediately.当MCP服务器未运行时,使用MongoDB:启动MCP服务器命令立即启动MCP服务器。

prompt
MCP: Api Base URLIf you're using a custom Atlas deployment, specify the API URL used by the MongoDB MCP server that enables Atlas MCP tools.如果使用自定义Atlas部署,请指定MongoDB MCP服务器使用的API URL,该服务器可启用Atlas MCP工具。https://cloud.mongodb.com/
MCP: Api Client ID

Atlas API client ID for authenticating against the Atlas API. Use a Service Account for programmatic access to Atlas APIs. Required for enabling Atlas tools in MongoDB MCP server. Store your ID securely and do not commit it to version control.Atlas API客户端ID,用于针对Atlas API进行身份验证。使用服务帐户以编程方式访问Atlas API。需要在MongoDB MCP服务器中启用Atlas工具。安全地存储ID,不要将其提交给版本控制。

To learn more, see Connecting with Atlas API Credentials.要了解更多信息,请参阅连接Atlas API凭据

Empty
MCP: Api Client Secret

Atlas API client secret for authenticating against the Atlas API. Use a Service Account for programmatic access to Atlas APIs. Required for enabling Atlas tools in MongoDB MCP server. Store this securely and do not commit to version control.Atlas API客户机密,用于针对Atlas API进行认证。使用服务帐户以编程方式访问Atlas API。需要在MongoDB MCP服务器中启用Atlas工具。安全地存储此内容,不要进行版本控制。

To learn more, see Connecting with Atlas API Credentials.要了解更多信息,请参阅连接Atlas API凭据

Empty
MCP: Disabled Tools:禁用工具Tool names, operation types (create, update, delete, read, metadata), or categories (atlas, mongodb) to disable when using the MongoDB MCP server.使用mongodb MCP服务器时要禁用的工具名称、操作类型(创建、更新、删除、读取、元数据)或类别(图集、mongodb)。Empty
MCP Export Cleanup Interval Ms导出清理间隔MsMCP导出清理间隔MsHow often (in milliseconds) the MongoDB MCP server runs the export cleanup process to remove expired files. Default is 2 minutes (120000ms).MongoDB MCP服务器运行导出清理过程以删除过期文件的频率(以毫秒为单位)。默认值为2分钟(120000ms)。120000
MCP Exports Path导出路径

The directory where the MongoDB MCP server exports data when using the export tool. Ensure that the path is available for writes or leave this setting empty to use the default path based on your operating system.使用导出工具时MongoDB MCP服务器导出数据的目录。确保路径可用于写入,或将此设置留空,以使用基于操作系统的默认路径。

Default paths:默认路径:

  • Windows: %LOCALAPPDATA%\mongodb\mongodb-mcp\exports
  • macOS and Linux: ~/.mongodb/mongodb-mcp/exports
Empty
MCP Export Timeout Ms导出超时MsThe maximum time in milliseconds an export operation can run before MongoDB MCP server terminates it. Default is 5 minutes (300000ms).导出操作在MongoDB MCP服务器终止之前可以运行的最长时间(毫秒)。默认值为5分钟(300000ms)。300000
MCP Index Check索引检查When enabled, the MongoDB MCP server enforces that query operations must use an index, and rejects queries that perform a collection scan. This helps prevent performance issues in production environments.启用后,MongoDB MCP服务器强制要求查询操作必须使用索引,并拒绝执行集合扫描的查询。这有助于防止生产环境中的性能问题。Disabled
MCP: Read Only:只读When enabled, the MongoDB MCP server only allows read, connect, and metadata operation types. Create, update, and delete operations are disabled.启用后,MongoDB MCP服务器只允许读取、连接和元数据操作类型。创建、更新和删除操作已禁用。Enabled