feat(mcp): add mcp support for emdash#2938
Draft
kchung wants to merge 4 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 local MCP server that lets managed agents create and manage Emdash tasks. The main changes are:
Confidence Score: 5/5No additional blocking issue qualifies for this follow-up review.
|
| Filename | Overview |
|---|---|
| apps/emdash-desktop/src/main/core/mcp/controller.ts | Adds managed-server redaction, live catalog details, and ownership-aware save handling. |
| apps/emdash-desktop/src/main/core/mcp/server/mcp-http-server.ts | Implements the authenticated localhost MCP HTTP listener and request filtering. |
| apps/emdash-desktop/src/main/core/mcp/server/register-tools.ts | Registers project and task-management tools with validation and structured responses. |
| apps/emdash-desktop/src/main/core/mcp/server/create-task-from-prompt.ts | Creates and provisions tasks from MCP prompts, then starts PTY or ACP conversations. |
| apps/emdash-desktop/src/main/core/tasks/operations/getDeletePreflight.ts | Updates deletion preflight handling so dirty worktrees require confirmation. |
Reviews (2): Last reviewed commit: "fix(mcp): keep new custom emdash-named s..." | 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 |
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 (not offended if not merged or accepted): 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 changesAlso 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