Skip to content

feat(mcp): add session spawning helper#292

Merged
forketyfork merged 3 commits intomainfrom
feature/291-mcp-spawn-session
Apr 28, 2026
Merged

feat(mcp): add session spawning helper#292
forketyfork merged 3 commits intomainfrom
feature/291-mcp-spawn-session

Conversation

@forketyfork
Copy link
Copy Markdown
Owner

Solution

Adds a separate architect-mcp stdio helper for local MCP clients. It exposes spawn_session, validates the tool arguments, and forwards requests to the running Architect app through a Unix-domain control socket discovered from the runtime temp directory.

The app handles those requests on the main loop: it validates the working directory, picks or expands a grid slot, spawns the terminal session, queues optional command text, focuses the new session, and returns structured success or stable error codes. Build, release packaging, Homebrew, and docs now ship and describe the helper.

Closes #291

Checks

  • nix develop -c zig build
  • nix develop -c zig build test
  • nix develop -c just lint
  • git diff --check
  • MCP smoke checks for tools/list and spawn_session

Test plan

  • Start Architect, call spawn_session through architect-mcp with an existing absolute cwd, and confirm a new focused session appears.
  • Call spawn_session with a command value and confirm the command is submitted in the new shell.

Issue: Implement #291 by adding an MCP entry point that lets external clients ask a running Architect app to create a terminal session.
Solution: Add a separate `architect-mcp` stdio server plus a small local control socket owned by the GUI process. The helper validates `spawn_session` calls, forwards them to Architect, and returns structured success or stable error codes. Runtime handles spawning on the main loop so grid changes, focus, and command input stay on the existing session path.
@forketyfork forketyfork requested a review from Copilot April 28, 2026 12:36
@forketyfork forketyfork marked this pull request as ready for review April 28, 2026 12:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 050793be53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/control.zig Outdated
Comment thread src/app/control.zig Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an architect-mcp stdio MCP helper and a local control socket path so external MCP clients can request that a running Architect instance spawn a new terminal session.

Changes:

  • Introduces architect-mcp MCP JSON-RPC server with a single spawn_session tool and argument validation.
  • Adds an in-app Unix control socket listener + queue drained on the main loop to execute external spawn requests.
  • Updates build/release packaging (macOS bundling, Homebrew, GitHub release workflow) and docs to ship and describe the helper.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/mcp/main.zig New MCP stdio server implementation + unit tests for tool listing and error results
src/app/runtime.zig Main-loop drain/handling of external spawn requests; slot planning, cwd validation, command queueing; tests
src/app/control.zig New shared control-socket protocol: discovery, request parsing, socket listener thread, request queue, response parsing
scripts/bundle-macos.sh Bundles/signs architect-mcp into the app bundle and patches dylib references
docs/development.md Notes that release archives include both architect and architect-mcp
docs/ai-integration.md Documents MCP spawn_session interface and helper paths
docs/ARCHITECTURE.md Updates architecture docs to include control socket + MCP helper data flow
build.zig Builds/installs architect-mcp and adds a test target for it
README.md Documents MCP capability, usage, and helper paths
Formula/architect.rb Installs architect-mcp into the bundle and symlinks it on PATH
.github/workflows/release.yaml Passes architect-mcp into the macOS bundling step

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/app/control.zig Outdated
Comment thread src/app/control.zig Outdated
Comment thread src/mcp/main.zig
Comment thread src/app/control.zig Outdated
Issue: Address PR #292 review comments about blocked control reads, shared discovery files, atomic discovery writes, and oversized MCP stdin lines.
Solution: Bound local control request reads with a non-blocking accepted socket and a deadline, use per-user/per-process discovery files, atomically publish discovery JSON with 0600 permissions, and make the MCP stdin loop discard the rest of an oversized line before parsing again.
Issue: `architect-mcp` could miss the running app when Architect and the helper were launched from different environments, because the fallback discovery path used process-local TMPDIR values.
Solution: Keep honoring XDG_RUNTIME_DIR when it is set, but otherwise use a stable per-user runtime directory under the user cache location. Create that managed directory with private permissions and document the discovery location so MCP clients can work without users copying temp paths.
@forketyfork forketyfork merged commit 92c5692 into main Apr 28, 2026
4 checks passed
@forketyfork forketyfork deleted the feature/291-mcp-spawn-session branch April 28, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add MCP spawn_session interface

2 participants