MCP server: connect, authenticate and read the Project (#188) #201
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
needs-info
needs-triage
question
ready-for-agent
ready-for-human
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
crowmaki/ai-studio!201
Loading…
Reference in a new issue
No description provided.
Delete branch "issue-188-mcp-server"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #188. Part of #157.
What
This is the first slice of the MCP server. A harness can connect to the running app, authenticate and read the open Project.
src-tauri/src/mcp.rsis a second adapter next to the taurpcApi. It serves Streamable HTTP (rmcppinned to=3.5.1, on axum) on127.0.0.1only, on the app's Tokio runtime. It holds a clone of the windows'ApiImpl, so it shares the session, the Render worker, the undo log and theChangedDtoevents (ADR-0003).Authorization: Bearer <token>gets 401. A request whoseOriginis not a loopback origin gets 403 (rmcp's origin allowlist). rmcp's default loopbackHostcheck stays on.McpSettingsin studio-core (mcp.json, next tocomfyui.json) holds on/off (off by default), the port (default 8790) and a random token made on first read. They are not in any Project's undo log. The newApiImplcommands aremcp_settings,set_mcp_settings(enabled, port)andregenerate_mcp_token. Each change restarts the listener. The DTO also reports the URL while the server is listening, or an error such as "port 8790 is already in use", ready for the settings UI ticket. The app starts the server at launch when it is switched on.CommandErrorbecomes a tool error (isError) with itskindand amessage(newDisplayimpl), never a protocol error. Invalid aspect ratios and image models now list the valid values.get_project,undo,redoandundo_state. Undo and redo return the label of the edit they acted on.src-tauri/tests/common/mcp.rs): it starts the server in-process on an ephemeral port over anApiImplwith a temp config dir, pointed atfake-comfy, and connects a realrmcpclient. Later slices reuse it.Tests
src-tauri/tests/mcp_server.rscovers each acceptance criterion: token and origin refusal, the instructions, "no Project open" thenget_project, anApiImpledit undone over MCP that reverts and emits a change, the excluded commands missing fromtools/list, and the server being off by default, then restarting on a port change, a token regeneration or a switch-off. It also covers serving at start and reporting a port that is in use.crates/studio-core/tests/mcp_settings.rscovers the settings file.I mutation-checked the auth and origin checks: disabling either one fails the test. The full Rust suite and
svelte-checkpass.Notes for review
ApiImpl→McpServer→ listener →ApiImplis a reference cycle while the server is on. That is harmless in the app, which lives for the whole process.