Skip to content

feat(mcp): add mcp support for emdash#2938

Draft
kchung wants to merge 4 commits into
generalaction:mainfrom
kchung:chung/feat-mcp
Draft

feat(mcp): add mcp support for emdash#2938
kchung wants to merge 4 commits into
generalaction:mainfrom
kchung:chung/feat-mcp

Conversation

@kchung

@kchung kchung commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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.

Tool Params Description
list_projects none List open projects
list_tasks projectId List tasks in a project with status
create_task projectId, prompt, name?, provider?, model?, branchName?, baseBranch?, chatUi? Create a task in an isolated worktree and start an agent on the prompt
rename_task projectId, taskId, name Rename a task
archive_task projectId, taskId Archive a task
delete_task projectId, taskId, confirm? Delete a task; requires confirm: true when the worktree has uncommitted changes

Also includes a fix for the delete preflight, which reported dirty worktrees as clean; the delete_task confirmation 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 format clean
  • pnpm 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 fix
  • Manual: registered against Claude Code, exercised all six tools end to end, verified 401 without token, the dirty-worktree confirm flow, and that the catalog card disappears when a second instance owns the port

Screenshot/Recording (if applicable)

Screenshot 2026-07-21 at 4 44 24 PM
mcp.mp4

kchung and others added 3 commits July 21, 2026 16:06
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>
@kchung

kchung commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a local MCP server that lets managed agents create and manage Emdash tasks. The main changes are:

  • Token-protected MCP access through a localhost HTTP listener.
  • Tools for listing projects and creating, renaming, archiving, and deleting tasks.
  • Managed MCP registration and catalog integration for supported agents.
  • Task creation with provider, model, branch, and chat options.
  • Correct dirty-worktree detection for task deletion.

Confidence Score: 5/5

No additional blocking issue qualifies for this follow-up review.

  • The latest ownership fix was reviewed against the previously reported controller behavior.
  • No new distinct production failure remains to report in this round.

Important Files Changed

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

Comment thread apps/emdash-desktop/src/main/core/mcp/controller.ts
Comment thread apps/emdash-desktop/src/main/core/mcp/server/register-tools.ts
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>
@kchung

kchung commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@greptile review

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.

[feat]: Add MCP support for emdash

1 participant