目是什么意思| 失眠去医院挂什么科| 耳朵里面痒用什么药| 为什么会莫名其妙的哭| 应激反应是什么意思| 多种维生素什么时候吃效果最好| 阿尔茨海默症是什么| 反复发烧是什么原因| 宝宝低烧是什么原因引起的| 春五行属什么| 梦魇是什么原因造成的| 维密是什么意思| 香蕉皮擦脸有什么作用与功效| 子宫肌瘤吃什么好| 药流后可以吃什么水果| 621什么星座| uv是什么意思| 低gi食物是什么意思| 狐狸和乌鸦告诉我们什么道理| 一什么河| 肝气郁结是什么意思| 皿是什么意思| 牛油果坏了是什么样| lee是什么牌子中文名| 低血糖吃什么食物| 颠了是什么意思| 复方石韦胶囊治什么病| 巴沙鱼是什么鱼| 脚趾麻木是什么病先兆| 黑裙子配什么鞋子| 取是什么意思| 绿茶喝多了有什么危害| 中叶是什么意思| 杨八妹属什么生肖| 炭疽病用什么农药最好| 印度是什么制度的国家| 蝈蝈是什么动物| 威士忌什么味道| 梦见出血是什么征兆| 喝咖啡不能吃什么食物| 日斤念什么字| 12月10日是什么星座| 牛奶能做什么美食| 凤眼果什么时候成熟| 势利眼是什么意思| 吴亦凡什么学历| 国师是什么生肖| 避重就轻是什么意思| 新白娘子传奇许仙为什么用女的演| 90年是什么命| 女性分泌物发黄是什么原因| 九月二十五是什么星座| 磨砂膏有什么作用| 预防感冒吃什么药| 送表的寓意是什么| 物色是什么意思| 宝宝手足口病吃什么药| aape是什么牌子| 男性尿道感染吃什么药| 故宫里面有什么| 心率快是什么原因| 肌酐高什么原因引起的| 嗣读什么| 5月是什么月| 玉皇大帝的老婆叫什么| 晚上睡觉遗精是什么原因| 乳腺结节低回声是什么意思| l do是什么意思| 猫咪能看到什么颜色| 手上的线分别代表什么图解| 瞳孔放大意味着什么| 人参和什么泡酒最好| 什么叫一桌餐| 褪黑素不能和什么一起吃| 1度房室传导阻滞是什么意思| 导演是干什么的| 什么是电离辐射| 老公生日送什么礼物| 脸油是什么原因导致的| 漫谈是什么意思| 什么工作赚钱| 淋巴细胞百分比偏高是什么原因| 脚上长鸡眼去医院挂什么科| 绝非偶然是什么意思| 68岁属什么生肖| 胃胆汁反流是什么原因引起的| 什么病治不好| 什么是宫颈息肉| 动脉圆锥是什么意思| 鳖吃什么| 怀孕了胃不舒服是什么原因| 阳痿早泄是什么原因| 念珠菌吃什么药最好| 为什么会心肌梗死| 什么是天葬| 世界上笔画最多的字是什么字| 痔疮复发的原因是什么| 香油是什么油| 倾注是什么意思| 熊猫为什么有黑眼圈| 芈月传芈姝结局是什么| 突然的反义词是什么| 什么是应力| 羊羹是什么做的| 属鸡的适合干什么行业最赚钱| 左枕前位是什么意思| 血脂高吃什么药最好| 送产妇什么礼物最合适| 2月9号什么星座| 冯字五行属什么| 宫腔内无回声区是什么意思| 白血病是什么原因引起的| 1111是什么意思| 牛蒡茶有什么功效| dennis什么意思| 西瓜和什么不能一起吃| 邻家女孩什么意思| 肝主疏泄是什么意思| 尿碱是什么| 耳朵发热是什么原因| 什么是活性叶酸| 小孩什么时候长牙| 小孩流鼻涕吃什么药| 湖北有什么山| 梦见卖衣服是什么意思| 脖子上长癣是什么原因| 尿不出尿是什么原因| 腱鞘炎吃什么药好| 冠状沟有白色分泌物是什么原因| 我做错了什么| 晚字五行属什么| 什么得什么词语| 绞股蓝长什么样子| 水仙茶属于什么茶| 天启是什么意思| 什么样的普洱茶才是好茶| 空谷幽兰下一句是什么| 双手发麻是什么病的前兆| 反射弧太长是什么意思| 北京大栅栏有什么好玩的| 舌头白苔厚是什么原因| 7月15是什么星座的| 生化什么意思| 杨桃什么季节成熟| 小孩割包皮挂什么科室| 长高吃什么钙片| 惊魂未定的意思是什么| 空唠唠的意思是什么| 护照类型p是什么意思| 手肿胀是什么原因| 布谷鸟长什么样| 头晕在医院挂什么科| 耳石症吃什么药最好| 腰椎钙化是什么意思| 小孩子手脚脱皮是什么原因| bravo是什么意思| 有什么花| 取环后要注意什么事项| 胃糜烂有什么症状| 卖萌什么意思| 血管明显是什么原因| 脑壳疼是什么原因| 病毒性咽喉炎吃什么药| 鱼为什么睁着眼睛睡觉| 甲状腺低密度结节是什么意思| 包馄饨用猪肉什么部位| 肠胃不好适合喝什么茶| 73年属什么| 福是什么生肖| nse是什么意思| 慢性咽炎吃什么药好得快能根治| 恩施玉露属于什么茶| 桂花是什么生肖| 心情沉重是什么意思| 农历什么意思| 芙蓉花长什么样| 苋菜是什么菜| 先兆临产是什么意思| 什么是周期| 韧带损伤有什么症状| 拆线去医院挂什么科| 属蛇与什么属相相克| 开车什么意思| 直肠炎吃什么药| 手指关节痛挂什么科| 多囊卵巢综合征吃什么药| 命大是什么意思| 聚乙二醇是什么| 肚子肥胖是什么原因引起的| 秦始皇原名叫什么名字| 尿路感染吃什么药比较好的快| 乳头瘤病毒是什么意思| 什么床不能睡觉| 梦见别人给我介绍对象是什么意思| 如愿以偿是什么意思| 闻鸡起舞是什么生肖| 长粉刺是什么原因| 指什么| 什么红酒好喝| 京畿是什么意思| 二个月不来月经是什么原因| 免疫五项能查出什么病| 热射病是什么病| 脚底板发黄是什么原因| 什么是胶体| 上海玉佛寺求什么最灵验| 皮草是什么意思| 恶心想吐吃什么药| 胳膊麻是什么原因| b超跟彩超有什么区别| 姨妈期吃什么水果| 应激是什么意思| 餐中服用是什么意思| 喝酒吃什么解酒| 宫颈管搔刮术是什么| 八段锦什么时间练最好| 山药和什么不能一起吃| 喝冰美式有什么好处| 肚子左下方是什么器官| 一什么叮咛| 虬角为什么要染成绿色| 长湿疹是什么原因引起的| 眉毛里面有痣代表什么| 2月25日是什么星座| 香精是什么东西| 人怕冷是什么原因引起的| 泻火是什么意思| 为什么会流鼻血| 凝血功能是什么意思| 谁也不知道下一秒会发生什么| 脑血管堵塞是什么症状| mds是什么| 微信什么时候开始的| 端午节在什么时候| 左下腹部是什么器官| 鼻子两侧毛孔粗大是什么原因造成的| 细胞是什么| 什么凝视| 结石长什么样子图片| 耳加贵念什么| 丑小鸭告诉我们一个什么道理| 小孩白细胞高是什么原因| 女人得痔疮原因是什么| 容五行属什么| 哺乳期感冒吃什么药不影响哺乳| 什么的亮光| 隔离霜和粉底液有什么区别| 十月十二号是什么星座| hpv亚临床感染是什么意思| 大学生村官是什么编制| 晨勃是什么意思| 什么的小球| 被跳蚤咬了涂什么药膏| 十羊九不全是什么意思| 乳头刺痛什么原因| 吃什么发胖最快| 药师是干什么的| 胃痉挛吃什么药| 乙酰氨基葡萄糖苷酶阳性什么意思| da是什么单位| 吃什么水果能降血压| 为什么不能拜女娲娘娘| 女排精神是什么| 什么是德训鞋| 百度

