Skip to content

Commit 6a36430

Browse files
authored
add extension sample for mcp server publishing (#1156)
1 parent 46f526c commit 6a36430

File tree

8 files changed

+461
-0
lines changed

8 files changed

+461
-0
lines changed

mcp-extension-sample/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
out
2+
node_modules
3+
.vscode-test/
4+
*.vsix
5+
6+
*.d.ts
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [{
8+
"name": "Run Extension",
9+
"type": "extensionHost",
10+
"request": "launch",
11+
"runtimeExecutable": "${execPath}",
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}"
14+
],
15+
"outFiles": [
16+
"${workspaceFolder}/out/**/*.js"
17+
],
18+
"preLaunchTask": "npm: watch"
19+
}
20+
]
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
}
19+
]
20+
}

mcp-extension-sample/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# MCP Extension sample
2+
3+
This sample demonstrates usage of the MCP connection API. This API is currently still proposed.
4+
5+
## Running the Sample
6+
7+
- Run `npm install` in terminal to install dependencies
8+
- A `postinstall` script would download latest version of `vscode.proposed.<proposalName>.d.ts`
9+
- Run the `Run Extension` target in the Debug View. This will:
10+
- Start a task `npm: watch` to compile the code
11+
- Run the extension in a new VS Code window
12+
- In the new window, run the command `Add Gist Source` command with a gist containing MCP servers ([example](https://gist.github.com/connor4312/3939ae7f6e55b2e391b5d585df27465c))
13+
- You can now run these MCP servers in chat.

mcp-extension-sample/package-lock.json

Lines changed: 245 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mcp-extension-sample/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"enabledApiProposals": [
3+
"mcpConfigurationProvider"
4+
],
5+
"name": "mcp-extension-sample",
6+
"displayName": "mcp-extension-sample",
7+
"description": "Sample showing how to use Proposed API",
8+
"version": "0.0.1",
9+
"publisher": "vscode-samples",
10+
"private": true,
11+
"license": "MIT",
12+
"repository": "https://github.com/Microsoft/vscode-extension-samples",
13+
"engines": {
14+
"vscode": "^1.99.0"
15+
},
16+
"categories": [
17+
"Other"
18+
],
19+
"main": "./out/extension.js",
20+
"contributes": {
21+
"commands": [
22+
{
23+
"command": "mcp-extension-sample.addGist",
24+
"title": "MCP Extension Sample: Add Gist Source"
25+
},
26+
{
27+
"command": "mcp-extension-sample.removeGist",
28+
"title": "MCP Extension Sample: Remove Gist Source"
29+
}
30+
],
31+
"modelContextServerCollections": [
32+
{
33+
"id": "exampleGist",
34+
"label": "Github Gists"
35+
}
36+
]
37+
},
38+
"scripts": {
39+
"vscode:prepublish": "npm run compile",
40+
"compile": "tsc -p ./",
41+
"watch": "tsc -watch -p ./",
42+
"download-api": "dts dev",
43+
"postdownload-api": "dts main",
44+
"postinstall": "npm run download-api"
45+
},
46+
"devDependencies": {
47+
"@types/node": "^20",
48+
"@vscode/dts": "^0.4.1",
49+
"typescript": "^5.8.2"
50+
}
51+
}

0 commit comments

Comments
 (0)