Skip to main content
Glama

full_document_workflow

Capture document pages, process images, and convert to PDF in a single automated workflow for document digitization.

Instructions

Complete workflow: capture document pages, optionally process them, and convert to PDF.

Args:
    window_id: Window ID containing the document
    page_count: Number of pages to capture
    output_pdf: Path for the final PDF file
    capture_dir: Temporary directory for captures
    title: Optional PDF title
    navigation_key: Key for page navigation
    delay_seconds: Delay between navigation and capture
    process_images_flag: Whether to enhance images before PDF conversion

Returns:
    JSON string with complete workflow results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
window_idYes
page_countYes
output_pdfYes
capture_dirNo
titleNo
navigation_keyNoPage_Down
delay_secondsNo
process_images_flagNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The full_document_workflow tool handler, decorated with @mcp.tool() for registration. This async function orchestrates the complete workflow: capturing multiple pages from a window, optionally processing (enhancing) the images, converting them to PDF, and optionally cleaning up temp files. It returns a JSON summary of all steps.
    @mcp.tool()
    async def full_document_workflow(
        window_id: str,
        page_count: int,
        output_pdf: str,
        capture_dir: Optional[str] = None,
        title: Optional[str] = None,
        navigation_key: str = "Page_Down",
        delay_seconds: float = 1.0,
        process_images_flag: bool = True
    ) -> str:
        """
        Complete workflow: capture document pages, optionally process them, and convert to PDF.
        
        Args:
            window_id: Window ID containing the document
            page_count: Number of pages to capture
            output_pdf: Path for the final PDF file
            capture_dir: Temporary directory for captures
            title: Optional PDF title
            navigation_key: Key for page navigation
            delay_seconds: Delay between navigation and capture
            process_images_flag: Whether to enhance images before PDF conversion
        
        Returns:
            JSON string with complete workflow results.
        """
        try:
            # Get configured temp directory (with backward compatibility)
            config = get_config()
            if capture_dir is None:
                if config.should_use_legacy_mode():
                    capture_dir = "temp_captures"  # Legacy default
                else:
                    actual_capture_dir = get_temp_directory()
            else:
                actual_capture_dir = get_temp_directory(capture_dir)
            
            # Convert to string for compatibility with existing manager interface
            capture_dir_str = str(actual_capture_dir)
            
            workflow_results = {
                "status": "success",
                "steps": []
            }
            
            # Step 1: Capture pages
            logger.info("Step 1: Capturing document pages")
            wm = get_window_manager()
            if hasattr(wm.manager, 'capture_multiple_pages'):
                captured_files = wm.manager.capture_multiple_pages(
                    window_id=window_id,
                    page_count=page_count,
                    output_dir=capture_dir_str,
                    navigation_key=navigation_key,
                    delay_seconds=delay_seconds
                )
            else:
                # Fallback for Windows applications
                actual_capture_dir.mkdir(parents=True, exist_ok=True)
                captured_files = []
                for page_num in range(1, page_count + 1):
                    filename = generate_page_filename(page_num)
                    output_path = actual_capture_dir / filename
                    captured_path = wm.capture_window(window_id, str(output_path))
                    captured_files.append(captured_path)
                    
                    if page_num < page_count:
                        time.sleep(delay_seconds)
            
            workflow_results["steps"].append({
                "step": "capture",
                "status": "success",
                "files_captured": len(captured_files),
                "output_directory": capture_dir_str
            })
            
            # Step 2: Process images (if requested)
            processed_files = captured_files
            if process_images_flag:
                logger.info("Step 2: Processing captured images")
                ip = get_image_processor()
                processing_results = ip.process_batch(
                    capture_dir_str, 
                    ["enhance"]
                )
                
                if processing_results["enhanced_files"]:
                    processed_files = processing_results["enhanced_files"]
                    
                workflow_results["steps"].append({
                    "step": "processing",
                    "status": "success",
                    "enhanced_files": len(processing_results["enhanced_files"])
                })
            
            # Step 3: Convert to PDF
            logger.info("Step 3: Converting to PDF")
            pc = get_pdf_converter()
            pdf_path = pc.images_to_pdf(
                processed_files,
                output_pdf,
                sort_files=True,
                title=title or f"Document captured from window {window_id}"
            )
            
            pdf_info = pc.get_pdf_info(pdf_path)
            
            workflow_results["steps"].append({
                "step": "pdf_conversion",
                "status": "success",
                "output_pdf": pdf_path,
                "pdf_info": pdf_info
            })
            
            # Step 4: Cleanup temporary files (optional)
            import shutil
            try:
                config = get_config()
                if config.get_config_summary().get("auto_cleanup_temp", True):
                    # Only cleanup if it's a temp directory or legacy temp pattern
                    if (capture_dir is None and not config.should_use_legacy_mode()) or \
                       (capture_dir_str.startswith("temp_") or "temp" in str(actual_capture_dir).lower()):
                        shutil.rmtree(capture_dir_str)
                        workflow_results["steps"].append({
                            "step": "cleanup",
                            "status": "success",
                            "cleaned_directory": capture_dir_str
                        })
            except Exception as cleanup_error:
                logger.warning(f"Failed to cleanup {capture_dir_str}: {cleanup_error}")
            
            workflow_results.update({
                "window_id": window_id,
                "pages_captured": len(captured_files),
                "final_pdf": pdf_path,
                "pdf_info": pdf_info
            })
            
            return json.dumps(workflow_results, indent=2)
            
        except Exception as e:
            logger.error(f"Workflow failed: {e}")
            return json.dumps({
                "status": "error",
                "error": str(e),
                "window_id": window_id,
                "page_count": page_count,
                "output_pdf": output_pdf
            })
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the workflow steps but lacks critical behavioral details: it doesn't specify what 'process them' entails (e.g., image enhancement), whether this is a read-only or destructive operation, what permissions or prerequisites are needed, or how errors are handled. The description is insufficient for a tool with 8 parameters and complex workflow behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with a clear summary sentence followed by organized parameter explanations. It's appropriately sized for an 8-parameter tool, though the 'Args' and 'Returns' sections could be more integrated. Every sentence adds value, with no redundant information, making it efficient for understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, workflow behavior) and lack of annotations, the description is moderately complete. The parameter explanations help, but behavioral aspects are under-specified. The existence of an output schema reduces the need to detail return values, but the description should better explain the workflow's operational characteristics and error handling for adequate completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description provides a helpful 'Args' section that lists all 8 parameters with brief explanations, adding significant meaning beyond the input schema which has 0% description coverage. It clarifies purposes like 'Path for the final PDF file' for output_pdf and 'Whether to enhance images' for process_images_flag. However, some explanations remain vague (e.g., 'Key for page navigation' doesn't specify valid values).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool performs a 'complete workflow' that captures document pages, optionally processes them, and converts to PDF. It specifies the verb ('capture', 'process', 'convert') and resource ('document pages', 'PDF'), but doesn't explicitly differentiate from sibling tools like 'capture_document_pages' or 'convert_to_pdf' which might handle parts of this workflow separately.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'capture_document_pages' or 'convert_to_pdf', nor does it explain when this comprehensive workflow is preferable to using individual tools. The agent must infer usage from the 'complete workflow' phrasing without explicit context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/PovedaAqui/auto-snap-mcp'

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