Skip to main content
Glama
pietermyb

mcp-pdf-reader

close-pdf

Close an open PDF file to free system resources and manage document sessions. Use this tool when finished reading or processing a PDF to maintain optimal performance.

Instructions

Close an open PDF file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_idYesID of the PDF to close

Implementation Reference

  • Handler function for the 'close-pdf' tool. It closes the PDF by removing it from the pdfs and pdf_paths dictionaries, notifies clients of resource changes, and returns a confirmation message.
    elif name == "close-pdf":
        pdf_id = arguments.get("pdf_id")
        if not pdf_id or pdf_id not in pdfs:
            raise ValueError("Invalid PDF ID")
    
        path = pdf_paths[pdf_id]
    
        # Remove from storage
        del pdfs[pdf_id]
        del pdf_paths[pdf_id]
    
        # Notify clients that resources have changed
        await server.request_context.session.send_resource_list_changed()
    
        return [
            types.TextContent(
                type="text",
                text=f"Closed PDF '{os.path.basename(path)}'",
            )
        ]
  • Registration of the 'close-pdf' tool in the list_tools handler, including name, description, and input schema requiring 'pdf_id'.
    types.Tool(
        name="close-pdf",
        description="Close an open PDF file",
        inputSchema={
            "type": "object",
            "properties": {
                "pdf_id": {"type": "string", "description": "ID of the PDF to close"},
            },
            "required": ["pdf_id"],
        },
    ),
  • Input schema definition for the 'close-pdf' tool, specifying the required 'pdf_id' parameter.
    types.Tool(
        name="close-pdf",
        description="Close an open PDF file",
        inputSchema={
            "type": "object",
            "properties": {
                "pdf_id": {"type": "string", "description": "ID of the PDF to close"},
            },
            "required": ["pdf_id"],
        },
    ),

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/pietermyb/mcp-pdf-reader'

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