Skip to main content
Glama
GILSMON

MCP Policy Gatekeeper

by GILSMON

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
NameRequiredDescriptionDefault
pathYesFile path

Implementation Reference

  • 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)]
  • 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"]
        }
    ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/GILSMON/mcpServer_as_gatekeeper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server