|
1 | 1 | // The module 'vscode' contains the VS Code extensibility API |
2 | 2 | // Import the module and reference it with the alias vscode in your code below |
3 | 3 |
|
4 | | -import { ExtensionContext } from 'vscode'; |
| 4 | +import * as vscode from 'vscode'; |
5 | 5 | import * as editorConfig from './data/editor-config'; |
6 | 6 | import * as files from './ui/file' |
7 | 7 | import * as auth from './auth' |
8 | 8 |
|
9 | | -export async function activate(context: ExtensionContext) { |
| 9 | +// This identifier is replaced at build time by esbuild using --define:EXTENSION_VERSION |
| 10 | +// Keep a `typeof` guard when reading it so runtime is safe if the define wasn't provided. |
| 11 | +declare const EXTENSION_VERSION: string | undefined; |
| 12 | + |
| 13 | +export async function activate(context: vscode.ExtensionContext) { |
10 | 14 | editorConfig.activate(context); |
11 | 15 | auth.activate(context, context.subscriptions); |
12 | 16 | files.activate(context); |
| 17 | + if (vscode.lm?.registerMcpServerDefinitionProvider) { |
| 18 | + const definition: vscode.McpHttpServerDefinition = new vscode.McpHttpServerDefinition( |
| 19 | + '[Extension] Socket Security', |
| 20 | + vscode.Uri.parse('https://mcp.socket.dev/'), |
| 21 | + { |
| 22 | + 'user-agent': `Socket Security VSCode Extension/${EXTENSION_VERSION}`, |
| 23 | + } |
| 24 | + ) |
| 25 | + const provider: vscode.McpServerDefinitionProvider<vscode.McpHttpServerDefinition> = { |
| 26 | + provideMcpServerDefinitions(token) { |
| 27 | + return [ |
| 28 | + definition |
| 29 | + ]; |
| 30 | + }, |
| 31 | + resolveMcpServerDefinition(definition, token) { |
| 32 | + return definition |
| 33 | + } |
| 34 | + } |
| 35 | + vscode.lm.registerMcpServerDefinitionProvider('socket-security.mcp-server', provider); |
| 36 | + } |
13 | 37 | } |
0 commit comments