get_document_info
Retrieve detailed metadata and properties from a Word document using a standardized interface, enabling efficient document analysis and management.
Instructions
Get information about a Word document.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | Yes |
Implementation Reference
- Core handler function that processes the input filename, ensures proper extension for local files, retrieves document properties using a utility function, and returns them as formatted JSON or an error message.async def get_document_info(filename: str) -> str: """Get information about a Word document from local path or URL. Args: filename: Path or URL to the Word document """ # Only add .docx extension for local paths, not URLs if not is_url(filename): filename = ensure_docx_extension(filename) try: properties = get_document_properties(filename) return json.dumps(properties, indent=2) except Exception as e: return f"Failed to get document info: {str(e)}"
- word_document_server/main.py:532-535 (registration)Registers the 'get_document_info' tool with the FastMCP server using the @mcp.tool() decorator. This wrapper function delegates execution to the core handler in document_tools.py and provides the tool description used for schema inference.@mcp.tool() async def get_document_info(filename: str): """Get information about a Word document.""" return await document_tools.get_document_info(filename)
- word_document_server/tools/__init__.py:9-13 (registration)Exposes the get_document_info function by importing it into the tools package __init__.py, making it available for import in the main server registration.from word_document_server.tools.document_tools import ( create_document, get_document_info, get_document_text, get_document_outline, list_available_documents, copy_document, merge_documents )