Skip to content

chore(0.16): MCP + server — mcp.zig, server.zig + Child.run #285

@justrach

Description

@justrach

Problem

The MCP server is the main entry point that reads stdin and writes stdout per JSON-RPC. It also opens project directories, realpath's paths, accesses snapshot files, reads WAL logs, and shells out to git via Child.run. The legacy server.zig also has fs ops.

Failing evidence

src/mcp.zig:176,188,1420,1431,1457,2417,2429  std.fs.max_path_bytes buffers
src/mcp.zig:391,572,590,2087,2106           std.fs.File in function sigs
src/mcp.zig:422                              std.fs.File.stdin()
src/mcp.zig:1029,2000,2001                   std.fs.cwd().openFile/createFile
src/mcp.zig:1408,1470                        std.fs.cwd().openDir
src/mcp.zig:1433                             std.fs.cwd().access
src/mcp.zig:1458,2430                        std.fs.cwd().realpath
src/mcp.zig:1479                             std.fs.selfExePathAlloc
src/mcp.zig:1601                             std.fs.cwd().readFileAlloc (WAL)
src/mcp.zig:1343,1367,1484                   std.process.Child.run (git shell-outs)
src/server.zig:276                           std.fs.cwd().openFile

Expected

  • mcp.run(io, ...) accepts io and threads it to every handler.
  • handleRead, handleSnapshot, handleProjects, handleIndex, handleFind all accept or reach a captured io.
  • writeResult / writeError / writeRequest — stdout becomes either cio.File (we have a shim already) or std.Io.File with writeStreamingAll(io, ...).
  • Git shell-outs use cio.runCapture (already in shim) instead of std.process.Child.run.
  • std.fs.selfExePathAlloc replaced with std.Io.selfExePath or a cio shim.

Fix

Convert fs ops as in storage/discovery. For the three Child.run sites, swap to cio.runCapture(.{ .allocator = alloc, .argv = &.{"git", ...}, .max_output_bytes = N }).

Depends on

#PARENT_FOUNDATION, #PARENT_STORAGE, #PARENT_DISCOVERY

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions