read_files
Read files during penetration testing to analyze system data, configuration files, or security logs for vulnerability assessment and attack path discovery.
Instructions
read a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/pentestmcp/server.py:161-161 (registration)Registration of the 'read_files' tool using the @mcp.tool decorator.@mcp.tool(name='read_files', description="read a file")
- src/pentestmcp/server.py:162-180 (handler)The handler function implements the logic to read the contents of a file given its path, handling errors and returning the content as string or None.def read_files(path: str | Path) -> str | None: try: if not path: raise ValueError("Path cannot be empty") file_path = Path(path).expanduser() if not file_path.is_file(): raise FileNotFoundError(f"File does not exist: {file_path}") with file_path.open('r', encoding='utf-8') as file: content = file.read() print(f"File read successfully: {file_path}") return content except Exception as e: print(f"Error reading file: {e}") return None