MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / get_parameters

Method get_parameters

src/dynamic/server.py:775–842  ·  view source on GitHub ↗

Get the parameters of a function or class from source code. Args: object (Union[Type['T'], Callable]): The function or class to get parameters for

(self, object: Union[Type['T'], Callable])

Source from the content-addressed store, hash-verified

773 return list(self._loaded_modules.keys())
774
775 def get_parameters(self, object: Union[Type['T'], Callable]) -> Dict[str, Any]:
776 """Get the parameters of a function or class from source code.
777
778 Args:
779 object (Union[Type['T'], Callable]): The function or class to get parameters for
780 """
781 try:
782 if isinstance(object, Type):
783 signature = inspect.signature(object.__call__)
784 hints = get_type_hints(object.__call__)
785 docstring = inspect.getdoc(object.__call__) or ""
786 elif isinstance(object, Callable):
787 signature = inspect.signature(object)
788 hints = get_type_hints(object)
789 docstring = inspect.getdoc(object) or ""
790 except Exception as e:
791 raise ValueError(f"Failed to get parameters for {object}: {e}")
792
793 # Get descriptions
794 doc_descriptions = self.parse_docstring_descriptions(docstring)
795
796 properties = {}
797 required = []
798
799 for name, param in signature.parameters.items():
800 if name == "self":
801 continue
802
803 # Skip generic "input" parameter
804 if name == "input" and len(signature.parameters) == 2: # self + input
805 continue
806
807 # Skip VAR_KEYWORD (**kwargs) and VAR_POSITIONAL (*args) parameters
808 if param.kind in (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD):
809 continue
810
811 # Get type annotation
812 annotation = hints.get(name, param.annotation)
813 json_type, python_type = self.annotation_to_types(annotation)
814
815 # Determine if required
816 is_required = param.default is inspect._empty
817
818 # Build schema
819 schema: Dict[str, Any] = {
820 "type": json_type,
821 "description": doc_descriptions.get(name, ""),
822 }
823 schema[PYTHON_TYPE_FIELD] = python_type
824
825 if not is_required:
826 schema["default"] = param.default
827
828 properties[name] = schema
829 if is_required:
830 required.append(name)
831
832 if not properties:

Callers 12

registerMethod · 0.80
updateMethod · 0.80
copyMethod · 0.80
register_agent_classMethod · 0.80
registerMethod · 0.80
updateMethod · 0.80
copyMethod · 0.80
register_tool_classMethod · 0.80
registerMethod · 0.80
updateMethod · 0.80
copyMethod · 0.80

Calls 5

annotation_to_typesMethod · 0.95
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected