Token导航 LogoToken导航TokenDH.com
Wsl MCP Server logo
运维云端未说明官方级别未说明来源级核验

Wsl MCP Server

MCP Server

一个基于.NET 10的模型上下文协议(MCP)服务器,提供AI驱动的Windows Subsystem for Linux(WSL)配置和管理功能,包括智能代理、性能分析和资源预测。

工具数

15

提示词数

0

GitHub Stars

0

资源数

0
性能优化C#AI驱动

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

sirredbeard

提供方

sirredbeard

最后核验

2026/5/17 20:23

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

WSL MCP服务器-智能WSL管理

使用构建的强大的模型上下文协议(MCP)服务器。NET 10,支持基于AI的Windows Linux子系统(WSL)配置和管理。具有使用Microsoft语义内核和机器学习功能进行优化和预测的智能代理。

🚀 特性

WSL核心管理

  • 分销管理:列出、安装、启动、停止、导出和导入WSL发行版
  • 命令执行:在任何WSL发行版中运行命令
  • 配置:通过以下方式修改WSL设置(内存、CPU、交换等) .wslconfig
  • 文件操作:在Windows和WSL文件系统之间复制文件
  • 系统信息:获取详细的WSL版本和状态信息

🤖 人工智能驱动的智能

  • 语义核心代理:具有自然语言理解能力的复杂任务规划和执行
  • 性能分析:基于机器学习的WSL资源使用和瓶颈洞察
  • 智能推荐:基于系统指标的AI生成的优化建议
  • 资源预测:预测不同工作负载类型的资源需求
  • 自动化任务规划:将复杂的操作分解为可管理的步骤

🎯 Windows 11 ML集成

  • 性能趋势分析
  • 瓶颈检测
  • 针对具体工作量的资源建议
  • 健康评分和诊断

📋 先决条件

  • Windows 11(建议使用22H2或更高版本)
  • WSL 2已安装并配置
  • .NET 10 SDK
  • (可选)用于高级代理功能的OpenAI API密钥

🛠️ 安装

1.克隆或下载

cd d:\wsl-mcp-agent

2.恢复依赖关系

dotnet restore

3.建设项目

dotnet build

4.(可选)配置AI功能

对于语义内核代理功能,设置环境变量:

$env:OPENAI_API_KEY = "your-api-key-here"

或者使用Azure OpenAI:

$env:AZURE_OPENAI_ENDPOINT = "your-endpoint"
$env:AZURE_OPENAI_KEY = "your-key"

5.运行服务器

dotnet run

📖 MCP工具参考

WSL基本操作

wsl_list_distros

列出所有已安装的WSL发行版及其状态信息。

参数:无

示例响应:

[
  {
    "name": "Ubuntu",
    "isDefault": true,
    "state": "Running",
    "version": "2"
  }
]

wsl_get_info

获取WSL版本和系统信息。

参数:无

wsl_install_distro

安装新的WSL发行版。

参数:

  • distro (string):发行版名称(例如,“Ubuntu”、“Debian”、“Kali Linux”)

wsl_start_distro

启动或唤醒WSL分发。

参数:

  • distro (string):要开始的分发名称

wsl_stop_distro

停止/终止正在运行的WSL分发。

参数:

  • distro (string):要停止的分发名称

wsl_execute_command

在WSL发行版中执行命令。

参数:

  • distro (string):分发名称
  • command (string):要执行的命令

示例:

{
  "distro": "Ubuntu",
  "command": "uname -a"
}

配置和管理

wsl_configure

配置WSL设置(内存、处理器、交换等)。

参数:

  • settings (object):配置对象

示例:

{
  "settings": {
    "memory": "8GB",
    "processors": "4",
    "swap": "4GB",
    "localhostForwarding": "true"
  }
}

wsl_export_distro

将WSL发行版导出到tar文件。

参数:

  • distro (string):分发名称
  • output_path (string):tar文件的路径(例如,“C:\\backups\\ubuntu.tar”)

wsl_import_distro

从tar文件导入WSL发行版。

参数:

  • distro (string):新分发名称
  • tar_path (string):tar文件的路径
  • install_path (string):安装位置

文件操作

wsl_copy_from_wsl

将文件从WSL复制到Windows。

参数:

  • distro (string):分发名称
  • wsl_path (string):WSL中的源路径(例如,“/home/user/file.txt”)
  • windows_path (string):Windows中的目标(例如,“C:\\temp\\file.txt”)

wsl_copy_to_wsl

将文件从Windows复制到WSL。

参数:

  • distro (string):分发名称
  • windows_path (string):Windows中的源路径
  • wsl_path (string):WSL中的目标

🤖 AI代理功能

wsl_agent_task

使用AI代理执行复杂的WSL任务,并进行规划和推理。

参数:

  • task (string):自然语言任务描述
  • context (字符串,可选):其他上下文或约束

示例:

{
  "task": "Set up a new Ubuntu distribution optimized for Docker development",
  "context": "I need at least 16GB memory and want to enable systemd"
}

wsl_get_recommendations

获取人工智能支持的WSL优化建议。

参数:

  • distro (字符串,可选):特定分发名称

示例响应:

{
  "score": 75,
  "items": [
    {
      "category": "Memory",
      "priority": "High",
      "title": "High Memory Usage Detected",
      "description": "Current memory usage is 85%",
      "action": "Add 'memory=8GB' to .wslconfig",
      "expectedImpact": "Improved performance and reduced swapping"
    }
  ]
}

