GroupDocs.Parser for Python via .NET is designed to work with AI agents, LLMs, and code generation tools. The library ships machine-readable documentation in several formats, including an AGENTS.md file inside the pip package itself, so that AI assistants can discover and use the API without manual guidance.
MCP server for the documentation
GroupDocs provides an MCP (Model Context Protocol) server that lets LLMs query the documentation on demand instead of loading it all at once. This saves tokens and lets your AI assistant fetch only what it needs for the current task.
To connect your AI tool to the MCP server, add the GroupDocs endpoint to your MCP configuration:
// Claude Code: ~/.claude/settings.json (or project .mcp.json)
// Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json
{"mcpServers":{"groupdocs-docs":{"url":"https://docs.groupdocs.com/mcp"}}}
// .vscode/mcp.json in your project root
{"servers":{"groupdocs-docs":{"url":"https://docs.groupdocs.com/mcp"}}}
// .cursor/mcp.json in your project root
{"mcpServers":{"groupdocs-docs":{"url":"https://docs.groupdocs.com/mcp"}}}
// Any MCP-compatible client
{"mcpServers":{"groupdocs-docs":{"url":"https://docs.groupdocs.com/mcp"}}}
The GroupDocs.Parser MCP server is a separate server that does the work itself: it lets an AI agent extract text, tables, metadata, images and barcodes from documents, locally on your machine. The server is the .NET build of GroupDocs.Parser and ships as a Docker image, so it runs alongside a Python project without a .NET installation.
Use the documentation MCP server when an agent writes Python code against this library, and the extraction MCP server when the agent itself reads documents. SDK, Cloud or MCP? compares the options.
AGENTS.md: built into the package
The groupdocs-parser-net pip package includes an AGENTS.md file at groupdocs/parser/AGENTS.md. AI coding assistants that scan installed packages (such as Claude Code, Cursor, and GitHub Copilot) can read it to learn the imports, key patterns, callbacks, the command line, licensing, platform requirements, and troubleshooting tips. Its full text is reproduced below.
After installing the package, you can find it with:
pip show -f groupdocs-parser-net | grep AGENTS
Machine-readable documentation
Every documentation page is available as a plain Markdown file that AI tools can fetch and process directly:
Point your AI assistant to the full documentation file for comprehensive context:
Fetch https://docs.groupdocs.com/parser/python-net/llms-full.txt and use it
as a reference for GroupDocs.Parser for Python via .NET API.
Why GroupDocs.Parser is a good building block for AI pipelines
Models read text, not files. GroupDocs.Parser turns the documents an agent receives into text and data it can use, with the same API across PDF, Office, OpenDocument, email, eBook, archive and image files:
Feed RAG and search: extract plain text, or Markdown that keeps headings, lists and tables, page by page.
Get structured data: read tables as rows and cells, metadata as names and values, and invoice-like layouts with templates.
Read what reviewers said: collect comments and notes with their authors and pages, or include them in the extracted text.
Open what is inside: process the documents inside ZIP archives, email attachments and PDF portfolios.
Recognize scans: run OCR on scanned pages and images.
A typical extraction step looks like this:
importjsonfromgroupdocs.parserimportParserwithParser("invoice.pdf")asparser:info=parser.get_document_info()text=parser.get_text()tables=parser.get_tables()or[]record={"format":info.file_type.file_format,"pages":info.page_count,"characters":len(textor""),"tables":[[[table[row,column].textforcolumninrange(table.column_count)]forrowinrange(table.row_count)]fortableintables],}# feed `record` into your index, an agent's context, or a review queueprint(json.dumps(record,indent=2))
The following sample file is used in this example: invoice.pdf
For the sample invoice it prints the document’s size and its three tables (abridged):
An agent with a shell can get the same data without writing code, through the command line: groupdocs-parser text invoice.pdf --format markdown, groupdocs-parser info invoice.pdf --json, groupdocs-parser annotations reviewed.docx --json.
Without a license, extracted text stops after about 20 lines and only the first 5 metadata items are returned. Set the GROUPDOCS_LIC_PATH environment variable before an agent runs these steps. See Licensing and evaluation limitations.
Pair with other GroupDocs products
For richer AI document pipelines, chain GroupDocs.Parser with:
SDK, Cloud or MCP?: which GroupDocs.Parser product line fits your project
AGENTS.md reference
The complete AGENTS.md shipped in the 26.10 package:
# GroupDocs.Parser for Python via .NET -- AGENTS.md
> Instructions for AI agents working with this package.
Extract text, formatted text (HTML, Markdown), tables, images, metadata, hyperlinks, barcodes, annotations and the table of contents from PDF, Word, Excel, PowerPoint, email, eBook, archive and image files (65+ formats).
## Install
```bash
pip install groupdocs-parser-net
```**Python**: 3.5 - 3.14 | **Platforms**: Windows x64, Linux x64 (glibc 2.27+), macOS 13+ (Intel, Apple Silicon; OCR needs 13.3+)
## Resources
| Resource | URL |
|---|---|
| Documentation | https://docs.groupdocs.com/parser/python-net/ |
| LLM-optimized docs | https://docs.groupdocs.com/parser/python-net/llms-full.txt |
| API reference | https://reference.groupdocs.com/parser/python-net/ |
| Code examples | https://github.com/groupdocs-parser/GroupDocs.Parser-for-Python-via-.NET |
| Release notes | https://releases.groupdocs.com/parser/python-net/release-notes/ |
| PyPI | https://pypi.org/project/groupdocs-parser-net/ |
| Free support forum | https://forum.groupdocs.com/c/parser/ |
| Temporary license | https://purchase.groupdocs.com/temporary-license |
## MCP Server
If your environment has MCP configured, you can connect your AI tool to the GroupDocs documentation server for on-demand API lookups:
```json
{"mcpServers":{"groupdocs-docs":{"url":"https://docs.groupdocs.com/mcp"}}}```Works with Claude Code (`~/.claude/settings.json`), Cursor (`.cursor/mcp.json`), VS Code Copilot (`.vscode/mcp.json`), and any MCP-compatible client. If MCP is unavailable, fall back to the LLM-optimized docs URL above and to this file, which is shipped inside the wheel.
## Imports
Each class lives in one module; the root exports only `Parser`, `License`, `Metered` and `Resources`. The exceptions are in `groupdocs.parser.exceptions`.
```python
fromgroupdocs.parserimportLicense,Parserfromgroupdocs.parser.dataimportAnnotationItem,PageImageArea,PageTableArea,Rectangle,Point,Size,...fromgroupdocs.parser.exportimportJsonExporter,XmlExporterfromgroupdocs.parser.optionsimport(FileType,FormattedTextMode,FormattedTextOptions,LoadOptions,PageAreaOptions,ParserSettings,PreviewOptions,TextOptions,...)fromgroupdocs.parser.templatesimportTemplate,TemplateField,TemplateTable,TemplateTableLayout,...fromgroupdocs.parser.exceptionsimportInvalidPasswordException,UnsupportedDocumentFormatException```## Extract Text
```python
fromgroupdocs.parserimportParserwithParser("document.pdf")asparser:text=parser.get_text()# str, or None when the format has no textiftextisnotNone:print(text)```-`get_text()` / `get_formatted_text()` return a `str` that also answers `read_to_end()` -- 25.12 code and .NET-style code both work. `None` means not supported.
- One page: `parser.get_text(page_index)` (0-based). Options: `parser.get_text(TextOptions(True))` for raw mode, `TextOptions(False, True)` for OCR.
- Markdown or HTML: `parser.get_formatted_text(FormattedTextOptions(FormattedTextMode.MARKDOWN))`.
## Other Extraction
```python
fromgroupdocs.parserimportParserwithParser("document.pdf")asparser:info=parser.get_document_info()# file_type.file_format, page_count, sizefortableinparser.get_tables()or[]:# PageTableArearows=[[table[r,c].textforcinrange(table.column_count)]forrinrange(table.row_count)]forimageinparser.get_images()or[]:# PageImageAreaimage.save("img%s"%image.file_type.extension)# or image.get_image_stream().read() -> bytesfornoteinparser.get_annotations()or[]:# AnnotationItem: value, author_name, page_indexprint(note.author_name,note.value.strip())foriteminparser.get_metadata()or[]:# MetadataItem: name, valueprint(item.name,item.value)```Check `parser.features.<name>` (text, tables, images, hyperlinks, annotations, metadata, structure, toc, ...) before a call when the format is unknown; an unsupported call returns `None`.
## Callbacks
```python
importiofromgroupdocs.parser.optionsimportParserSettings,PreviewOptionssettings=ParserSettings(lambdalevel,message,exception:print(level,message))# loggersettings=ParserSettings(external_resource_handler=lambdaargs:setattr(args,"skipped",True))pages={}options=PreviewOptions(lambdapage_number:pages.setdefault(page_number,io.BytesIO()))# page previewsoptions.preview_page_render=lambdainfo:print("rendering page",info.page_number)```-`ParserSettings` has no empty constructor: pass a logger, an OCR connector or a resource handler (keywords pick which).
- The logger may be an object with `trace`/`warning`/`error`; the resource handler an object with `on_loading(args)` or a subclass of `ExternalResourceHandler`. The engine consults the handler for images in HTML and MHTML only.
## Command Line
`groupdocs-parser text|info|metadata|images|annotations|list-formats FILE` (or `python -m groupdocs.parser`). `text` takes `--page N` (from 1), `--format plain|markdown|html`, `--ocr`, `--include-annotations`, `-o FILE`; `info`, `metadata` and `annotations` take `--json`; `images` takes `--out DIR`; every command takes `--password`. Exit codes: 0 ok, 2 user error, 1 engine error or unsupported operation.
## Licensing
```python
fromgroupdocs.parserimportLicense# From fileLicense().set_license("path/to/license.lic")# From streamwithopen("license.lic","rb")asf:License().set_license(f)```Or auto-apply: `export GROUPDOCS_LIC_PATH="path/to/license.lic"`**Evaluation vs licensed.** Without a license the library still runs, but extracted text stops after about 20 lines and ends with "Evaluation only. Created with GroupDocs.Parser for .NET.", and only the first 5 metadata items are returned. Set `GROUPDOCS_LIC_PATH` (or call `License().set_license(...)`) and re-run to clear both. A 30-day full license is free: https://purchase.groupdocs.com/temporary-license
## API Reference
### Parser
| Method | Returns | Description |
|---|---|---|
| `Parser(path_or_stream, load_options=None, parser_settings=None)` | | Open a file path or a binary stream |
| `get_text(options=None, page_index=None)` | `str` or `None` | Plain text |
| `get_formatted_text(options, page_index=None)` | `str` or `None` | HTML / Markdown / plain |
| `get_document_info()` | `DocumentInfo` | Format, pages, size |
| `search(keyword, options=None)` | list of `SearchResult` | Keyword or regex search |
| `get_highlight(position, is_direct, options)` | `HighlightItem` | Text around a position |
| `get_structure()` | `XmlReader` | Document structure as XML |
| `get_toc()` | list of `TocItem` | Table of contents; `item.extract_text()` returns the section text |
| `get_container()` | list of `ContainerItem` | Archive entries / attachments |
| `get_metadata()` | list of `MetadataItem` | Document properties |
| `get_text_areas()` / `get_images()` / `get_hyperlinks()` / `get_barcodes()` / `get_tables()` | lists | Page areas, whole document or `(page_index, options)` |
| `get_annotations(page_index=None)` | list of `AnnotationItem` | Comments and notes |
| `get_page_preview(page_index)` | `Stream` (`.read()` -> bytes) | PNG preview of one page |
| `generate_preview(preview_options)` | `None` | Previews through callbacks |
| `parse_by_template(template)` | `DocumentData` | Fields and tables by layout |
| `parse_form()` | `DocumentData` | PDF form fields |
| `Parser.get_file_info(path_or_stream)` | `FileInfo` | static: format and encryption, without opening |
## Key Patterns
- **Properties**: use `snake_case` -- auto-mapped to .NET `PascalCase`. Assigning a misspelled property raises `AttributeError`.
- **Context managers**: `with Parser(...) as x:` ensures resources are released
- **Streams**: pass `open("file", "rb")` or `io.BytesIO(data)` where .NET expects Stream; a Stream the engine returns has `.read()`- **Truth tests**: an engine object is true; a returned list is false when empty. Prefer `is None` checks for "not supported"
- **Enums**: case-insensitive, lazy-loaded (e.g., `FileType.DOCX`, `FormattedTextMode.MARKDOWN`)
- **Collections**: `for item in result`, `len(result)` and `result[i]` work on returned lists
- **Errors**: engine errors raise `GroupDocsParserException` or a subclass (`InvalidPasswordException`, `CorruptedDocumentException`, `UnsupportedDocumentFormatException`) from `groupdocs.parser.exceptions`, not `RuntimeError` as in 25.12
## Platform Requirements
| Platform | Requirements |
|---|---|
| Windows | None |
| Linux | `apt install libicu-dev libfontconfig1 fonts-liberation libgdiplus` (no Microsoft core fonts) |
| macOS | macOS 13 or newer; OCR (text from scanned pages and images) needs 13.3 or newer. `brew install mono-libgdiplus` |
libgdiplus serves presentations: page previews, ODP and OTP files, and PowerPoint files with tables or hyperlinks. Every other format works without it.
## Troubleshooting
**The process aborts with `Couldn't find a valid ICU package`** -- install ICU: `sudo apt install libicu-dev`. Do NOT set `DOTNET_SYSTEM_GLOBALIZATION_INVARIANT`.
**Merged table cells come out as separate rows in `get_structure()`** -- install the Liberation fonts: `sudo apt install fonts-liberation`**`The type initializer for 'Gdip' threw an exception` / `DllNotFoundException: libgdiplus`** -- install libgdiplus: `sudo apt install libgdiplus` (macOS: `brew install mono-libgdiplus`). Presentations need it: page previews, ODP and OTP files, and PowerPoint files with tables or hyperlinks.
**The first `Parser(...)` takes 20-30 seconds** -- expected: the engine loads once per process; later documents open in a fraction of a second.
**An `aspose_data` folder of about 80 MB appears in the working directory** -- the first OCR call unpacks the recognition models there (no download). Set `Resources.storage_path = "/path/to/cache"` (`from groupdocs.parser import Resources`) before the first OCR call to choose the folder, e.g. when the working directory is read-only.
**`TypeError: __init__() - no overload matched` for `ParserSettings()`** -- there is no empty `ParserSettings`; pass a logger, OCR connector or resource handler.
**`is not a supported wheel on this platform`** -- the OS is older than glibc 2.27 / macOS 13, or pip is older than 20.3: `python -m pip install --upgrade pip`**OCR, or text from an image, raises `GroupDocsParserException` naming `Microsoft.ML.OnnxRuntime.NativeMethods` / `DllNotFoundException` on macOS 13.0-13.2** -- OCR's ONNX Runtime library needs macOS 13.3 or newer; update macOS. Every other feature works on 13.0.
**`XType: com.apple.fonts is not accessible.` on stderr (macOS, in CI or a background service)** -- harmless: with no logged-in desktop session macOS reads the system font folders directly. Nothing to fix.
**`TypeLoadException`** -- reinstall: `pip install --force-reinstall groupdocs-parser-net`**Still stuck?** Post your question at https://forum.groupdocs.com/c/parser/ -- the development team responds directly.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.