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
| Name | Required | Description | Default |
|---|---|---|---|
| pdf_id | Yes | ID of the PDF to close |
Implementation Reference
- src/pdf_reader_mcp/server.py:466-485 (handler)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)}'", ) ]
- src/pdf_reader_mcp/server.py:362-372 (registration)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"], }, ),
- src/pdf_reader_mcp/server.py:362-372 (schema)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"], }, ),