list_pdfs
Locate and retrieve PDF file paths from specified directories using an optional filter. Simplify document management and access by identifying relevant PDFs efficiently.
Instructions
List PDF files in configured base paths
Args:
path_filter: Optional string to filter PDF paths
Returns:
List of PDF paths matching the filter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path_filter | No |
Implementation Reference
- mcp_pdf_forms/server.py:19-50 (handler)The handler function for the 'list_pdfs' MCP tool, registered via @mcp.tool() decorator. It scans configured base directories (BASE_PATHS) recursively for PDF files, optionally filters by path string, and returns a sorted list of matching full paths.@mcp.tool() def list_pdfs(path_filter: Optional[str] = None) -> List[str]: """ List PDF files in configured base paths Args: path_filter: Optional string to filter PDF paths Returns: List of PDF paths matching the filter """ results = [] for base_path in BASE_PATHS: base = Path(base_path) if not base.exists(): continue for root, _, files in os.walk(base): root_path = Path(root) for file in files: if file.lower().endswith(".pdf"): pdf_path = root_path / file path_str = str(pdf_path) # Apply filter if provided if path_filter and path_filter not in path_str: continue results.append(path_str) return sorted(results)
- mcp_pdf_forms/server.py:19-19 (registration)Registration of the list_pdfs tool using the FastMCP @mcp.tool() decorator, which uses the function signature and docstring for input/output schema.@mcp.tool()
- mcp_pdf_forms/server.py:20-29 (schema)Input/output schema defined by type hints (Optional[str] input, List[str] output) and docstring describing args and return value.def list_pdfs(path_filter: Optional[str] = None) -> List[str]: """ List PDF files in configured base paths Args: path_filter: Optional string to filter PDF paths Returns: List of PDF paths matching the filter """