close-pdf
Use this tool to securely close an open PDF file by specifying its unique ID, ensuring proper resource management and system efficiency.
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)The handler function in handle_call_tool that executes the close-pdf tool: validates pdf_id, removes the PDF from global pdfs and pdf_paths dictionaries, notifies resource change, and returns 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)The 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:365-371 (schema)The JSON schema for close-pdf tool input, defining a required pdf_id string.inputSchema={ "type": "object", "properties": { "pdf_id": {"type": "string", "description": "ID of the PDF to close"}, }, "required": ["pdf_id"], },