wsl_analyze_performance

使用机器学习见解分析WSL性能和资源使用情况。

参数:

  • distro (字符串,可选):特定分发名称

wsl_predict_resources

使用ML预测未来的资源需求。

参数:

  • distro (string):分发名称
  • workload (string):工作负载描述(例如,“Docker容器”、“ML培训”、“web开发”)

示例:

{
  "distro": "Ubuntu",
  "workload": "Running multiple Docker containers for microservices development"
}

示例响应:

{
  "recommendedMemoryGb": 16,
  "recommendedCpuCores": 6,
  "recommendedDiskGb": 100,
  "confidence": 0.90,
  "reasoning": "Container workloads require substantial resources"
}

🎮 用法示例

示例1:基本WSL管理

// List all distributions
{"tool": "wsl_list_distros"}

// Start Ubuntu
{"tool": "wsl_start_distro", "arguments": {"distro": "Ubuntu"}}

// Execute command
{"tool": "wsl_execute_command", "arguments": {
  "distro": "Ubuntu",
  "command": "df -h"
}}

示例2:配置

// Configure WSL for high-performance workloads
{"tool": "wsl_configure", "arguments": {
  "settings": {
    "memory": "16GB",
    "processors": "8",
    "swap": "8GB",
    "nestedVirtualization": "true",
    "vmIdleTimeout": "60000"
  }
}}

示例3:人工智能驱动的任务执行

// Let the agent handle complex setup
{"tool": "wsl_agent_task", "arguments": {
  "task": "Install and configure a new Debian distribution for Python data science work",
  "context": "Need Jupyter, pandas, numpy, and scikit-learn"
}}

// Get performance recommendations
{"tool": "wsl_get_recommendations", "arguments": {
  "distro": "Ubuntu"
}}

// Predict resources for workload
{"tool": "wsl_predict_resources", "arguments": {
  "distro": "Ubuntu",
  "workload": "Training machine learning models with TensorFlow"
}}

示例4:备份和迁移

// Export current distribution
{"tool": "wsl_export_distro", "arguments": {
  "distro": "Ubuntu",
  "output_path": "C:\\Backups\\ubuntu-backup.tar"
}}

// Import to new location
{"tool": "wsl_import_distro", "arguments": {
  "distro": "Ubuntu-Dev",
  "tar_path": "C:\\Backups\\ubuntu-backup.tar",
  "install_path": "C:\\WSL\\Ubuntu-Dev"
}}

🏗️ 建筑

技术栈

  • .NET 10:最新。NET功能,包括原生AOT支持
  • 模型上下文协议:用于工具注册和通信的MCP SDK
  • 微软语义内核:AI代理编排和规划
  • 微软。毫升:用于预测和建议的机器学习
  • Windows SDK:本机Windows集成

项目结构

WslMcpServer/
├── Program.cs                    # MCP server initialization and tool registration
├── Services/
│   └── WslService.cs            # Core WSL operations via wsl.exe
├── Agents/
│   ├── WslAgentService.cs       # Semantic Kernel agent integration
│   └── WslIntelligenceService.cs # ML-powered analytics and predictions
└── WslMcpServer.csproj          # Project configuration

⚙️ 配置

WSL配置(.wslconfig)

服务器可以修改 %USERPROFILE%\.wslconfig:

[wsl2]
memory=8GB              # Memory allocation
processors=4            # CPU cores
swap=4GB               # Swap space
localhostForwarding=true
nestedVirtualization=true
vmIdleTimeout=60000
dnsTunneling=true      # Improved network performance

环境变量

  • OPENAI_API_KEY:代理功能的OpenAI API密钥
  • AZURE_OPENAI_ENDPOINT:Azure OpenAI端点
  • AZURE_OPENAI_KEY:Azure OpenAI密钥

🔍 故障排除

WSL未找到

确保WSL已安装:

wsl --install

权限问题

如果需要,以管理员身份运行:

Start-Process powershell -Verb RunAs

代理功能不起作用

  1. 验证是否设置了AI凭据
  2. 检查网络连接
  3. 查看日志以了解详细错误

🚧 发展

为生产而建

dotnet publish -c Release -r win-x64 --self-contained

运行测试

dotnet test

启用调试日志

修改 appsettings.json 或设置:

$env:DOTNET_ENVIRONMENT = "Development"

📝 许可证

有关详细信息,请参阅LICENSE文件。

🤝 贡献

欢迎投稿!该项目展示了:

  • 最新的。NET 10功能
  • MCP服务器实现
  • AI代理与语义内核的集成
  • Windows ML功能
  • WSL自动化

🔗 相关资源

💡 高级用例

  1. 自动化开发环境:跨团队创建一致的开发环境
  2. CI/CD集成:管理WSL环境以构建管道
  3. 多分布测试:跨不同Linux发行版进行测试
  4. 资源优化:基于工作负载的人工智能资源分配
  5. 灾难恢复:自动备份和恢复过程
  6. 性能监控:持续分析和优化建议

______________________________________________________________________

用。净值10🚀 | 由AI驱动🤖 | 适用于Windows 11💻

目录标签

目录标签

性能优化C#AI驱动WSL管理本地部署资源预测Windows开发

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

15

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP