mcp-context-forge
mcp-context-forge copied to clipboard
[BUG]: ImportError no pq wrapper available in Containerfile.lite
🐞 Bug Summary
psycopg fails to import in the Containerfile.lite runtime image on s390x architecture because libpq.so.5 is not found, despite libpq package being installed in the runtime stage.
Error message:
File "/app/.venv/lib64/python3.12/site-packages/psycopg/pq/__init__.py", line 108, in import_from_libpq
raise ImportError(f"""\
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: libpq.so.5: cannot open shared object file: No such file or directory
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found
🧩 Affected Component
Select the area of the project impacted:
- [ ]
mcpgateway- API - [ ]
mcpgateway- UI (admin panel) - [ ]
mcpgateway.wrapper- stdio wrapper - [ ] Federation or Transports
- [ ] CLI, Makefiles, or shell scripts
- [x] Container setup (Docker/Podman/Compose)
- [ ] Other (explain below)
🔁 Steps to Reproduce
- Build Containerfile.lite on an
s390xhost (or using QEMU emulation):docker build -f Containerfile.lite -t mcpgateway-lite . - Run the container:
docker run mcpgateway-lite - Observe the crash during startup when initializing the database extension.
🤔 Expected Behavior
The application should start successfully, and psycopg should be able to load the libpq library.
📓 Logs / Error Output
File "/app/.venv/lib64/python3.12/site-packages/psycopg/pq/__init__.py", line 108, in import_from_libpq
raise ImportError(f"""\
ImportError: no pq wrapper available.
Attempts made:
- couldn't import psycopg 'c' implementation: libpq.so.5: cannot open shared object file: No such file or directory
- couldn't import psycopg 'binary' implementation: No module named 'psycopg_binary'
- couldn't import psycopg 'python' implementation: libpq library not found
🧠 Environment Info
| Key | Value |
|---|---|
| Version or commit | main |
| Runtime | Python 3.12 |
| Platform / OS | s390x / RHEL/UBI 10 |
| Container | Docker / Podman |
🧩 Additional Context (optional)
On s390x, psycopg-binary wheels are often unavailable, so we build psycopg[c] from source. This requires libpq to be present at runtime. While libpq is installed via microdnf, it seems it's either not providing libpq.so.5 or it's not in the environment's library search path. Adding postgresql-libs or ensuring libpq is correctly linked may resolve this.