Try to extend agent mode in VS Code!

麂皮是什么材质

百度 我就提到了给寺院设道墙收门票,不仅仅是为了经济利益,背后依然有着意识形态上对佛教的歧视。

Model Context Protocol (MCP) is an open standard that enables AI models to interact with external tools and services through a unified interface. Visual Studio Code implements the full MCP specification, enabling you to create MCP servers that provide tools, prompts, and resources for extending the capabilities of AI agents in VS Code.

This guide covers everything you need to know to build MCP servers that work seamlessly with VS Code and other MCP clients.

Important

MCP support in VS Code is currently in preview.

Why use MCP servers?

Implementing an MCP server to extend chat in VS Code with language model tools has the following benefits:

  • Extend agent mode with specialized, domain-specific, tools that are automatically invoked as part of responding to a user prompt. For example, enable database scaffolding and querying to dynamically provide the LLM with relevant context.
  • Flexible deployment options for local and remote scenarios.
  • Reuse your MCP server across different tools and platforms.

You might consider implementing a language model tool with the Language Model API in the following scenarios:

  • You want to deeply integrate with VS Code by using extension APIs.
  • You want to distribute your tool and updates by using the Visual Studio Marketplace.

Add MCP servers to VS Code

Users can add MCP servers within VS Code in several ways:

  • Workspace configuration: Specify the server configuration in a .vscode/mcp.json file in the workspace.
  • Global configuration: Define servers globally in the user profile.
  • Autodiscovery: VS Code can discover servers from other tools like Claude Desktop.
  • Extension: VS Code extensions can register MCP servers programmatically.

