MCP ExplorerExplorer

Luamcp

@called-don a year ago
1 MIT
FreeCommunity
AI Systems
LuaMCP is a simple Lua execution environment for MCP, with restricted access.

Overview

What is Luamcp

LuaMCP is a simple Lua execution environment designed to understand MCP. It restricts external interference to ensure a secure execution context.

Use cases

Use cases for LuaMCP include running Lua scripts in a controlled environment, testing Lua code snippets during development, and providing a safe platform for executing user-defined Lua code.

How to use

To use LuaMCP, set it up in Visual Studio Code by enabling the MCP setting and adding LuaMCP to the settings.json file. You can execute Lua code using the EvalLuaCode tool and manage global variables with ListGlobals.

Key features

Key features of LuaMCP include the ability to execute Lua code snippets, manage session states with unique identifiers, and list global variables while controlling visibility of certain libraries.

Where to use

LuaMCP can be used in educational environments for teaching Lua programming, in development for testing Lua scripts, and in secure applications where code execution needs to be sandboxed.

Content

LuaMCP

MCP の理解のために書いた、シンプルな Lua 実行環境です。外部に悪さできないように一通りの手段は塞いであります [^jail]

Tools

EvalLuaCode

  • string code
  • string? sessionId = null

code を実行して結果を返します。関数の定義など、グローバル変数に格納したものを後から使うことができます

sessionId はそれぞれの Lua のステートに振られる識別子です。省略すると新しい独立したステートを作成し一意な sessionId を与えます

それぞれのステートは永続化されていません。MCP サーバーの終了時に揮発します

[!NOTE]
code が Lua のチャンクとして正しい必要があるため、return 1 + 1do for k, _ in pairs(_G) do print(k) end end のようにする必要があります(だいたい指示しなくてもこうしてくれますが)

ListGlobals

  • string? sessionId = null
  • bool? includeMisc = false

ステートのグローバル変数のリストを返します
ライブラリのテーブルや _G, _VERSION 等は表示しないことができます

メモ

プロンプト

* 明示的に指示されなければワークスペースのソースコードを触らない
* 日本語で応答
* なるべく Lua MCP を使う。とくに計算せよ、変数に格納せよ等の指示に従う
  + ただし、eval せずに先にソースコードを確認したいこともある。ニュアンスの違いを読み取り適切に判断せよ
* 定義せよ、あるいはグローバル変数に格納せよと言われていないものはなるべく local にすること
  + 指示された動作を行う関数それそのものは local を付けず(グローバルで)定義してよい
  + 必要に応じて即時実行関数を活用せよ

設定

Visual Studio Code の場合

設定で Chat › Mcp: Enabled にして LuaMCP を settings.json に追加してください

    "mcp": {
        "inputs": [],
        "servers": {
            "LuaMCP": {
                "command": "path\\to\\LuaMCP.exe",
            }
        }
    }

[^jail]: LuaEngine.cs の #region limitations 周辺

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers