Enable uvx GitHub repository usage with automatic Pyodide setup#10
Merged
Conversation
…tiple npm strategies Critical fix for the error: "Cannot find module 'pyodide.asm.js' imported from pyodide.js" Problem resolved: - Original download only fetched pyodide.js but Pyodide requires multiple files (pyodide.asm.js, pyodide.asm.wasm, python_stdlib.zip) - Limited npm installation strategy only worked with existing package.json Solution implemented: - Enhanced npm installation with dual strategy approach: 1. Install in project root (if package.json exists) 2. Install in temporary directory (fallback for uvx scenarios) - Complete Pyodide package download including all essential files: - pyodide.js (main JavaScript file) - pyodide.asm.js (WebAssembly JavaScript glue) - pyodide.asm.wasm (WebAssembly binary) - python_stdlib.zip (Python standard library) - pyodide_py.tar (Python packages) - Improved path detection to include temporary npm installations - Robust file verification before returning success Technical improvements: - _auto_install_pyodide(): Multi-strategy npm installation - _npm_install_in_project_root(): Original project-based installation - _npm_install_global_temp(): New temporary directory installation for uvx - _find_npm_pyodide(): Enhanced path search including temp directories - _download_pyodide(): Complete package download with file verification Testing verified: - ✅ Pyodide initialization: All essential files present - ✅ PuLP integration: Import and problem setup successful - ✅ File generation: LP format output working correctly - ✅ Library detection: Correctly identifies MIP libraries This fix enables reliable uvx usage: uvx --from=github.com/user/mip-mcp.git mip-mcp 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
🚀 Major enhancement: Enable seamless
uvx --from=https://github.com/...usage with automatic Pyodide setup and zero manual configuration required.Problem Solved
Previously, users trying to run:
Would encounter Pyodide dependency issues requiring manual
npm installor complex setup.Critical Issue Fixed:
"Cannot find module 'pyodide.asm.js' imported from pyodide.js"Solution Implemented
🔧 PyodideManager: Centralized Installation System
⚡ Server Startup Integration
✓ Pyodide setup ready - auto-install from /path🛡️ Robust Fallback Chain
pyodide.js(main JavaScript file)pyodide.asm.js(WebAssembly JavaScript glue)pyodide.asm.wasm(WebAssembly binary)python_stdlib.zip(Python standard library)pyodide_py.tar(Python packages)Key Features
🎯 Zero User Friction
📦 Smart Dependency Management
🔍 Enhanced User Experience
Technical Implementation
Files Added/Modified
src/mip_mcp/utils/pyodide_manager.py✨ New centralized Pyodide management (301 lines)src/mip_mcp/server.py: Add startup Pyodide checking with_check_pyodide_sync()src/mip_mcp/mcp_server.py: Useserver.run()for proper initialization flowsrc/mip_mcp/executor/pyodide_executor.py: Integrate PyodideManager for path resolutionpyproject.toml: Addaiohttp>=3.8.0for download functionalityREADME.md: Document uvx GitHub usage with automatic setupArchitecture Benefits
Testing Verified ✅
Startup Behavior
Installation Scenarios
Code Quality
Integration Testing
Impact
Before
After
Breaking Changes
Future Extensibility
This enhancement transforms MIP-MCP into a truly plug-and-play optimization library that works seamlessly with modern Python tooling like
uvx. Users can now focus on their optimization problems instead of dependency management! 🚀Related Issues
🤖 Generated with Claude Code