Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

pdf_add_password

Add password protection to PDF files to control access, restrict printing, and prevent unauthorized modifications using encryption algorithms like AES-256.

Instructions

Add password protection to a PDF file. Ref: https://developer.pdf.co/api-reference/pdf-password/add.md

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files.
owner_passwordYesThe main owner password that is used for document encryption and for setting/removing restrictions.
user_passwordNoThe optional user password will be asked for viewing and printing document.
encryption_algorithmNoEncryption algorithm. Valid values: RC4_40bit, RC4_128bit, AES_128bit, AES_256bit. AES_128bit or higher is recommended.AES_256bit
allow_accessibility_supportNoAllow or prohibit content extraction for accessibility needs.
allow_assembly_documentNoAllow or prohibit assembling the document.
allow_print_documentNoAllow or prohibit printing PDF document.
allow_fill_formsNoAllow or prohibit the filling of interactive form fields (including signature fields) in the PDF documents.
allow_modify_documentNoAllow or prohibit modification of PDF document.
allow_content_extractionNoAllow or prohibit copying content from PDF document.
allow_modify_annotationsNoAllow or prohibit interacting with text annotations and forms in PDF document.
print_qualityNoAllowed printing quality. Valid values: HighResolution, LowResolution.
httpusernameNoHTTP auth user name if required to access source url. (Optional)
httppasswordNoHTTP auth password if required to access source url. (Optional)
passwordNoPassword of the PDF file if it's already password-protected. (Optional)
nameNoFile name for the generated output. (Optional)
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • MCP tool handler for 'pdf_add_password'. Includes @mcp.tool() decorator for registration, detailed input schema via Pydantic Fields, and logic to build parameters before calling the service helper.
    @mcp.tool() async def pdf_add_password( url: str = Field( description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files." ), owner_password: str = Field( description="The main owner password that is used for document encryption and for setting/removing restrictions." ), user_password: str = Field( description="The optional user password will be asked for viewing and printing document.", default="", ), encryption_algorithm: str = Field( description="Encryption algorithm. Valid values: RC4_40bit, RC4_128bit, AES_128bit, AES_256bit. AES_128bit or higher is recommended.", default="AES_256bit", ), allow_accessibility_support: bool = Field( description="Allow or prohibit content extraction for accessibility needs.", default=False, ), allow_assembly_document: bool = Field( description="Allow or prohibit assembling the document.", default=False ), allow_print_document: bool = Field( description="Allow or prohibit printing PDF document.", default=False ), allow_fill_forms: bool = Field( description="Allow or prohibit the filling of interactive form fields (including signature fields) in the PDF documents.", default=False, ), allow_modify_document: bool = Field( description="Allow or prohibit modification of PDF document.", default=False ), allow_content_extraction: bool = Field( description="Allow or prohibit copying content from PDF document.", default=False, ), allow_modify_annotations: bool = Field( description="Allow or prohibit interacting with text annotations and forms in PDF document.", default=False, ), print_quality: str = Field( description="Allowed printing quality. Valid values: HighResolution, LowResolution.", default="", ), httpusername: str = Field( description="HTTP auth user name if required to access source url. (Optional)", default="", ), httppassword: str = Field( description="HTTP auth password if required to access source url. (Optional)", default="", ), password: str = Field( description="Password of the PDF file if it's already password-protected. (Optional)", default="", ), name: str = Field( description="File name for the generated output. (Optional)", default="" ), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: """ Add password protection to a PDF file. Ref: https://developer.pdf.co/api-reference/pdf-password/add.md """ params = ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, password=password, name=name, ) additional_params = { "ownerPassword": owner_password, } if user_password is not None: additional_params["userPassword"] = user_password if encryption_algorithm is not None: additional_params["EncryptionAlgorithm"] = encryption_algorithm if allow_accessibility_support is not None: additional_params["AllowAccessibilitySupport"] = allow_accessibility_support if allow_assembly_document is not None: additional_params["AllowAssemblyDocument"] = allow_assembly_document if allow_print_document is not None: additional_params["AllowPrintDocument"] = allow_print_document if allow_fill_forms is not None: additional_params["AllowFillForms"] = allow_fill_forms if allow_modify_document is not None: additional_params["AllowModifyDocument"] = allow_modify_document if allow_content_extraction is not None: additional_params["AllowContentExtraction"] = allow_content_extraction if allow_modify_annotations is not None: additional_params["AllowModifyAnnotations"] = allow_modify_annotations if print_quality is not None: additional_params["PrintQuality"] = print_quality return await add_pdf_password(params, **additional_params, api_key=api_key)
  • Service helper function that performs the actual HTTP request to the PDF.co API endpoint for adding password to PDF.
    async def add_pdf_password( params: ConversionParams, api_key: str | None = None, **kwargs ) -> BaseResponse: return await request( "pdf/security/add", params, custom_payload=kwargs, api_key=api_key )
  • Output type annotation using BaseResponse model for standardized response handling.
    ) -> BaseResponse: """ Add password protection to a PDF file. Ref: https://developer.pdf.co/api-reference/pdf-password/add.md """ params = ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, password=password, name=name, ) additional_params = { "ownerPassword": owner_password, } if user_password is not None: additional_params["userPassword"] = user_password if encryption_algorithm is not None: additional_params["EncryptionAlgorithm"] = encryption_algorithm if allow_accessibility_support is not None: additional_params["AllowAccessibilitySupport"] = allow_accessibility_support if allow_assembly_document is not None: additional_params["AllowAssemblyDocument"] = allow_assembly_document if allow_print_document is not None: additional_params["AllowPrintDocument"] = allow_print_document if allow_fill_forms is not None: additional_params["AllowFillForms"] = allow_fill_forms if allow_modify_document is not None: additional_params["AllowModifyDocument"] = allow_modify_document if allow_content_extraction is not None: additional_params["AllowContentExtraction"] = allow_content_extraction if allow_modify_annotations is not None: additional_params["AllowModifyAnnotations"] = allow_modify_annotations if print_quality is not None: additional_params["PrintQuality"] = print_quality return await add_pdf_password(params, **additional_params, api_key=api_key)
  • Decorator that registers the function as an MCP tool named 'pdf_add_password'.
    @mcp.tool()

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/pdfdotco/pdfco-mcp'

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