In addition, users can trigger MCP installation by opening a special URL (vscode:mcp/install), which is used in the MCP gallery on the VS Code website. Users can access the gallery directly from the MCP view in the Extensions view.

Finally, install MCP servers from the command line with the --add-mcp command-line option.

Manage MCP servers

You can manage the list of installed MCP servers from the Extension view (??X (Windows, Linux Ctrl+Shift+X)) in VS Code.

Screenshot showing the MCP servers in the Extensions view.

Right-click on an MCP server or select the gear icon to perform the following actions:

  • Start/Stop/Restart: Start, stop, or restart the MCP server.
  • Disconnect Account: Disconnect the account for authentication with the MCP server.
  • Show Output: View the server logs to diagnose issues.
  • Show Configuration: View the MCP server configuration.
  • Configure Model Access: Configure which models the MCP server can access (sampling).
  • Show Sampling Requests: View the sampling requests made by the MCP server.
  • Browse Resources: View the resources provided by the MCP server.
  • Uninstall: Uninstall the MCP server from your environment.

Alternatively, run the MCP: List Servers command from the Command Palette to view the list of configured MCP servers. You can then select a server and perform actions on it.

Tip

When you open the .vscode/mcp.json file, VS Code shows commands to start, stop, or restart a server directly from the editor.

MCP server configuration with lenses to manage server.

MCP URL handler

VS Code provides a URL handler for installing an MCP server from a link. To form the URL, construct an obj object in the same format as you would provide to --add-mcp, and then create the link by using the following logic:

// For Insiders, use `vscode-insiders` instead of `code`
const link = `vscode:mcp/install?${encodeURIComponent(JSON.stringify(obj))}`;

This link can be used in a browser, or opened on the command line, for example via xdg-open $LINK on Linux.

MCP features supported by VS Code

VS Code supports the following transport methods for MCP servers:

  • Standard input/output (stdio): Run a server as a local process that communicates over standard input and output
  • Streamable HTTP (http): Communicate with a (remote) server using HTTP POST and GET
  • Server-sent events (sse, legacy): Supported with a (remote) server over HTTP using server-sent events

The following MCP features are supported in VS Code:

  • Tools: Executable actions that can be used in agent mode
  • Prompts: Reusable chat prompt templates, optionally with parameters, which users can invoke through slash commands(/mcp.servername.promptname) in chat
  • Resources: Data and content which users can add as chat context or interact with directly in VS Code
  • Authorization: Authorize access to an MCP server using OAuth
  • Sampling (Preview): Make language model requests using the user's configured models and subscription
  • Elicitation: Request input from the user
  • Workspace roots: Information about the user's workspace structure

For complete specification details, see the Model Context Protocol documentation.

Tools

Tool definition

VS Code supports MCP tools in agent mode, where they are invoked as needed based on the task. Users can enable and configure them with the tools picker. The tool description is shown in the tools picker, alongside the tool name, and in the dialog when asking for confirmation before running a tool.

