MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / build_submodule_tool

Function build_submodule_tool

src/harness/submodules/loader.py:126–156  ·  view source on GitHub ↗

Build a tool definition from a submodule function spec.

(spec: SubmoduleFunctionSpec)

Source from the content-addressed store, hash-verified

124
125
126def build_submodule_tool(spec: SubmoduleFunctionSpec) -> Dict[str, Any]:
127 """Build a tool definition from a submodule function spec."""
128 properties = {}
129 required = []
130 for p in spec.model_params:
131 if not p.name:
132 raise ValueError(
133 f"Submodule {spec.module_path} has a parameter without a name"
134 )
135 if p.schema and isinstance(p.schema, dict):
136 properties[p.name] = p.schema
137 else:
138 properties[p.name] = {
139 "type": p.param_type or "string",
140 "description": p.description or "",
141 }
142 if p.required:
143 required.append(p.name)
144
145 return {
146 "type": "function",
147 "function": {
148 "name": spec.name,
149 "description": spec.description or "",
150 "parameters": {
151 "type": "object",
152 "properties": properties,
153 "required": required,
154 },
155 },
156 }
157
158
159def load_submodule_tools_for_yaml(

Callers 4

test_basic_toolMethod · 0.90
test_tool_with_paramsMethod · 0.90
test_tool_with_schemaMethod · 0.90

Calls

no outgoing calls

Tested by 3

test_basic_toolMethod · 0.72
test_tool_with_paramsMethod · 0.72
test_tool_with_schemaMethod · 0.72