fix: preserve wrapped function metadata in register() decorator#3
Open
neox-d wants to merge 1 commit into
Open
fix: preserve wrapped function metadata in register() decorator#3neox-d wants to merge 1 commit into
neox-d wants to merge 1 commit into
Conversation
The register() decorator replaces the user's endpoint function with an inner
wrapper, but doesn't copy over __module__, __name__, etc.
On Frappe v17, frappe.whitelist() unconditionally wraps every function with validate_argument_types, which resolves the app name at decoration time via func.__module__.split(".")[0]. Without @functools.wraps, this resolves to
"frappe_mcp" instead of the user's app, causing Frappe to load frappe_mcp.hooks — which doesn't exist since frappe_mcp is a pip package, not a Frappe app.
Author
|
Hey @18alantom, raised this PR to fix a crash on Frappe v17. Can you look into it? |
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.
The mcp.register() decorator replaces the user's endpoint function with an inner
wrapper, but doesn't copy over module, name, etc.
On Frappe v17, frappe.whitelist() unconditionally wraps every function with validate_argument_types, which resolves the app name at decoration time via func.module.split(".")[0]. Without @functools.wraps, this resolves to
"frappe_mcp" instead of the user's app, causing Frappe to load frappe_mcp.hooks - which doesn't exist since frappe_mcp is a pip package, not a Frappe app.