Screenshot that shows the tools picker in agent mode, highlighting tools from an MCP server.

Users can edit model-generated input parameters in the tool confirmation dialog. The confirmation dialog will be shown for all tools that are not marked with the readOnlyHint annotation.

Screenshot that shows the tool confirmation dialog with input parameters for an MCP tool.

Dynamic tool discovery

VS Code also supports dynamic tool discovery, allowing servers to register tools at runtime. For example, a server can provide different tools based on the framework or language detected in the workspace, or in response to the user's chat prompt.

Tool annotations

To provide extra metadata about a tool's behavior, you can use tool annotations:

  • title: Human-readable title for the tool, shown in the Chat view when a tool is invoked
  • readOnlyHint: Optional hint to indicate that the tool is read-only. VS Code doesn't ask for confirmation to run read-only tools.

Resources

Resources enable you to provide data and content to users in a structured way. Users can directly access resources in VS Code, or use them as context in chat prompts. For example, an MCP server could generate screenshots and make them available as resources, or provide access to log files, which are then updated in real-time.

When you define an MCP resource, the resource name is shown in the MCP Resources Quick Picks. Resources can be opened via the MCP: Browse Resources command or attached to a chat request with Add Context and then selecting MCP Resource. Resources can contain text or binary content.

Screenshot that shows the MCP Resources Quick Pick.

VS Code supports resource updates, enabling users to see changes to the contents of a resource in real-time in the editor.

Resource templates

VS Code also supports resource templates, enabling users to provide input parameters when referencing a resource. For example, a database query tool could ask for the database table name.

When accessing a resource with a template, users are prompted for the required parameters in a Quick Pick. You can provide completions to suggest values for the parameter.

Prompts

Prompts are reusable chat prompt templates that users can invoke in chat by using a slash command (mcp.servername.promptname). Prompts can be useful for onboarding users to your servers by highlighting various tools or providing built-in complex workflows that adapt to the user's local context and service.

If you define completions to suggest values for prompt input arguments, then VS Code shows a dialog to collect input from the user.

server.prompt(
  'teamGreeting',
  'Generate a greeting for team members',
  {
    name: completable(z.string(), value => {
      return ['Alice', 'Bob', 'Charlie'].filter(n => n.startsWith(value));
    })
  },
  async ({ name }) => ({
    messages: [
      {
        role: 'assistant',
        content: { type: 'text', text: `Hello ${name}, welcome to the team!` }
      }
    ]
  })
);

Screenshot that shows the prompt dialog for an MCP prompt with input parameters.

Note

Users can enter a terminal command in the prompt dialog and use the command output as input for the prompt.

When you include a resource type in the prompt response, VS Code attaches that resource as context to the chat prompt.

Authorization

VS Code supports MCP servers that require authentication, allowing users to interact with an MCP server that operates on behalf of their user account for that service.

The authorization specification cleanly separates MCP servers as Resource Servers from Authorization Servers, allowing developers to delegate authentication to existing identity providers rather than building their own OAuth implementations from scratch.

VS Code has built-in authentication support for GitHub and Microsoft Entra. If your MCP server implements the latest specification and uses GitHub or Microsoft Entra as the authorization server, users can manage which MCP servers have access to their account through the Accounts menu > Manage Trusted MCP Servers action for that account.

Screenshot that shows the Accounts menu with the Manage Trusted MCP Servers action.

If your MCP server uses a different authorization server, VS Code also supports Dynamic Client Registration. Users can then view their authentication status also through the Accounts menu. To remove dynamic client registrations, users can use the Authentication: Remove Dynamic Authentication Providers command in the Command Palette.

VS Code still supports MCP servers that behave as an authorization server, but it is recommended to use the latest specification for new servers.

Sampling (Preview)

VS Code provides access to sampling for MCP servers. This allows your MCP server to make language model requests using the user's configured models and subscriptions. Sampling can be used to summarize large data or extract information before sending it to the client, or to implement smarter agentic decision in tool logic.

The first time an MCP server performs a sampling request, the user is prompted to authorize the server to access their models.

Screenshot that shows the authorization prompt for an MCP server to access models.

