@@ -18,6 +18,7 @@ import (
1818
1919 "github.com/deevus/pixels/internal/config"
2020 "github.com/deevus/pixels/sandbox"
21+ "github.com/deevus/pixels/sandbox/user"
2122)
2223
2324// Tools is the dependency bundle every MCP handler closes over.
@@ -190,17 +191,6 @@ func (t *Tools) requireSandbox(name string) (Sandbox, error) {
190191 return sb , nil
191192}
192193
193- // pixelUID/pixelGID is the unprivileged sandbox user that MCP file operations
194- // write as. Files written by the MCP write_file tool are chowned to this
195- // owner so subsequent exec calls (which also run as this user) can read and
196- // modify them. Hardcoded to match the convention established by the
197- // provisioning scripts (rc.local creates `pixel` at uid 1000); MCP cannot
198- // write root-owned files by design.
199- const (
200- pixelUID = 1000
201- pixelGID = 1000
202- )
203-
204194// editFileMaxBytes caps the in-memory read for EditFile. Editing past this
205195// would silently truncate the rest of the file on write-back.
206196const editFileMaxBytes = 10 * 1024 * 1024
@@ -628,7 +618,7 @@ func (t *Tools) WriteFile(ctx context.Context, in WriteFileIn) (WriteFileOut, er
628618 }
629619 defer t .Locks .Acquire (sb .Name )()
630620
631- if err := t .Backend .WriteFile (ctx , sb .Name , in .Path , []byte (in .Content ), mode , pixelUID , pixelGID ); err != nil {
621+ if err := t .Backend .WriteFile (ctx , sb .Name , in .Path , []byte (in .Content ), mode , user . UID , user . GID ); err != nil {
632622 return WriteFileOut {}, err
633623 }
634624 t .touch (sb .Name )
@@ -710,7 +700,7 @@ func (t *Tools) EditFile(ctx context.Context, in EditFileIn) (EditFileOut, error
710700 updated = strings .Replace (original , in .OldString , in .NewString , 1 )
711701 }
712702
713- if err := t .Backend .WriteFile (ctx , sb .Name , in .Path , []byte (updated ), 0o644 , pixelUID , pixelGID ); err != nil {
703+ if err := t .Backend .WriteFile (ctx , sb .Name , in .Path , []byte (updated ), 0o644 , user . UID , user . GID ); err != nil {
714704 return EditFileOut {}, fmt .Errorf ("write: %w" , err )
715705 }
716706 t .touch (sb .Name )
0 commit comments