fix: resolve FastAPI/MCP dependency conflict (anyio version incompatibility)#5
Open
vicmuchina wants to merge 8 commits intocaiovicentino:mainfrom
Open
Conversation
CRITICAL FIX: Market discovery tools were returning historical data (2020-2021) instead of current data (2024-2027). Problem: - Gamma API was missing the closed=false parameter - Without it, API returns ALL markets including closed/historical ones Solution: Add closed=false parameter to all market discovery Gamma API calls: - search_markets() - get_trending_markets() - filter_markets_by_category() - get_closing_soon_markets() - get_sports_markets() - get_crypto_markets() Additional fixes: - Fixed timezone comparison in get_closing_soon_markets() - Fixed event_markets to handle different response formats Test Results: Without closed=false: Returns markets from 2020-2021 (historical) With closed=false: Returns markets from 2024-2027 (current) Verification: python3 test_gamma_closed_parameter.py Impact: - Minimal change: Only adds closed=false to API parameters - Maintains original architecture - Gamma API is NOT deprecated - No breaking changes - All 8 market discovery tools now return current data
This test confirms the fix is working: - Without closed=false: Returns historical data (2020-2021) - With closed=false: Returns current data (2024-2027) All 8 market discovery tools now return current market data.
Fixes: 1. Pin pydantic to 2.9.2 (compatible with mcp 1.20+) 2. Update mcp to >=1.20.0 3. Add typing-extensions dependency 4. Update pydantic-settings to >=2.3.0 5. Create run-polymarket-mcp.sh startup script Root cause: - pydantic 2.11.7 changed internal structure, AnyUrl not in main namespace - mcp 1.11.0 requires specific pydantic version - typing-extensions system version conflicts with pydantic 2.11+ This fixes the ImportError and provides proper startup script.
This document provides: - Summary of the fix - Code changes made - Test results - Dependencies information - How to run the server - Architecture overview
…bility) Fixes critical installation failure caused by incompatible anyio version requirements between fastapi and MCP packages. ## Problem Package installation failed with: ``` ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts - fastapi 0.104.0 depends on anyio<4.0.0 and >=3.7.1 - mcp 1.25.0 depends on anyio>=4.5 ``` These two dependencies have incompatible anyio version requirements, making the package impossible to install. ## Solution Updated pyproject.toml dependencies to resolve the conflict: - fastapi: >=0.104.0 → >=0.109.0 (compatible with anyio>=4.5) - pydantic: >=2.9.0,<2.10.0 → >=2.9.0 (removed upper bound) FastAPI 0.109+ dropped the anyio<4.0.0 constraint and is compatible with anyio>=4.5, satisfying MCP's requirements. ## Tested ✓ Clean virtual environment installation successful ✓ Package imports correctly: `import polymarket_mcp` ✓ All dependencies resolve without conflicts Breaking change: None - only updated minimum version requirements
- Add COMPLETE_INSTALLATION_GUIDE.md with all issues and solutions - Add run_with_env.sh helper script for proper PYTHONPATH management - Add run_opencode_mcp.py for OpenCode integration - Add test_server_init.py for server initialization testing - Add INSTALLATION_COMPLETE.md for quick reference - Document typing_extensions compatibility issues and solutions - Document Python version requirements (3.12.3) - Document OpenCode integration steps - Provide troubleshooting guide
…shooting - Add critical installation issues and solutions section - Document typing_extensions system package conflict - Document Python path priority issues - Document OpenCode integration steps - Add complete 7-step installation procedure - Add quick start commands - Add critical points to avoid common issues - Add troubleshooting section - Add best practices - Link to comprehensive installation guide
- Add install-fixed-version.sh for pinned dependency installation - Add install-with-conda.sh for Conda environment setup - Add install-with-micromamba.sh for Micromamba environment setup - Add run-mcp-isolated.sh for isolated MCP server execution - Add run-polymarket-mcp-isolated.sh for isolated Polymarket MCP execution - Add run_isolated_mcp.py for Python-based isolated MCP runner - Simplify run-polymarket-mcp.sh to use exec for proper signal handling - Add comprehensive solution documentation (FINAL_SOLUTION.md, etc.) - Add ISSUES_FIXED.md documenting resolved installation issues - Update .gitignore to exclude environment directories (.micromamba-env/, .final-env/)
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.
This PR has been updated with comprehensive installation and OpenCode integration fixes.
New Additions
Files Added
run_with_env.sh- Helper script for proper environment setuprun_opencode_mcp.py- Isolated MCP server runner for OpenCodetest_server_init.py- Server initialization test scriptCOMPLETE_INSTALLATION_GUIDE.md- Comprehensive installation guide with all issues and solutionsINSTALLATION_COMPLETE.md- Quick reference guideIssues Resolved
Key Points
run_with_env.shSee
COMPLETE_INSTALLATION_GUIDE.mdfor detailed installation instructions and troubleshooting.