Skip to content

Switch from ATXP proxy to @atxp/client for direct MCP connections#2

Merged
robdimarco-atxp merged 1 commit into
mainfrom
robdimarco/atxp-410-switch-to-using-atxpclient-rather-than-the-proxy-server
Oct 14, 2025
Merged

Switch from ATXP proxy to @atxp/client for direct MCP connections#2
robdimarco-atxp merged 1 commit into
mainfrom
robdimarco/atxp-410-switch-to-using-atxpclient-rather-than-the-proxy-server

Conversation

@robdimarco-atxp
Copy link
Copy Markdown
Contributor

@robdimarco-atxp robdimarco-atxp commented Oct 14, 2025

Summary

This PR implements direct ATXP MCP client connections replacing the proxy-based approach, as specified in Linear issue ATXP-410.

Key Benefits:

  • Direct MCP client connections without proxy overhead
  • Async operation pattern with scheduled task checking
  • Better error handling with user-friendly messages
  • Clearer status feedback for all operations

Changes Made

Core Implementation

  • Added @atxp/client dependency to package.json
  • Created src/tools/atxp-tools.ts (770 lines) with 9 ATXP tools
  • Updated src/server.ts to remove proxy initialization and enhance system prompt
  • Updated src/tools.ts to export new ATXP tools

Tools Implemented

Image Generation:

  • generateImageAsync - Start async image generation, returns task ID
  • getImageGenerationStatus - Check image status with user-friendly messages

Video Generation:

  • generateVideoAsync - Start async video generation, returns task ID
  • getVideoGenerationStatus - Check video status

Browser Automation:

  • browseRunTask - Start browser automation task
  • browseGetTask - Get browser task status and results
  • browseStopTask - Stop a running browser task
  • browseGetTaskScreenshots - Get screenshots from completed task
  • browseGetTaskGif - Get GIF recording from completed task

Technical Improvements

Cloudflare Workers Compatibility:

  • Custom cloudflareWorkersFetch using globalThis.fetch
  • Fetch function passed to both ATXPAccount and atxpClient

MCP Response Handling:

  • parseMCPResult() helper extracts JSON from content[0].text format
  • Proper typing with MCPToolResult interface

Error Handling:

  • All tools return structured error objects instead of throwing
  • User-friendly error messages for all failure cases
  • Console logging for debugging

Status Feedback:

  • Status-specific messages with emojis
  • Clear communication about task IDs and scheduling
  • Informative completion/failure messages

System Prompt Updates:

  • Comprehensive async workflow instructions
  • Examples for image, video, and browse operations
  • Clear guidance on task scheduling and status checking

Testing

  • ✅ TypeScript compilation passes
  • ✅ All linter checks pass
  • ✅ Image generation tested and working
  • ✅ Video generation tested and working
  • ✅ Browse tools tested and working

Related Issues

Closes https://linear.app/circuitandchisel/issue/ATXP-410/switch-to-using-atxpclient-rather-than-the-proxy-server

Test Plan

  • Test image generation with async workflow
  • Test video generation with async workflow
  • Test browse automation with async workflow
  • Verify scheduled task checks work correctly
  • Verify error messages are user-friendly
  • Verify status messages provide clear feedback

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

This PR implements direct ATXP MCP client connections replacing the proxy-based approach, as specified in Linear issue ATXP-410.

## Changes Made

### Core Implementation
- **Added @atxp/client dependency** to package.json
- **Created src/tools/atxp-tools.ts** with 9 ATXP tools for image, video, and browse operations
- **Updated src/server.ts** to remove proxy initialization and update system prompt
- **Updated src/tools.ts** to export new ATXP tools

### Key Features

#### Image Generation Tools
- `generateImageAsync`: Start async image generation, returns task ID
- `getImageGenerationStatus`: Check status with user-friendly completion/failure messages

#### Video Generation Tools
- `generateVideoAsync`: Start async video generation, returns task ID
- `getVideoGenerationStatus`: Check status with timeout parameter for quick checks

#### Web Browsing Tools
- `browseRunTask`: Start browser automation task with natural language instructions
- `browseGetTask`: Get detailed task status, steps, and output
- `browseStopTask`: Stop running tasks
- `browseGetTaskScreenshots`: Retrieve screenshots from completed tasks
- `browseGetTaskGif`: Get GIF recording from completed tasks

### Technical Improvements

#### Cloudflare Workers Compatibility
- Added `cloudflareWorkersFetch` using `globalThis.fetch` for Workers environment
- Pass `fetchFn` to both `ATXPAccount` and `atxpClient` for proper execution context
- Use `oAuthChannelFetch` for OAuth operations

#### MCP Response Handling
- Parse JSON from MCP tool result format: `content[0].text`
- Handle all response types with proper error checking
- Extract correct field names (e.g., `id` for browse tasks, `taskId` for image/video)

#### Error Handling & User Feedback
- All tools return structured objects with `type`, `taskId`, and user-friendly `message`
- Comprehensive try-catch blocks with descriptive error messages
- Status-specific messages (completed ✅, failed ❌, in progress 🔄)
- Clear instructions for next steps in each message

#### System Prompt Updates
- Updated to reflect async workflow with scheduled status checks
- Added examples for image, video, and browse operations
- Includes instructions for informing users about task IDs and status checks
- Documents all tool parameters and return formats

## Testing
- ✅ TypeScript compilation passes
- ✅ All linter checks pass (9 expected warnings for `any` usage)
- ✅ Image generation tested and working
- ✅ Browse tools tested and working with correct field names

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@robdimarco-atxp robdimarco-atxp merged commit 4678ca5 into main Oct 14, 2025
1 check passed
@robdimarco-atxp robdimarco-atxp deleted the robdimarco/atxp-410-switch-to-using-atxpclient-rather-than-the-proxy-server branch October 14, 2025 18:19
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.

1 participant