Skip to content

Commit

Permalink
adds arg for setting diagnostics level for code_checker (microsoft#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrabach authored Feb 8, 2025
1 parent c13e66f commit 2c2f710
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 124 deletions.
57 changes: 54 additions & 3 deletions mcp-servers/mcp-server-vscode/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,66 @@
// Place your settings in this file to overwrite default and user settings.
{
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"editor.bracketPairColorization.enabled": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.guides.bracketPairs": "active",
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"files.eol": "\n",
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"files.trimTrailingWhitespace": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"python.analysis.autoFormatStrings": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.diagnosticMode": "workspace",
"python.analysis.fixAll": ["source.unusedImports"],
"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.typeCheckingMode": "standard",
"python.defaultInterpreterPath": "${workspaceFolder}/.venv",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.unusedImports": "explicit",
"source.organizeImports": "explicit",
"source.formatDocument": "explicit"
}
},
"ruff.nativeServer": "on",
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
// For use with optional extension: "streetsidesoftware.code-spell-checker"
"cSpell.ignorePaths": ["ASSISTANT_BOOTSTRAP.md"],
"cSpell.words": ["modelcontextprotocol", "nosources", "vscodeignore"]
"cSpell.words": [
"amodio",
"charliermarsh",
"dbaeumer",
"esbenp",
"fastmcp",
"modelcontextprotocol",
"nosources",
"pipx",
"toplevel",
"venv",
"vscodeignore",
"yarnrc"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ Your task is to methodically gather context from all relevant parts of the proje

### Step 1: Load MCP Context Documentation

- **Action:**
- **Action:**
Use your directory listing tool to list all files in:

`/workspaces/semanticworkbench/mcp-servers/ai-assist-content`

- **Then:**
- **Then:**
Read the following files:
- `README.md`
- `mcp-llms-full.txt`
Expand All @@ -61,12 +61,12 @@ These files provide the conceptual framework for MCP and contextual guidelines.

### Step 2: Examine the Reference Implementation

- **Action:**
- **Action:**
List all files in the MCP Server Giphy project:

`/workspaces/semanticworkbench/mcp-servers/mcp-server-giphy`

- **Then:**
- **Then:**
Specifically review the files in its `server` subdirectory (e.g., `main.py`, `giphy_search.py`) and high-level configuration files (like `pyproject.toml` and `.vscode` settings).

This will help you understand best practices and reference design patterns used in our MCP projects.
Expand All @@ -75,12 +75,12 @@ This will help you understand best practices and reference design patterns used

### Step 3: Explore the VSCode MCP Server VSCode Extension Project

- **Action:**
- **Action:**
List all files in:

`/workspaces/semanticworkbench/mcp-servers/mcp-server-vscode`

- **Then:**
- **Then:**
Recursively read the contents of key files and directories, including but not limited to:
- `README.md`
- `package.json`
Expand Down
20 changes: 10 additions & 10 deletions mcp-servers/mcp-server-vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ The **VSCode MCP Server** is a VSCode extension that acts as a Model Context Pro

## Features

- **Automatic Startup:**
- **Automatic Startup:**
The extension activates automatically on VSCode startup (using `"activationEvents": ["*"]` in `package.json`), ensuring the MCP server is always running without manual intervention.

- **MCP Server Integration:**
- **MCP Server Integration:**
Built using the MCP TypeScript SDK (`@modelcontextprotocol/sdk`), the extension instantiates an MCP server that registers diagnostic tools and handles MCP protocol messages.

- **Diagnostic Tool (`code_checker`):**
- **Diagnostic Tool (`code_checker`):**
The registered `code_checker` tool collects diagnostics from VSCode’s built-in language services, filtering out files without errors. When invoked, it returns a formatted JSON object containing diagnostic information (only for files with issues).

- **SSE Communication:**
- **SSE Communication:**
An Express-based HTTP server runs on port 6010, exposing:

- A **GET `/sse`** endpoint to establish a long-lived Server-Sent Events (SSE) connection.
- A **POST `/messages`** endpoint for receiving MCP messages from external clients (such as your AI assistant).
- A **POST `/messages`** endpoint for receiving MCP messages from external clients (such as your AI assistant).
Special care is taken to handle the request body properly—thanks to passing the already-parsed `req.body` to avoid stream-related errors.

- **Verbose Logging:**
- **Verbose Logging:**
All activity, including server startup, SSE connection status, and message handling events, is logged to an output channel named **"VSCode MCP Server"** to aid debugging and transparency.

## Project Structure
Expand All @@ -42,14 +42,14 @@ vscode-mcp-server/

## Setup and Installation

1. **Install Dependencies:**
1. **Install Dependencies:**
Ensure you have Node.js (v16 or higher) and pnpm installed. Then, from the project directory, run:

```bash
pnpm install
```

2. **Package the Extension:**
2. **Package the Extension:**
To package the extension, execute:
```bash
pnpm run package-extension
Expand Down Expand Up @@ -115,10 +115,10 @@ To use the VSCode MCP Server with Claude Desktop, you need to configure Claude D
## Debugging the Extension
1. **Start Debugging:**
1. **Start Debugging:**
Open the project in VSCode, then press **F5** to launch the Extension Development Host. This will automatically activate the extension based on the `"activationEvents": ["*"]` setting.
2. **MCP Server Operation:**
2. **MCP Server Operation:**
On activation, the extension:
- Starts the MCP server which registers the `code_checker` tool.
- Sets up an Express HTTP server on port **6010** with:
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions mcp-servers/mcp-server-vscode/src/extension.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as vscode from 'vscode';
export declare function activate(context: vscode.ExtensionContext): void;
import * as vscode from "vscode";
export declare const activate: (context: vscode.ExtensionContext) => void;
export declare function deactivate(): void;
Loading

0 comments on commit 2c2f710

Please sign in to comment.