VS Code MCP Configuration

Configure MCP servers in VS Code to monitor AI assistant interactions. Works with Copilot, Claude, and other AI extensions.

Prerequisites
  • 1.Install the MCP extension for VS Code from the marketplace
  • 2.Install Kilometers CLI: curl -sSL https://get.kilometers.ai/install.sh | sh
  • 3.Configure your API key: km init
Configuration Options
Choose between global settings or workspace-specific configuration:

User Settings

Global VS Code settings for all workspaces

FILE PATH
~/Library/Application Support/Code/User/settings.json

Workspace Settings

Project-specific settings (recommended)

FILE PATH
.vscode/settings.json

Configuration Templates

Add these configurations to your VS Code settings.json file. Each template shows the exact settings needed for different MCP servers.

GitHub MCP Integration
Access GitHub repositories directly from VS Code AI features

Setup Instructions:

  1. 1.Install the MCP extension for VS Code from the marketplace
  2. 2.Create a GitHub Personal Access Token at https://github.com/settings/tokens
  3. 3.Grant 'repo' permissions for private repositories access
  4. 4.Install the GitHub MCP server: npm install -g @modelcontextprotocol/server-github
  5. 5.Replace 'your_github_token_here' with your actual token

VS Code Settings:

settings.json
{
  "mcp.servers": {
    "github": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_token_here"
      }
    }
  }
}

Test Your Configuration:

After saving your settings, restart VS Code and run:

km validate

Use your AI assistant in VS Code and check the Kilometers dashboard for events.

Filesystem Access
Allow AI to read and write files in your workspace

Setup Instructions:

  1. 1.Install the MCP extension for VS Code
  2. 2.Install the filesystem MCP server: npm install -g @modelcontextprotocol/server-filesystem
  3. 3.The ${workspaceFolder} variable automatically uses your current workspace
  4. 4.For multiple workspaces, you can specify absolute paths

VS Code Settings:

settings.json
{
  "mcp.servers": {
    "filesystem": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-filesystem",
        "${workspaceFolder}"
      ],
      "env": {}
    }
  }
}

Test Your Configuration:

After saving your settings, restart VS Code and run:

km validate

Use your AI assistant in VS Code and check the Kilometers dashboard for events.

Web Search Integration
Enable AI to search the web using Brave Search

Setup Instructions:

  1. 1.Sign up for Brave Search API at https://api.search.brave.com/
  2. 2.Get your API key from the Brave Search dashboard
  3. 3.Install the Brave Search MCP server: npm install -g @modelcontextprotocol/server-brave-search
  4. 4.Replace 'your_brave_api_key_here' with your actual API key

VS Code Settings:

settings.json
{
  "mcp.servers": {
    "brave-search": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-brave-search"
      ],
      "env": {
        "BRAVE_API_KEY": "your_brave_api_key_here"
      }
    }
  }
}

Test Your Configuration:

After saving your settings, restart VS Code and run:

km validate

Use your AI assistant in VS Code and check the Kilometers dashboard for events.

Database Queries
Query SQLite databases from VS Code AI

Setup Instructions:

  1. 1.Install the SQLite MCP server: npm install -g @modelcontextprotocol/server-sqlite
  2. 2.Replace '/path/to/database.db' with your actual database path
  3. 3.Use relative paths for databases in your project
  4. 4.Server provides read-only access to the database

VS Code Settings:

settings.json
{
  "mcp.servers": {
    "sqlite": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-sqlite",
        "/path/to/database.db"
      ],
      "env": {}
    }
  }
}

Test Your Configuration:

After saving your settings, restart VS Code and run:

km validate

Use your AI assistant in VS Code and check the Kilometers dashboard for events.

Multiple Servers
Configure multiple MCP servers in VS Code

Setup Instructions:

  1. 1.Configure multiple MCP servers in the same settings file
  2. 2.Each server must have a unique name
  3. 3.All servers will be monitored by Kilometers independently
  4. 4.Test each server individually before combining

VS Code Settings:

settings.json
{
  "mcp.servers": {
    "github": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "your_github_token_here"
      }
    },
    "filesystem": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-filesystem",
        "${workspaceFolder}"
      ],
      "env": {}
    },
    "brave-search": {
      "command": "km",
      "args": [
        "npx",
        "@modelcontextprotocol/server-brave-search"
      ],
      "env": {
        "BRAVE_API_KEY": "your_brave_api_key_here"
      }
    }
  }
}

Test Your Configuration:

After saving your settings, restart VS Code and run:

km validate

Use your AI assistant in VS Code and check the Kilometers dashboard for events.

Advanced Configuration

Workspace Variables:

VS Code supports variables in MCP server configurations:

  • ${workspaceFolder} - Current workspace root
  • ${workspaceFolderBasename} - Workspace name
  • ${file} - Current file path
  • ${env:VARIABLE_NAME} - Environment variable

Per-Project Configuration:

Create a .vscode/settings.json file in your project root for project-specific MCP servers:

{
  "mcp.servers": {
    "project-db": {
      "command": "km",
      "args": ["npx", "@modelcontextprotocol/server-sqlite", "./data/project.db"],
      "env": {}
    }
  }
}
Troubleshooting

Common Issues:

  • MCP extension not found: Install from VS Code marketplace
  • Server not starting: Check that MCP server is installed globally
  • No events appearing: Verify Kilometers CLI is configured with km validate
  • Permission errors: Ensure file paths are accessible to VS Code

Debug Steps:

  1. 1.Check VS Code output panel for MCP extension logs
  2. 2.Verify JSON syntax in settings.json
  3. 3.Test MCP server manually: km npx @modelcontextprotocol/server-github
  4. 4.Check environment variables and API keys

Start Monitoring Your VS Code AI

Once configured, all interactions between VS Code AI extensions and MCP servers will be monitored by Kilometers.