MCPcopy Create free account
hub / github.com/modelcontextprotocol/mcpb / get_file_info

Function get_file_info

examples/file-manager-python/server/main.py:76–101  ·  view source on GitHub ↗

Get information about a file

(path: str)

Source from the content-addressed store, hash-verified

74
75@mcp.tool()
76def 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…