-
Notifications
You must be signed in to change notification settings - Fork 83
Add command-executor MCP server with user confirmation flow #1846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Introduces a new MCP (Model Context Protocol) server that enables Claude Code to execute TypeAgent commands for music playback, list management, calendar operations, and other natural language tasks. Key features: - Connects Claude Code to TypeAgent dispatcher via WebSocket - Automatic reconnection with 5-second retry interval - Comprehensive logging to temp files for debugging - Supports natural language commands (e.g., "play bohemian rhapsody", "add milk to grocery list") - Clean output formatting with HTML image tags stripped Includes example configuration for .mcp.json and detailed installation instructions in README. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add trademark section to README - Remove dist-test build outputs from git - Fix package.json field ordering (use exports instead of main) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Use exact trademark text format with proper line breaks - Sort package.json scripts alphabetically Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit enhances the split editor command in the Coda extension to support more flexible editor selection and improves TypeAgent schema disambiguation. **Bug Fixes:** - Fix off-by-one error when selecting "first" or "last" editor by sorting by viewColumn - Fix multiple split issue by adding conditionals to focus changes - Remove unnecessary focus restoration logic for voice command scenarios **Features:** - Add support for splitting editors by position: "first", "last", "active", or numeric index - Add support for splitting editors by file name: "split app.tsx to the right" - Search all open tabs using tabGroups API, not just visible editors - Automatically open and focus files found in background tabs before splitting **Schema Improvements:** - Add clear disambiguation between splitEditor and moveCursorInFile actions - Add "USE THIS for" and "DO NOT USE for" guidance in schema comments - Add concrete examples to help LLM choose correct action - Remove moveCursorInFile reference from main code schema (not useful for voice) **Documentation:** - Add VSCODE_CAPABILITIES.md documenting all VSCode automation features - Update split editor examples to show new position and file-based splitting Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This enhancement allows the player agent to create playlists with songs specified by title and artist, and to add lists of songs to existing playlists, eliminating the need to search and build a track list first. Changes: - Add SongSpecification interface for specifying songs by track name, optional artist, and optional album - Extend CreatePlaylistAction with optional songs parameter to support creating playlists with songs in one action - Add new AddSongsToPlaylistAction for bulk adding songs to existing playlists - Implement searchSongsAndGetUris helper function to search Spotify for songs and collect their URIs - Update createPlaylist handler to search for and add songs when creating playlists - Add addSongsToPlaylist handler for the new action - Add validation support for the new action in playerHandlers Benefits: - Users can create playlists with songs in a single request - Supports requests like "create a playlist with the top 10 songs" - Provides feedback on songs that couldn't be found - Maintains backward compatibility with existing createPlaylist usage Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This package provides a pseudo terminal wrapper for CLI coding assistants like Claude Code, with support for transparent I/O passthrough and future caching capabilities. Features: - PTY wrapper using node-pty for proper terminal emulation - Transparent passthrough of all stdin/stdout/stderr - Support for multiple CLI assistants (Claude Code, Node REPL, Python, etc.) - Windows compatibility with automatic .exe handling - Graceful exit handling (Ctrl+C, SIGTERM) - Terminal features: colors, cursor control, resizing - Configurable assistant system for extensibility Architecture: - assistantConfig.ts: Pluggable configuration for different assistants - ptyWrapper.ts: Core PTY wrapper with node-pty - cli.ts: Command-line interface entry point - index.ts: Public API exports Usage: coder-wrapper # Use Claude Code (default) coder-wrapper -a node # Use Node REPL coder-wrapper -a python # Use Python REPL Future enhancements: - Cache checking with TypeAgent dispatcher before forwarding requests - Request/response logging and performance metrics - Cache hit/miss statistics Testing requires a real terminal (TTY) - see TESTING.md for manual test procedures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit adds optional caching functionality to the coderWrapper package, allowing it to check TypeAgent's cache before forwarding commands to the wrapped CLI agent. Key changes: **coderWrapper package:** - Add cacheClient.ts: MCP client for checking TypeAgent cache via command-executor - Add debugLogger.ts: Debug logging to ~/.tmp/typeagent-coder-wrapper/ - Update ptyWrapper.ts: - Add cache checking before forwarding commands to wrapped agent - Handle \r\n separately to prevent duplicate command execution on Windows - Add processing lock to prevent concurrent command handling - Add enableCache option (default: false) - Add debug option for detailed logging - Update CLI to support --enable-cache and --debug flags **commandExecutor MCP server:** - Add startup connection race handling (return cache miss instead of error) - Add CACHE_HIT prefix for detection by cacheClient - Improve error handling for disconnected dispatcher **dispatcher:** - Add checkCache RPC method to dispatcher interface - Implement checkCache in dispatcher client and server - Support multi-client cache sharing via AsyncLocalStorage routing **agentServer:** - Add AsyncLocalStorage-based request routing for multi-client support - Wrap checkCache calls with client context to route responses correctly - Each client gets isolated cache results despite shared dispatcher The cache is disabled by default and must be explicitly enabled with enableCache: true or --enable-cache flag. When enabled and cache hits occur, results are returned immediately without invoking the wrapped CLI agent. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…mcp-server # Conflicts: # ts/packages/coderWrapper/README.md # ts/packages/coderWrapper/package.json # ts/packages/coderWrapper/src/cli.ts # ts/packages/coderWrapper/src/index.ts # ts/packages/coderWrapper/src/ptyWrapper.ts # ts/pnpm-lock.yaml
This commit introduces a new agentSdkWrapper package that provides direct integration with the Anthropic Agent SDK, offering an alternative to the PTY-based coderWrapper approach with enhanced caching capabilities. New Package: agentSdkWrapper - Direct API integration using Agent SDK's query() function - Programmatic control over request/response cycle - Intelligent caching through TypeAgent's cache infrastructure - Cache context injection via UserPromptSubmit hooks - Extended thinking/reasoning display support - MCP server integration for music, lists, calendar, and VSCode automation - Configurable model selection (Sonnet/Opus) and tool restrictions - Debug mode with detailed timing and logging Key Features: - Cache-first architecture: checks TypeAgent cache before API calls - Context injection: follow-up questions can reference cached interactions - Streaming support: displays responses and reasoning in real-time - Session continuity: maintains conversation context across queries - MCP command-executor integration with acceptEdits permission mode Improvements to Existing Packages: - commandExecutor: Added lifecycle documentation explaining transient/persistent connection patterns, HTML-to-plaintext conversion for cache results - agentServer: Enhanced error handling for disconnected clients, maintains connection logging for debugging Architecture Notes: - Agent SDK spawns new Claude Code process per query (transient connections) - Each process spawns fresh MCP server instance connecting to shared dispatcher - agentServer maintains single persistent dispatcher across all connections - Connection/disconnection messages retained for debugging purposes Benefits over PTY wrapper: - Better performance (no process spawning/PTY overhead) - More control over API calls and tool configuration - Easier testing (pure TypeScript functions) - Cleaner code (no terminal escape codes) - Programmatic access for TypeScript integration Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Resolved conflicts in: - packages/agentServer/server/src/server.ts: Kept our error handling for disconnected clients - pnpm-lock.yaml: Accepted theirs and regenerated
Replaced regex-based HTML sanitization with html-to-text library to address: 1. Incomplete multi-character sanitization (High severity) 2. Double escaping/unescaping vulnerability (High severity) Changes: - Removed manual regex chains for HTML tag stripping - Removed unsafe entity decoding sequence - Added html-to-text library with proper HTML parsing - Configured to skip images and preserve formatting - Added @types/html-to-text for TypeScript support This eliminates injection risks from incomplete tag removal and prevents double-decoding vulnerabilities. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix build failures by properly declaring html-to-text dependencies: - Added html-to-text ^9.0.5 to dependencies - Added @types/html-to-text ^9.0.4 to devDependencies - Updated pnpm-lock.yaml to match package.json This resolves the ERR_PNPM_OUTDATED_LOCKFILE errors in CI builds. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented a two-phase confirmation flow to handle TypeAgent's askYesNo prompts in the MCP server context. Since MCP tools are request-response based and cannot pause for user input, the flow works as follows: 1. When a command requires confirmation, askYesNo() throws a USER_CONFIRMATION_REQUIRED error instead of blocking 2. The MCP server catches this error and returns a user-friendly message 3. Claude uses AskUserQuestion to confirm with the user 4. If approved, Claude retries the command with confirmed=true parameter 5. On retry, askYesNo() sees the confirmed flag and returns true immediately Changes: - Added optional 'confirmed' parameter to ExecuteCommandRequest schema - Added currentRequestConfirmed state tracking to CommandServer - Modified askYesNo() to check confirmation flag and throw error if not confirmed - Updated executeCommand() to handle USER_CONFIRMATION_REQUIRED errors - Enhanced tool description to document the confirmation flow - Added proper cleanup in finally block to reset confirmation state This implementation is stateless and works across MCP server restarts, providing a clean API for handling destructive operations safely. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Summary
This PR adds a Model Context Protocol (MCP) server that integrates TypeAgent's command execution capabilities with Claude Code via the Agent SDK. It enables Claude to execute user commands (music, lists, calendar, VSCode automation) through TypeAgent's dispatcher, with proper user confirmation for destructive operations.
Key Features
1. Command Executor MCP Server
packages/commandExecutorproviding MCP server for TypeAgent integrationexecute_commandtool to Claude2. Agent SDK Wrapper
packages/agentSdkWrapperwrapping Anthropic's Agent SDKclaude_codepreset for consistent behavior3. User Confirmation Flow
USER_CONFIRMATION_REQUIREDerrorAskUserQuestionconfirmed=trueparameter4. HTML Image Processing
html-to-textfor safe HTML parsingTest Plan
Files Changed
New Packages
packages/commandExecutor/- MCP server implementationpackages/agentSdkWrapper/- Agent SDK wrapper with TypeAgent integrationKey Files
packages/commandExecutor/src/commandServer.ts- MCP server with confirmation flowpackages/agentSdkWrapper/src/cli.ts- Agent SDK configurationpackages/commandExecutor/README.md- Setup and usage documentationpackages/agentSdkWrapper/README.md- Integration guideRelated Issues
🤖 Generated with Claude Code