Conversation
the-lab-agent and `the-lab init` both launch the bridge with a bare `python3` from PATH, not the interpreter the-lab is installed in. On macOS that is /usr/bin/python3 3.9.6. The `list[str] | None` annotations on the watch helpers are evaluated at import time there and raise TypeError, so the bridge exits before `initialize` and the agent runs with no labapi tools. `from __future__ import annotations` postpones annotation evaluation. The bridge has no other 3.10-only syntax, so it imports and serves tools on 3.9. Verified against a running `the-lab .`: initialize + tools/list under /usr/bin/python3 3.9.6 exited 1 with the TypeError before the change, and returns 39 tools after it; 3.12 and 3.14 unchanged (39 tools). Assisted-by: Claude Code / claude-opus-5 Machine: MacBook-Anton Account: tonydzi Operator: anton Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A subprocess test that speaks JSON-RPC to lab_api_mcp.py the way a client does (initialize, tools/list) against a local HTTP server serving the real app's OpenAPI spec. No network, no account. It asserts spec-derived tools (orient, create_idea, ...) are listed, so it fails both when the bridge cannot start and when its INCLUDE table drifts from the API. LAB_MCP_PYTHON picks the interpreter that runs the bridge. CI gets an mcp-bridge job with bridge Python 3.9 and 3.12. Red/green on macOS with the bridge under /usr/bin/python3 3.9.6: with the previous commit reverted the test fails with the TypeError from `list[str] | None`; with it, OK. Assisted-by: Claude Code / claude-opus-5 Machine: MacBook-Anton Account: dzyatkovskiy.a@gmail.com Operator: anton Co-Authored-By: Claude Opus 5 <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.
Problem
I set up the_lab.api on a Mac and the agent had no
labapitools.the-lab-agent(and the.mcp.jsonthatthe-lab initwrites) starts the MCP bridge with a barepython3from PATH, not with the Python that the-lab is installed in. On macOS that is/usr/bin/python3, which is 3.9.6.The bridge has
list[str] | Nonein two function signatures (_events_longpoll,_watch). Python 3.9 evaluates these when it imports the file and fails:The bridge exits before
initialize, so the agent starts without any tools and nothing tells you why.Fix
Add
from __future__ import annotationsat the top of the bridge. Annotations are no longer evaluated at import time. I checked the rest of the file: there is no other 3.10-only syntax, so this one line is enough and the bridge stays "zero dependencies, any python3".How I tested
I ran
the-lab .on a scratch repo and sentinitialize+notifications/initialized+tools/listto the bridge over stdio with different interpreters:/usr/bin/python33.9.6 (macOS system)Another option would be to launch the bridge with
sys.executableinagent_cli.py. I did not do that because the.mcp.jsonwritten byinitwould still saypython3, and the one-line change fixes both paths.Regression test
A second commit adds
tests/test_mcp_bridge.pyso this does not come back quietly. It starts the bridge as a subprocess, sendsinitialize+tools/listover stdio and checks that spec-derived tools (orient,create_idea,list_ideas,get_instructions) are listed. The spec comes from the real app (app.openapi()), served by a localhttp.server, so there is no network and no account.LAB_MCP_PYTHONpicks the interpreter that runs the bridge.Red/green with the bridge under
/usr/bin/python33.9.6:FAIL ... AssertionError: 1 != 0 ... TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'NoneType'Ran 1 test ... OKci.ymlgets anmcp-bridgejob that runs it with bridge Python 3.9 and 3.12. There was no test suite yet, so I used stdlibunittest(python -m unittest tests.test_mcp_bridge) rather than add pytest. Happy to move it if you prefer another layout.— Anton Dziatkovskii · github.com/tonydzi