Users can specify which models they allow the MCP server to use for sampling by using the MCP: List Servers > Configure Model Access command in the Command Palette. You can specify modelPreferences in your MCP server to provide hints about which models to use for sampling, and VS Code will pick from the allowed models when evaluating the server's preferences

Screenshot that shows the Configure Model Access dialog for an MCP server.

Users can view the sampling requests made by an MCP server with the MCP: List Servers > Show Sampling Requests command in the Command Palette.

Workspace roots

VS Code provides the MCP server with the user's workspace root folder information.

Register an MCP server in your extension

To register an MCP server in your extension, you need to perform the following steps:

  1. Define the MCP server definition provider in the package.json file of your extension.
  2. Implement the MCP server definition provider in your extension code by using the vscode.lm.registerMcpServerDefinitionProvider API.

You can get started with a basic example of how to register an MCP server in a VS Code extension.

1. Static configuration in package.json

Extensions that want to register MCP servers must contribute the contributes.mcpServerDefinitionProviders extension point in the package.json with the id of the provider. This id should match the one used in the implementation.

{
    ...
    "contributes": {
        "mcpServerDefinitionProviders": [
            {
                "id": "exampleProvider",
                "label": "Example MCP Server Provider"
            }
        ]
    }
    ...
}

2. Implement the provider

To register an MCP server in your extension, use the vscode.lm.registerMcpServerDefinitionProvider API to provide the MCP configuration for the server. The API takes a providerId string and a McpServerDefinitionProvider object.

The McpServerDefinitionProvider object has three properties:

  • onDidChangeMcpServerDefinitions: event that is triggered when the MCP server configurations change.
  • provideMcpServerDefinitions: function that returns an array of MCP server configurations (vscode.McpServerDefinition[]).
  • resolveMcpServerDefinition: function that the editor calls when the MCP server needs to be started. Use this function to perform additional actions that may require user interaction, such as authentication.

An McpServerDefinition object can be one of the following types:

  • vscode.McpStdioServerDefinition: represents an MCP server available by running a local process and operating on its stdin and stdout streams.
  • vscode.McpHttpServerDefinition: represents an MCP server available using the Streamable HTTP transport.
Example MCP server definition provider

The following example demonstrates how to register MCP servers in an extension and prompt the user for an API key when starting the server.

import * as vscode from 'vscode';

