INNER CODE UNIT · Python

full_path

existence-master/Sentient · src/server/mcp_hub/file_management/main.py:47

    full_path = (base_dir / filename).resolve()
    
    # SECURITY CHECK: Ensure the resolved path is still inside the base directory
    if base_dir not in full_path.parents:
        raise ToolError("Access denied: Path traversal attempt detected.")

    return full_path

# --- Tool Definitions ---
@mcp.tool()
async def read_file(ctx: Context, filename: str) -> Dict[str, Any]:
    """
    Reads the content of a specified file from the temporary storage and extracts its text content. The `filename` should be one of the files returned by `list_files`.
    """
    logger.info(f"Executing tool: read_file with filename='{filename}'")
    try:
        user_id = auth.get_user_id_from_context(ctx)
        safe_user_id = "".join(c for c in user_id if c.isalnum() or c in ('-', '_'))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…