mcp-server-wslc

mcp-server-wslc

Enables AI agents to manage WSL containers and images via the wslc CLI, supporting container lifecycle, network, volume, and registry operations through natural language.

Category
访问服务器

README

mcp-server-wslc

npm version License Node.js

MCP (Model Context Protocol) server for Microsoft's wslc CLI — a typed API wrapper that lets AI agents manage WSL containers safely.

Supported Clients

Claude Code · Codex CLI · Hermes · OpenClaw · Cursor · VS Code Agent


Quick Start

npm install -g mcp-server-wslc

Or run directly with npx:

npx mcp-server-wslc

Requirements: Node.js >= 22, wslc on PATH.


Client Configuration

Claude Code

{
  "mcpServers": {
    "wslc": {
      "command": "npx",
      "args": ["mcp-server-wslc"]
    }
  }
}

Restart Claude Code, then try:

List all WSL containers. Pull alpine:latest. Create a container named "web-test" from ubuntu:24.04 with 512M memory.

Codex CLI

{
  "mcpServers": {
    "wslc": {
      "command": "npx",
      "args": ["mcp-server-wslc"]
    }
  }
}

Cursor / VS Code Agent

{
  "mcpServers": {
    "wslc": {
      "command": "npx",
      "args": ["mcp-server-wslc"]
    }
  }
}

Hermes / OpenClaw

{
  "mcpServers": {
    "wslc": {
      "command": "npx",
      "args": ["mcp-server-wslc"]
    }
  }
}

Commands

npm run dev          # tsx — run TypeScript directly
npm run build        # tsc → dist/
npm run check        # tsc --noEmit (type-check only)
npm run test         # vitest — run unit tests
npm run test:watch   # vitest — watch mode
npm run test:coverage # vitest — test coverage report
npm start            # node dist/index.js (production)

Available Tools

Core

Tool Description Parameters
list_containers List all WSL containers format (table | json)
list_images List all WSL container images format (table | json)

Container Management

Tool Description Key Parameters
container_create Create a new container image, name, cpus, memory, env, publish, volume, workdir, interactive, tty, rm
container_run Run a container image, name, detach, cpus, memory, env, publish, volume, interactive, tty, rm
container_inspect Show container details containerId
container_start Start a stopped container containerId, attach, interactive
container_stop Stop a running container containerId, signal, time
container_restart Restart a container (stop + start) containerId, signal, time
container_remove Remove a container containerId, force
container_logs View container logs containerId, follow, tail, timestamps, since, until
container_exec Execute a command in a container containerId, command, commandArgs, detach, env, interactive, tty, user, workdir
container_stats Resource usage snapshot containerId, all, format, noTrunc

container_restart composes stop + start — wslc has no native restart command.

Image Management

Tool Description Key Parameters
image_pull Pull an image from a registry image
image_push Push an image to a registry image
image_build Build an image from a Dockerfile path, file, tag, buildArg, target, pull, noCache, label, verbose
image_tag Tag an image source, target
image_inspect Show image details image
image_remove Remove an image image, force, noPrune

Network Management

Tool Description Key Parameters
network_list List all networks format, quiet
network_create Create a network name, driver, opt, label
network_remove Remove a network name, force

Volume Management

Tool Description Key Parameters
volume_list List all volumes format, quiet
volume_create Create a named volume name, driver, opt, label
volume_remove Remove a volume name, force

Registry Authentication

Tool Description Key Parameters
registry_login Log in to a registry server, username, password, passwordStdin
registry_logout Log out from a registry server

Security: Prefer passwordStdin over password to avoid exposing credentials in process lists.

System

Tool Description Key Parameters
system_version Get wslc CLI version
system_prune Remove all stopped containers

Example Prompts

List all running WSL containers.
Show me the wslc version.
What container images are available? Show in JSON format.
Create a container named "web-test" from ubuntu:24.04 with 1 CPU and 512M memory.
Run nginx in the background with port 8080 published.
View the last 50 lines of logs from container "web-test".
Get stats for all running containers in JSON format.
Pull alpine:latest and create a container from it.
Tag ubuntu:24.04 as my-ubuntu:latest.
Create a network named "backend" and run a container attached to it.

Project Structure

mcp-server-wslc/
├── src/
│   ├── index.ts                     # Entry point
│   ├── server.ts                    # McpServer + stdio transport
│   ├── registry/
│   │   └── registerTools.ts         # Central tool registration
│   ├── tools/
│   │   ├── containers/              # 11 files + 1 test
│   │   │   ├── list.ts, create.ts, run.ts, run.test.ts, inspect.ts
│   │   │   ├── start.ts, stop.ts, restart.ts, remove.ts
│   │   │   └── logs.ts, exec.ts, stats.ts
│   │   ├── images/                  # 7 files
│   │   │   ├── list.ts, pull.ts, push.ts, build.ts
│   │   │   └── tag.ts, inspect.ts, remove.ts
│   │   ├── networks/                # 3 files
│   │   │   └── list.ts, create.ts, remove.ts
│   │   ├── volumes/                 # 3 files
│   │   │   └── list.ts, create.ts, remove.ts
│   │   ├── registry/                # 2 files
│   │   │   └── login.ts, logout.ts
│   │   └── system/                  # 2 files
│   │       └── version.ts, prune.ts
│   └── utils/
│       ├── wslc.ts                  # runWslc() — single execution point
│       └── wslc.test.ts             # Unit tests for runWslc()
├── dist/                            # Compiled output (33 JS files)
├── vitest.config.ts
├── package.json
├── tsconfig.json
├── README.md
└── README.zh-CN.md

Testing

Unit tests use vitest. Tests cover:

  • runWslc() — execution wrapper: stdout/stderr trimming, timeout, ENOENT, error propagation
  • buildContainerRunArgs() — CLI argument construction for container_run: all parameter types and combinations
npm run test           # Single run
npm run test:watch     # Watch mode
npm run test:coverage  # Coverage report (v8)

License

ISC

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选