Get information about a file
(path: str)
| 74 | |
| 75 | @mcp.tool() |
| 76 | def get_file_info(path: str) -> str: |
| 77 | """Get information about a file""" |
| 78 | path_obj = Path(path) |
| 79 | |
| 80 | if not path_obj.exists(): |
| 81 | return f"Path not found: {path}" |
| 82 | |
| 83 | try: |
| 84 | stat_info = path_obj.stat() |
| 85 | file_type = "directory" if path_obj.is_dir() else "file" |
| 86 | |
| 87 | info = [ |
| 88 | f"Path: {path}", |
| 89 | f"Type: {file_type}", |
| 90 | f"Size: {stat_info.st_size} bytes", |
| 91 | f"Modified: {stat_info.st_mtime}", |
| 92 | f"Created: {stat_info.st_ctime}", |
| 93 | ] |
| 94 | |
| 95 | info_text = "\n".join(info) |
| 96 | return f"File Info:\n{info_text}" |
| 97 | |
| 98 | except PermissionError: |
| 99 | return f"Permission denied accessing: {path}" |
| 100 | except Exception as e: |
| 101 | return f"Error getting file info: {str(e)}" |
| 102 | |
| 103 | |
| 104 | # Main execution |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…