Skip to content

feat: add MCP server support for external AI tools#101

Open
4regab wants to merge 5 commits into
mainfrom
feat/mcp-support
Open

feat: add MCP server support for external AI tools#101
4regab wants to merge 5 commits into
mainfrom
feat/mcp-support

Conversation

@4regab

@4regab 4regab commented May 14, 2026

Copy link
Copy Markdown
Owner

This pull request was generated by @kiro-agent 👻

Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent


Summary

Closes #100

Adds Model Context Protocol (MCP) support to the TaskSync VS Code extension, enabling it to work with AI tools beyond GitHub Copilot (Claude Desktop, Cursor, Windsurf, etc.).

Architecture

The MCP server is a standalone spawnable Node.js script (dist/mcp-server.js) that:

  1. External AI tools launch it via stdio as an MCP server
  2. Communicates with the AI tool using the MCP protocol (stdin/stdout)
  3. Connects back to the VS Code extension's WebSocket remote server to relay ask_user requests
  4. Returns user responses to the AI tool in MCP format

Changes

  • src/mcp/mcpServer.ts - Standalone MCP server with ask_user tool, WebSocket relay, PIN authentication, fail-fast error handling
  • src/mcp/mcpServer.test.ts - 12 unit tests covering tool handler, auth flows, error paths, CLI arg parsing
  • src/server/remoteServer.ts - Added mcpAskUser WebSocket message handler with disconnect safety guards
  • src/extension.ts - Added tasksync.copyMcpConfig command for easy config copy to clipboard
  • esbuild.js - Second build entry for dist/mcp-server.js standalone bundle
  • package.json - Added @modelcontextprotocol/sdk, zod dependencies; copyMcpConfig command registration

How It Works

  1. User starts Remote Access in VS Code
  2. User copies MCP config (Command Palette > TaskSync: Copy MCP Configuration)
  3. User pastes config into their AI tool's MCP settings
  4. AI tool spawns node dist/mcp-server.js --port=3580 --pin=XXXX
  5. When AI calls ask_user, the script relays to VS Code via WebSocket
  6. User responds in TaskSync sidebar, response flows back to the AI tool

Testing

  • All 621 tests pass (31 test files)
  • Build, TypeScript type-check, and Biome lint all pass
  • Semantic code review approved after 3 iterations addressing PIN auth, fail-fast behavior, and WebSocket disconnect safety

kiro-agent and others added 5 commits May 14, 2026 17:21
Co-authored-by: James Gabriele <178603515+4regab@users.noreply.github.com>
Co-authored-by: James Gabriele <178603515+4regab@users.noreply.github.com>
Co-authored-by: James Gabriele <178603515+4regab@users.noreply.github.com>
Address review issues:
- Issue 1 (CRITICAL): StdioServerTransport cannot work inside VS Code
  extension host. Converted MCP server to a standalone spawnable script
  (dist/mcp-server.js) that AI tools launch directly. The script uses
  StdioServerTransport for MCP communication and connects back to the
  extension's remote WebSocket server to relay ask_user requests.
- Issue 2: Removed dead mcpServerName and mcpEnabled config settings.
  The standalone script uses internal constants (YAGNI).
- Issue 3: Eliminated per-call EventEmitter leak. The standalone process
  communicates via WebSocket, no longer using askUser() in-process.
- Issue 4: Added try/catch in tool handler returning isError: true with
  structured error JSON on failure.
- Issue 5: Hardcoded version left as-is (YAGNI).

Changes:
- Rewrote src/mcp/mcpServer.ts as standalone entry point with CLI args
  (--port, --pin) and WebSocket bridge to extension
- Removed src/mcp/mcpTypes.ts and src/mcp/index.ts (no longer needed)
- Removed McpServerManager from extension.ts, added copyMcpConfig command
- Added mcpAskUser message handler in remoteServer.ts
- Added second esbuild entry point for dist/mcp-server.js
- Updated package.json: removed mcpEnabled/mcpServerName/toggleMcp,
  added copyMcpConfig command
- Rewrote tests for new standalone WebSocket-based architecture

Co-authored-by: James Gabriele <178603515+4regab@users.noreply.github.com>
- Include --pin in copyMcpConfig when remote server is running
- Show warning if remote server not started when copying MCP config
- Fail fast with clear error when requireAuth arrives without PIN
- Guard ws.send() calls in mcpAskUser handler with readyState check
- Add test for missing PIN fail-fast behavior

Co-authored-by: James Gabriele <178603515+4regab@users.noreply.github.com>
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.

Tasksync Extension MCP Feature

2 participants