diff --git a/src/mcp_client.py b/src/mcp_client.py index 5950c16..ffe3353 100644 --- a/src/mcp_client.py +++ b/src/mcp_client.py @@ -296,6 +296,34 @@ def py_get_skeleton(path: str) -> str: except Exception as e: return f"ERROR generating skeleton for '{path}': {e}" +def ts_c_get_skeleton(path: str) -> str: + """Returns a skeleton of a C file.""" + p, err = _resolve_and_check(path) + if err: return err + assert p is not None + if not p.exists(): return f"ERROR: file not found: {path}" + try: + from src.file_cache import ASTParser + code = p.read_text(encoding="utf-8") + parser = ASTParser("c") + return parser.get_skeleton(code, path=str(p)) + except Exception as e: + return f"ERROR generating skeleton for '{path}': {e}" + +def ts_cpp_get_skeleton(path: str) -> str: + """Returns a skeleton of a C++ file.""" + p, err = _resolve_and_check(path) + if err: return err + assert p is not None + if not p.exists(): return f"ERROR: file not found: {path}" + try: + from src.file_cache import ASTParser + code = p.read_text(encoding="utf-8") + parser = ASTParser("cpp") + return parser.get_skeleton(code, path=str(p)) + except Exception as e: + return f"ERROR generating skeleton for '{path}': {e}" + def py_get_code_outline(path: str) -> str: """ Returns a hierarchical outline of a code file (classes, functions, methods with line ranges). @@ -314,6 +342,34 @@ def py_get_code_outline(path: str) -> str: except Exception as e: return f"ERROR generating outline for '{path}': {e}" +def ts_c_get_code_outline(path: str) -> str: + """Returns a hierarchical outline of a C file.""" + p, err = _resolve_and_check(path) + if err: return err + assert p is not None + if not p.exists(): return f"ERROR: file not found: {path}" + try: + from src.file_cache import ASTParser + code = p.read_text(encoding="utf-8") + parser = ASTParser("c") + return parser.get_code_outline(code, path=str(p)) + except Exception as e: + return f"ERROR generating outline for '{path}': {e}" + +def ts_cpp_get_code_outline(path: str) -> str: + """Returns a hierarchical outline of a C++ file.""" + p, err = _resolve_and_check(path) + if err: return err + assert p is not None + if not p.exists(): return f"ERROR: file not found: {path}" + try: + from src.file_cache import ASTParser + code = p.read_text(encoding="utf-8") + parser = ASTParser("cpp") + return parser.get_code_outline(code, path=str(p)) + except Exception as e: + return f"ERROR generating outline for '{path}': {e}" + def get_file_slice(path: str, start_line: int, end_line: int) -> str: """Return a specific line range from a file.""" p, err = _resolve_and_check(path) @@ -1061,8 +1117,16 @@ def dispatch(tool_name: str, tool_input: dict[str, Any]) -> str: return get_file_summary(path) if tool_name == "py_get_skeleton": return py_get_skeleton(path) + if tool_name == "ts_c_get_skeleton": + return ts_c_get_skeleton(path) + if tool_name == "ts_cpp_get_skeleton": + return ts_cpp_get_skeleton(path) if tool_name == "py_get_code_outline": return py_get_code_outline(path) + if tool_name == "ts_c_get_code_outline": + return ts_c_get_code_outline(path) + if tool_name == "ts_cpp_get_code_outline": + return ts_cpp_get_code_outline(path) if tool_name == "py_get_definition": return py_get_definition(path, str(tool_input.get("name", ""))) if tool_name == "py_update_definition": @@ -1256,6 +1320,80 @@ MCP_TOOL_SPECS: list[dict[str, Any]] = [ "required": ["path"], }, }, + { + "name": "ts_c_get_skeleton", + "description": ( + "Get a skeleton view of a C file. " + "This returns all function signatures and structs, " + "but replaces function bodies with '...'. " + "Use this to understand C interfaces without reading the full implementation." + ), + "parameters": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to the C file.", + } + }, + "required": ["path"], + }, + }, + { + "name": "ts_cpp_get_skeleton", + "description": ( + "Get a skeleton view of a C++ file. " + "This returns all classes, structs and function signatures, " + "but replaces function bodies with '...'. " + "Use this to understand C++ interfaces without reading the full implementation." + ), + "parameters": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to the C++ file.", + } + }, + "required": ["path"], + }, + }, + { + "name": "ts_c_get_code_outline", + "description": ( + "Get a hierarchical outline of a C file. " + "This returns structs and functions with their line ranges. " + "Use this to quickly map out a file's structure before reading specific sections." + ), + "parameters": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to the C file.", + } + }, + "required": ["path"], + }, + }, + { + "name": "ts_cpp_get_code_outline", + "description": ( + "Get a hierarchical outline of a C++ file. " + "This returns classes, structs and functions with their line ranges. " + "Use this to quickly map out a file's structure before reading specific sections." + ), + "parameters": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path to the C++ file.", + } + }, + "required": ["path"], + }, + }, { "name": "get_file_slice", "description": "Read a specific line range from a file. Useful for reading parts of very large files.",