Files
herolib/lib/ai/mcp/vcode/logic/vlang_tools.v
Mahmoud-Emad 6f6224f21b refactor: Rename module and import path
- Rename module from `codetools` to `code`
- Update import path from `incubaid.herolib.develop.codetools` to `incubaid.herolib.core.code`
2025-10-12 17:31:46 +03:00

40 lines
1.2 KiB
V

module vcode
import incubaid.herolib.ai.mcp
import incubaid.herolib.core.code
import incubaid.herolib.schemas.jsonschema
import x.json2 { Any }
const get_function_from_file_tool = mcp.Tool{
name: 'get_function_from_file'
description: 'get_function_from_file parses a V file and extracts a specific function block including its comments
ARGS:
file_path string - path to the V file
function_name string - name of the function to extract
RETURNS: string - the function block including comments, or empty string if not found'
input_schema: jsonschema.Schema{
typ: 'object'
properties: {
'file_path': jsonschema.SchemaRef(jsonschema.Schema{
typ: 'string'
})
'function_name': jsonschema.SchemaRef(jsonschema.Schema{
typ: 'string'
})
}
required: ['file_path', 'function_name']
}
}
pub fn (d &VCode) get_function_from_file_tool_handler(arguments map[string]Any) !mcp.ToolCallResult {
file_path := arguments['file_path'].str()
function_name := arguments['function_name'].str()
result := code.get_function_from_file(file_path, function_name) or {
return mcp.error_tool_call_result(err)
}
return mcp.ToolCallResult{
is_error: false
content: mcp.result_to_mcp_tool_contents[string](result.vgen())
}
}