feat(mcp): add mcp support for emdash#2938
Draft
kchung wants to merge 6 commits into
Draft
Conversation
The staged/unstaged result computed for a successful git status was unconditionally overwritten on the next line, so every worktree whose status check succeeded was reported clean, and status errors also reported clean. Report the real state on success and fail closed (dirty) when the status is unavailable (error, too-many-files, or a thrown exception) so delete flows err toward preserving the worktree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Serve a Streamable HTTP MCP server from the main process on 127.0.0.1:8212 (EMDASH_MCP_PORT overrides it, EMDASH_MCP_SERVER=false disables it), authenticated with a bearer token generated into userData. Requests must pass loopback Host/Origin checks and the token. Tools: list_projects, list_tasks, create_task (prompt plus optional provider, model, branch name, base branch, and chat UI), rename_task, archive_task, and delete_task, which requires confirm: true when the worktree has uncommitted changes. On boot emdash registers the server in the MCP configs of the agents it manages and heals stale URLs and tokens. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Surface the built-in server as a catalog entry whose live URL is injected by the main process and which is hidden while the server is down. Managed servers get their connection details from the main process on save (only providers are user-editable), bearer headers are redacted from renderer and agent-facing loads, and the add/edit modal renders managed connection fields read-only. Servers merely named "emdash" that point elsewhere are left untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@greptile review |
Contributor
Greptile SummaryThis PR adds a managed local MCP server for emdash agents. The main changes are:
Confidence Score: 5/5The reviewed updates look safe to merge.
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/main/core/mcp/controller.ts | Adds managed-server redaction, live catalog data, and ownership-aware configuration saves. |
| apps/emdash-desktop/src/main/core/mcp/server/mcp-http-server.ts | Adds the authenticated localhost MCP listener, request filtering, token persistence, and lifecycle handling. |
| apps/emdash-desktop/src/main/core/mcp/server/register-tools.ts | Registers MCP tools for project and task management. |
| apps/emdash-desktop/src/main/core/mcp/server/create-task-from-prompt.ts | Adds task creation, branch and model validation, worktree provisioning, and optional agent startup. |
| apps/emdash-desktop/src/main/core/tasks/operations/getDeletePreflight.ts | Corrects dirty-worktree detection used by the task deletion confirmation flow. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
Agent[Managed coding agent] -->|Bearer token| MCP[Local MCP HTTP server]
MCP --> Tools[Task management tools]
Tools --> Projects[Project manager]
Tools --> Tasks[Task service]
Tasks --> Worktree[Isolated worktree]
Renderer[MCP settings UI] --> Controller[MCP controller]
Controller --> Configs[Agent MCP configs]
Controller --> MCP
Reviews (3): Last reviewed commit: "feat(mcp): make create_task prompt optio..." | Re-trigger Greptile
resolveServerForSave only passed through foreign emdash-named servers that were already installed. A brand-new custom server saved under the managed name had its URL and headers replaced with the loopback connection details, or failed to save when the built-in server was down. Apply the same ownership check to the submitted entry: a new save with its own URL is the user's server and is written as-is. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@greptile review |
Add run_task_script and stop_task_script MCP tools so agents can drive a task's setup/run/teardown worktree lifecycle scripts, the same scripts the Scripts panel runs. Both start fire-and-forget and are visible live in the UI; stop_task_script can stop any script type via the shared PTY session. Export isLifecycleScriptSessionActive from the coordinator so run_task_script reports already_running instead of a false started.
Allow create_task without a prompt: the worktree is provisioned and the task created, but no agent conversation is started, leaving the task idle for the user to drive later. Provider/model are only resolved when a prompt is present, and the result reports conversationType 'none' with a null provider/model.
Contributor
Author
|
@greptile review |
|
I have been waiting for this for a long time 🎉 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
POC for MCP support in emdash: a local, token-protected MCP server that lets the agents emdash runs create and manage tasks themselves. Emdash registers the server with the agents it manages, and it shows up in the MCP library as a managed entry.
list_projectslist_tasksprojectIdcreate_taskprojectId,prompt?,name?,provider?,model?,branchName?,baseBranch?,chatUi?rename_taskprojectId,taskId,namearchive_taskprojectId,taskIddelete_taskprojectId,taskId,confirm?confirm: truewhen the worktree has uncommitted changesrun_task_scriptprojectId,taskId,typesetup,run, orteardownworktree lifecycle scriptstop_task_scriptprojectId,taskId,typerun_task_scriptAlso includes a fix for the delete preflight, which reported dirty worktrees as clean; the
delete_taskconfirmation gate depends on it.High risk areas: a new localhost HTTP listener in the main process, writes to agent MCP configs, task deletion tooling, and one new dependency (
@modelcontextprotocol/sdk).Related issues
Resolves #2937
Testing
pnpm run typecheck,pnpm run lint,pnpm run formatcleanpnpm run test: desktop node suite (2113 tests), core (481), including new suites for the HTTP server, tools, self-registration, task creation, controller redaction, and the preflight fixScreenshot/Recording (if applicable)
mcp.mp4