Skip to content
This repository was archived by the owner on Apr 3, 2026. It is now read-only.

feat: add run_server_code tool for server context execution#55

Open
kevinswint wants to merge 1 commit intoRoblox:mainfrom
kevinswint:feature/server-code-execution-pr
Open

feat: add run_server_code tool for server context execution#55
kevinswint wants to merge 1 commit intoRoblox:mainfrom
kevinswint:feature/server-code-execution-pr

Conversation

@kevinswint
Copy link
Copy Markdown

@kevinswint kevinswint commented Jan 12, 2026

Summary

Adds new MCP tool to execute Luau code in the actual game server context during playtest, unlike run_code which executes in the plugin context.

Motivation

Currently, run_code executes in the plugin's Lua context, which is isolated from server-side game state during playtest. This means you can't:

  • Verify if server scripts initialized properly
  • Check _G values set by ServerScriptService scripts
  • Test server-side functionality

This PR adds run_server_code which executes in the actual game server context.

New Tool: run_server_code

run_server_code({ code: "PING" })
run_server_code({ code: "return _G.PlayerDataStore" })  -- requires LoadStringEnabled

Architecture

  • MCP server queues code commands at /mcp/server_code endpoint
  • Game ServerScript (MCPServerCodeRunner.lua) polls for pending code
  • Script executes code and POSTs results back
  • Tool waits with 30s timeout

Setup

  1. Copy MCPServerCodeRunner.lua to ServerScriptService in your game
  2. Enable HttpService: Game Settings > Security > Allow HTTP Requests
  3. Start playtest (F5)
  4. Use the run_server_code tool

Built-in Commands (work without LoadStringEnabled)

  • PING - Returns "pong" to verify script is running
  • PLAYERS - Returns list of current players
  • STATE - Returns server state info as JSON
  • STOP - Stops the playtest

Test plan

  • Verify tool returns error when not in playtest
  • Verify tool returns error when MCPServerCodeRunner not present
  • Verify tool executes code and returns result (PING → pong)
  • Verify built-in commands work without LoadStringEnabled
  • Verify 30s timeout works

🤖 Generated with Claude Code

@kevinswint kevinswint force-pushed the feature/server-code-execution-pr branch from 07b5940 to c07a213 Compare January 12, 2026 07:37
@kevinswint kevinswint force-pushed the feature/server-code-execution-pr branch from c07a213 to 85f4f6c Compare January 30, 2026 03:05
Adds MCP tool to execute Luau code in the actual game server context
during playtest, unlike run_code which executes in the plugin context.

- run_server_code: Executes code where ServerScriptService scripts run
- GET/POST /mcp/server_code: HTTP endpoints for command queue/results
- MCPServerCodeRunner.lua: ServerScript that polls and executes commands
- Built-in commands (STOP, PING, PLAYERS, STATE) work without loadstring
- Arbitrary code requires LoadStringEnabled in ServerScriptService

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@kevinswint kevinswint force-pushed the feature/server-code-execution-pr branch from 85f4f6c to 52f82ba Compare January 30, 2026 03:54
@glocation87
Copy link
Copy Markdown

glocation87 commented Feb 12, 2026

We need this! runtime read/write is good for testing and debugging;
However, It would also be nice to have an implementation for the client context as well, i think the runtime lua files should be initialized and created by the plugin itself before playtest,

Perhaps:

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants