This guide explains how to set up and use the MCPShell with Visual Studio Code.
- Visual Studio Code with GitHub Copilot
- MCPShell installed (built from source or downloaded binary)
To use MCPShell with Visual Studio Code, follow these steps:
-
Create your YAML configuration file for the tools you want to expose (e.g.,
mcp-cli.yaml).mcp: run: shell: bash tools: - name: "weather" description: "Get the weather for a location" params: location: type: string description: "The location to get weather for" required: true constraints: - "location.size() <= 50" # Prevent overly long inputs run: command: "curl -s 'https://wttr.in/{{ .location }}?format=3'"
-
Configure VS Code to use the MCPShell by creating a
.vscode/mcp.jsonfile in your workspace:{ "servers": { "mcpshell": { "type": "stdio", "command": "/absolute/path/to/mcpshell", "args": ["mcp", "--tools", "/absolute/path/to/mcp-cli.yaml"] } } }If you have Go installed, you can use it directly:
{ "servers": { "mcpshell": { "type": "stdio", "command": "go", "args": [ "run", "github.com/inercia/MCPShell", "mcp", "--tools", "${workspaceFolder}/mcp-cli.yaml" ] } } }Note: You can use predefined VS Code variables like
${workspaceFolder}in your configuration. -
Restart VS Code or run the MCP: List Servers command from the Command Palette to start the server.
You can configure multiple instances of the MCPShell, each with different tool configurations:
{
"servers": {
"mcp-cli-example": {
"type": "stdio",
"command": "/absolute/path/to/mcpshell",
"args": [
"mcp",
"--tools",
"${workspaceFolder}/examples/config.yaml",
"--logfile",
"${workspaceFolder}/debug.log"
]
},
"mcp-cli-kubernetes-ro": {
"type": "stdio",
"command": "/absolute/path/to/mcpshell",
"args": [
"mcp",
"--tools",
"${workspaceFolder}/examples/kubectl-ro.yaml",
"--logfile",
"${workspaceFolder}/debug.kubernetes-ro.log"
],
"env": {
"KUBECONFIG": "${workspaceFolder}/kubeconfig.yaml"
}
}
}
}If your tools require API keys or other sensitive information, you can use input variables:
{
"inputs": [
{
"type": "promptString",
"id": "api-key",
"description": "API Key",
"password": true
}
],
"servers": {
"mcpshell": {
"type": "stdio",
"command": "/absolute/path/to/mcpshell",
"args": ["mcp", "--tools", "${workspaceFolder}/mcp-cli.yaml"],
"env": {
"API_KEY": "${input:api-key}"
}
}
}
}VS Code will prompt for these values when the server starts for the first time and securely store them for subsequent use.
After configuring the MCPShell:
- Open the Chat view (⌃⌘I on macOS, Ctrl+Alt+I on Windows/Linux)
- Select Agent mode from the dropdown
- Click the Tools button to view and select available tools
- Enter your query in the chat input box
When a tool is invoked, you'll need to confirm the action before it runs. You can choose to automatically confirm the specific tool for the current session, workspace, or all future invocations.
To manage your MCP servers:
- Run the MCP: List Servers command from the Command Palette
- Select a server to start, stop, restart, view configuration, or view server logs
If you're experiencing issues with the MCPShell in VS Code:
- Check for error indicators in the Chat view. Select the error notification and then Show Output to view server logs.
- Verify paths: Ensure all file paths in your configuration are correct.
- Environment variables: Make sure any required environment variables are properly set.
- Permissions: Verify that the MCPShell binary has execution permissions.
- Connection type: Ensure the server connection type (
type: "stdio") is correctly specified.
When using MCPShell with VS Code, be aware of the following security considerations:
- The tools you configure have the same system access permissions as VS Code.
- Be careful with tools that execute shell commands or access sensitive files.
- Use constraints to limit what your tools can do, especially when executing commands.
- Consider running VS Code with restricted permissions when using powerful tools.