export function activate(context: vscode.ExtensionContext) {
    const didChangeEmitter = new vscode.EventEmitter<void>();

    context.subscriptions.push(vscode.lm.registerMcpServerDefinitionProvider('exampleProvider', {
        onDidChangeMcpServerDefinitions: didChangeEmitter.event,
        provideMcpServerDefinitions: async () => {
            let servers: vscode.McpServerDefinition[] = [];

            // Example of a simple stdio server definition
            servers.push(new vscode.McpStdioServerDefinition(
            {
                label: 'myServer',
                command: 'node',
                args: ['server.js'],
                cwd: vscode.Uri.file('/path/to/server'),
                env: {
                    API_KEY: ''
                },
                version: '1.0.0'
            });

            // Example of an HTTP server definition
            servers.push(new vscode.McpHttpServerDefinition(
            {
                label: 'myRemoteServer',
                uri: 'http://localhost:3000',
                headers: {
                    'API_VERSION': '1.0.0'
                },
                version: '1.0.0'
            }));

            return servers;
        },
        resolveMcpServerDefinition: async (server: vscode.McpServerDefinition) => {

            if (server.label === 'myServer') {
                // Get the API key from the user, e.g. using vscode.window.showInputBox
                // Update the server definition with the API key
            }

            // Return undefined to indicate that the server should not be started or throw an error
            // If there is a pending tool call, the editor will cancel it and return an error message
            // to the language model.
            return server;
        }
    }));
}

Troubleshoot and debug MCP servers

MCP development mode in VS Code

When developing MCP servers, you can enable MCP development mode in VS Code. To enable development mode, add the dev property to your MCP server configuration and specify the following properties:

  • watch: A glob pattern to watch for file changes to files and automatically restart the server
  • debug: Debugger to attach to your MCP server process when starting it (currently only supported for servers launched with node or python)

The following example shows how to configure a Node.js MCP server that watches for changes to TypeScript files in the src directory and uses the Node.js debugger:

{
  "servers": {
    "my-mcp-server": {
      "type": "stdio",
      "command": "node",
      "cwd": "${workspaceFolder}",
      "args": ["./build/index.js"],
      "dev": {
        "watch": "src/**/*.ts",
        "debug": { "type": "node" }
      }
    }
  }
}

MCP output log

When VS Code encounters an issue with an MCP server, it shows an error indicator in the Chat view.

MCP Server Error

Select the error notification in the Chat view, and then select the Show Output option to view the server logs. Alternatively, run MCP: List Servers from the Command Palette, select the server, and then choose Show Output.

MCP Server Error Output

Best practices

  • Naming conventions to ensure unique and descriptive names
  • Implement proper error handling and validation with descriptive error messages
  • Use progress reporting to inform users about long-running operations
  • Keep tool operations focused and atomic to avoid complex interactions
  • Document your tools clearly with descriptions that help users understand when to use them
  • Handle missing input parameters gracefully by providing default values or clear error messages
  • Set MIME types for resources to ensure proper handling of different content types in VS Code
  • Use resource templates to allow users to provide input parameters when accessing resources
  • Cache resource content to improve performance and reduce unnecessary network requests
  • Set reasonable token limits for sampling requests to avoid excessive resource usage
  • Validate sampling responses before using them

Naming conventions

The following naming conventions are recommended for MCP servers and their components:

Component Naming Convention Guidelines
Tool name
  • Unique within the MCP server
  • Describes the action and the target of the action
  • Use snake case, structured as {verb}_{noun}
  • Examples: generate_report, fetch_data, analyze_code
Tool input parameter
  • Describes the purpose of the parameter
  • Use camelCase for multi-word parameters
  • Examples: path, queryString, userId
Resource name
  • Unique within the MCP server
  • Describes the content of the resource
  • Use title case
  • Examples: Application Logs, Database Table, GitHub Repository
Resource template parameter
  • Describes the purpose of the parameter
  • Use camelCase for multi-word parameters
  • Examples: name, repo, fileType
Prompt name
  • Unique within the MCP server
  • Describes the intended use of the prompt
  • Use camelCase for multi-word parameters
  • Examples: generateApiRoute, performSecurityReview, analyzeCodeQuality
Prompt input parameter
  • Describes the purpose of the parameter
  • Use camelCase for multi-word parameters
  • Examples: filePath, queryString, userId

Get started to create an MCP server

VS Code has all the tools you need to develop your own MCP server. While MCP servers can be written in any language that can handle stdout, the MCP's official SDKs are a good place to start:

You might also find the MCP for Beginners curriculum helpful to get started with building your first MCP server.

梦见蛇是什么预兆 人工受孕和试管婴儿有什么区别 泌尿是什么意思 排卵期在什么时候 但求无愧于心上句是什么
95开头的是什么电话 乌鸦长什么样 蝌蚪吃什么 1.29是什么星座 肝火大吃什么药
以什么当什么 beer是什么意思 杏花是什么生肖 安宫牛黄丸有什么作用 口苦是什么原因造成的
lz什么意思 阿斗是什么意思 独具一格是什么意思 50岁掉牙齿是什么原因 营养包是什么
训练有素是什么意思hcv8jop1ns5r.cn 什么是佛教什么是道教hcv9jop4ns6r.cn 新生儿什么时候上户口hcv9jop5ns0r.cn 下肢血管堵塞吃什么药hcv8jop5ns9r.cn 加盟资质需要什么条件hcv8jop9ns2r.cn
肝功能挂什么科hcv9jop6ns0r.cn 脚掌发红是什么原因hcv7jop9ns1r.cn 雅字取名的寓意是什么hcv8jop6ns1r.cn 岳字五行属什么hcv8jop3ns0r.cn 牙疼有什么好办法mmeoe.com
空孕囊是什么原因造成的travellingsim.com 蝙蝠吃什么hcv8jop8ns1r.cn 欲女是什么意思hcv8jop4ns1r.cn 类胡萝卜素主要吸收什么光hcv7jop9ns9r.cn wmf是什么牌子hcv8jop7ns5r.cn
喝茶叶茶有什么好处和坏处hcv9jop4ns6r.cn 任达华属什么生肖hcv9jop4ns0r.cn 五红汤什么时候喝最好hcv9jop5ns0r.cn 出院小结是什么travellingsim.com 猫奴是什么意思hcv9jop3ns7r.cn
百度