Repository navigation
Conversation
pyRevit 7.0.0 builds each routes Request without copying the incoming HTTP headers, so request.headers is always empty. The pairing check never sees the Authorization header and every bridge request is rejected with 401, even after a successful Connect. Wrap the routes handler's _prepare_request to copy the HTTP headers onto the request when pyRevit left them empty. pyRevit stops its server at session start and starts a new one only after extension startup scripts run, possibly in another script engine, so the handler class is patched at load and again through the live server on Revit's first Idling event. Token validation is unchanged; Origin headers now reach the existing browser check. Co-Authored-By: Claude Opus 5.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
On pyRevit 7.0.0 every bridge request is rejected with
401 Bridge is disconnected or pairing is invalid., even right after a successful MCP > Bridge > Connect.pyRevit 7.0.0's
HttpRequestHandler._prepare_request(pyrevit/routes/server/server.py) buildsbase.Requestwithout copying the incoming HTTP headers, sorequest.headersis always{}.revit_mcp.pairing.validate_requestnever sees theAuthorizationheader, so pairing can never succeed.Fix
revit_mcp/header_passthrough.pywraps the routes handler's_prepare_requestand copies the HTTP headers onto the request only when pyRevit left them empty, so pyRevit builds that already pass headers are unaffected.get_active_server().server.RequestHandlerClass) on Revit's firstIdlingevent.startup.pyinstalls it after route registration; any failure is logged and never blocks route registration.Originheaders now actually reach the existing browser-request rejection invalidate_request.Testing
tests/unit/test_header_passthrough.py(6 tests): headers copied when dropped, left alone when provided, idempotent patching, valid / browser-Origin/ missing-token requests throughvalidate_request, and patching the live server with or without one running. Full unit suite: 112 passed./status/returned 401; after, it returnsstatus: active, health: healthy.Note for reviewers
After a pyRevit Reload, pyRevit 7 can leave the previous routes server listening on the same port (
allow_reuse_address), and Windows may keep routing connections to that old, unpatched server. A full Revit restart clears it. This is a pyRevit issue, outside this extension, but it can look like this fix didn't work.🤖 Generated with Claude Code