Repository navigation
fix: pairing token in JSON body, and serialize concurrent Revit bridge calls - #90
Open
richard1seg1nz wants to merge 2 commits into
Open
richard1seg1nz wants to merge 2 commits into
richard1seg1nz wants to merge 2 commits into
Conversation
…ders pyRevit Routes (6.x and 7.0) builds each route Request without copying the HTTP headers, so the Authorization bearer never reached authorize_request and every bridge call returned 401 after pairing. - Client sends the token both as Authorization and in a revit_mcp_auth field of an application/json body (GET included). A header, when pyRevit exposes one, stays authoritative; otherwise the body field is checked in constant time. Routes pop the field before the payload is used or shown for review. - Reference both System.Security and System.Security.Cryptography.ProtectedData so DPAPI loads on .NET Framework Revit (2024 and older). - Catch EnvironmentError in get_token so IronPython's IOError on a missing pairing file yields 401 instead of an uncaught error reported as 408. Verified live on Revit 2025.4 / pyRevit 7.0.1: header-only 401, body token 200, wrong or missing token 401, model_info 200. Fixes mcp-servers-for-revit#71, mcp-servers-for-revit#84, mcp-servers-for-revit#85, mcp-servers-for-revit#78, mcp-servers-for-revit#75, mcp-servers-for-revit#88, mcp-servers-for-revit#70. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…onses pyRevit Routes dispatches every request through one shared ExternalEvent handler, so overlapping requests overwrite each other and both callers get the same response (e.g. get_revit_status returning current view info). Hold a single asyncio lock around each bridge call, including image export. 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.
Summary
ExternalEventhandler (REQUEST_HNDLRinpyrevit/routes/server/server.py). When two requests overlap, the second overwrites the first's handler, so both callers get the same response. For example,get_revit_statusrun in parallel withget_current_view_inforeturned the view info.main.pynow holds oneasyncio.Lockaround each bridge call, including image export.Testing
test_concurrent_revit_calls_do_not_share_responsesfakes the shared-handler behaviour. It fails without the fix and passes with it.Known limitation
If a request times out on the client while Revit is still running it, the lock is released and the next request can still collide. Fixing that fully means changing pyRevit Routes.
🤖 Generated with Claude Code