# 代码执行器
## 基本信息
- Slug: `bazinga012-mcp_code_executor`
- Source: modelscope
- Publisher: @bazinga012/mcp_code_executor
- Categories: developer-tools / virtualization
- Hosted: No
- License: MIT License
- Source URL: https://www.modelscope.cn/mcp/servers/@bazinga012/mcp_code_executor
## 简介
允许大型语言模型（LLMs）在指定的 Conda 环境中执行 Python 代码，从而能够访问高效代码执行所需的相关库和依赖项。
## 安装提示

```bash
git clone https://github.com/bazinga012/mcp_code_executor.git
```

## MCP Server 详情

# MCP 代码执行器
[![smithery 徽章](https://smithery.ai/badge/@bazinga012/mcp_code_executor)](https://smithery.ai/server/@bazinga012/mcp_code_executor)

MCP 代码执行器是一个 MCP 服务器，它允许 LLM 在指定的 Conda 环境中执行 Python 代码。这使得 LLM 能够运行具有访问在 Conda 环境中定义的库和依赖项的代码。

<a href="https://glama.ai/mcp/servers/45ix8xode3"><img width="380" height="200" src="https://glama.ai/mcp/servers/45ix8xode3/badge" alt="代码执行器 MCP 服务器" /></a>

## 功能

- 从 LLM 提示中执行 Python 代码
- 在指定的 Conda 环境中运行代码
- 可配置的代码存储目录

## 前提条件

- 安装了 Node.js
- 安装了 Conda
- 创建了所需的 Conda 环境

## 设置

1. 克隆此仓库：

```bash
git clone https://github.com/bazinga012/mcp_code_executor.git
```


2. 导航到项目目录：

```bash 
cd mcp_code_executor
```


3. 安装 Node.js 依赖项：

```bash
npm install
```


4. 构建项目：

```bash
npm run build
```


## 配置

要配置 MCP 代码执行器服务器，请将以下内容添加到您的 MCP 服务器配置文件中：

```json
{
  "mcpServers": {
    "mcp-code-executor": {
      "command": "node",
      "args": [
        "/path/to/mcp_code_executor/build/index.js" 
      ],
      "env": {
        "CODE_STORAGE_DIR": "/path/to/code/storage",
        "CONDA_ENV_NAME": "your-conda-env"
      }
    }
  }
}
```


替换占位符：
- 将 `/path/to/mcp_code_executor` 替换为克隆此仓库的绝对路径
- 将 `/path/to/code/storage` 替换为您希望存储生成代码的目录
- 将 `your-conda-env` 替换为您希望代码在其内运行的 Conda 环境名称

## 使用

配置完成后，MCP 代码执行器将允许 LLM 通过在指定的 `CODE_STORAGE_DIR` 中生成文件并在 `CONDA_ENV_NAME` 定义的 Conda 环境中运行来执行 Python 代码。

LLM 可以通过在其提示中引用此 MCP 服务器来生成和执行代码。

## 贡献

欢迎贡献！请打开一个 issue 或提交 pull request。

## 许可证

本项目根据 MIT 许可证发布。

