BM

bazinga012/mcp_code_executor

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

211 stars 43 forks 品質 65 トレンド 17MIT

bazinga012/mcp_code_executor は、https://github.com/bazinga012/mcp_code_executor.からインポートされたMCPサーバー候補です。

概要

bazinga012/mcp_code_executor は、https://github.com/bazinga012/mcp_code_executor.からインポートされたMCPサーバー候補です。

概要(AI 翻訳)

MCPコードエグゼキューターは、LLMが指定されたPython環境内でPythonコードを実行できるようにするMCPサーバーです。これにより、LLMは環境内で定義されたライブラリや依存関係にアクセスできるコードを実行することができます。また、トークン制限を超える可能性のある大規模なコードブロックを処理するためのインクリメンタルコード生成もサポートしています。

特徴

  • LLMプロンプトからPythonコードを実行
  • トークンの制限を克服するためのインクリメンタルコード生成のサポート
  • 指定された環境(Conda、virtualenv、またはUV virtualenv)内でコードを実行
  • 必要に応じて依存関係をインストールする
  • パッケージがすでにインストールされているかどうか確認
  • 実行時に環境を動的に構成する
  • 設定可能なコードストレージディレクトリ

前提条件

  • Node.js 設置
  • 以下のいずれか:
  • Condaを希望するConda環境でインストール
  • Python virtualenv
  • UV virtualenv

セットアップ

  1. このリポジトリのクローン:

  2. プロジェクトディレクトリへ移動する:

  3. Node.js依存関係をインストールする:

  4. プロジェクトの構築:

構成

MCPコード実行サーバーを設定するには、MCPサーバーの設定ファイルに以下を追加してください:

Node.jsを使って

Docker 使用中

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

MCP Code Executor

The MCP Code Executor is an MCP server that allows LLMs to execute Python code within a specified Python environment. This enables LLMs to run code with access to libraries and dependencies defined in the environment. It also supports incremental code generation for handling large code blocks that may exceed token limits.

Features

  • Execute Python code from LLM prompts
  • Support for incremental code generation to overcome token limitations
  • Run code within a specified environment (Conda, virtualenv, or UV virtualenv)
  • Install dependencies when needed
  • Check if packages are already installed
  • Dynamically configure the environment at runtime
  • Configurable code storage directory

Prerequisites

  • Node.js installed
  • One of the following:
    • Conda installed with desired Conda environment created
    • Python virtualenv
    • UV virtualenv

Setup

  1. Clone this repository:
git clone https://github.com/bazinga012/mcp_code_executor.git
  1. Navigate to the project directory:
cd mcp_code_executor
  1. Install the Node.js dependencies:
npm install
  1. Build the project:
npm run build

Configuration

To configure the MCP Code Executor server, add the following to your MCP servers configuration file:

Using Node.js

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

Using Docker

{
  "mcpServers": {
    "mcp-code-executor": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp-code-executor"
      ]
    }
  }
}

Note: The Dockerfile has been tested with the venv-uv environment type only. Other environment types may require additional configuration.

Environment Variables

Required Variables

  • CODE_STORAGE_DIR: Directory where the generated code will be stored

Environment Type (choose one setup)

  • For Conda:

    • ENV_TYPE: Set to conda
    • CONDA_ENV_NAME: Name of the Conda environment to use
  • For Standard Virtualenv:

    • ENV_TYPE: Set to venv
    • VENV_PATH: Path to the virtualenv directory
  • For UV Virtualenv:

    • ENV_TYPE: Set to venv-uv
    • UV_VENV_PATH: Path to the UV virtualenv directory

Available Tools

The MCP Code Executor provides the following tools to LLMs:

1. execute_code

Executes Python code in the configured environment. Best for short code snippets.

GitHub で README 全文を見る

インストール

docker run -i --rm mcp-code-executor
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

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