read_file
Read file contents to verify compliance with organizational policies before AI coding agents access them, preventing security and naming convention violations.
Instructions
Read contents of a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path |
Implementation Reference
- server.py:170-177 (handler)The handler for the 'read_file' tool. Resolves the path using resolve_path, checks if the file exists, reads the content if it does, and returns it wrapped in TextContent. Errors if not found.elif name == "read_file": path = resolve_path(arguments["path"]) if not path.exists(): return [TextContent(type="text", text=f"Error: File '{arguments['path']}' not found")] with open(path, 'r', encoding='utf-8') as f: content = f.read() return [TextContent(type="text", text=content)]
- server.py:92-98 (schema)Input schema definition for the 'read_file' tool, specifying an object with a required 'path' string property.inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": "File path"} }, "required": ["path"] }
- server.py:89-99 (registration)Registration of the 'read_file' tool in the list_tools() function, including name, description, and input schema.Tool( name="read_file", description="Read contents of a file", inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": "File path"} }, "required": ["path"] } ),