Skip to main content
Glama

parse_pdf

Parse PDF files from local paths or URLs into JSON or Markdown for automated data extraction.

Instructions

Parses a PDF file and returns the extracted content in the specified format.

The function supports both local file paths and remote URLs as input sources. It extracts
the content from the PDF and formats it either as structured JSON or as a Markdown string.

:param source: The source of the PDF file to be parsed.
    - If it is a string starting with "http://" or "https://", it will be treated as a remote URL.
    - Otherwise, it will be treated as a local file path (absolute path recommended, e.g. "/Users/yourname/file.pdf").
:param format: The desired format for the parsed output. Supports:
    - "json": Returns the extracted content as a dictionary.
    - "markdown": Returns the extracted content as a Markdown-formatted string.
:return: The extracted content in the specified format (JSON dictionary or Markdown string).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes
formatNojson

Implementation Reference

  • The parse_pdf async function that implements the tool logic: validates format, calls client.parse_pro.parse(source, format), and returns the result as a JSON string if needed.
    async def parse_pdf(source: str, format: Literal["json", "markdown"] = "json"):
        """
        Parses a PDF file and returns the extracted content in the specified format.
    
        The function supports both local file paths and remote URLs as input sources. It extracts
        the content from the PDF and formats it either as structured JSON or as a Markdown string.
    
        :param source: The source of the PDF file to be parsed.
            - If it is a string starting with "http://" or "https://", it will be treated as a remote URL.
            - Otherwise, it will be treated as a local file path (absolute path recommended, e.g. "/Users/yourname/file.pdf").
        :param format: The desired format for the parsed output. Supports:
            - "json": Returns the extracted content as a dictionary.
            - "markdown": Returns the extracted content as a Markdown-formatted string.
        :return: The extracted content in the specified format (JSON dictionary or Markdown string).
        """
        if format not in ["json", "markdown"]:
            raise ValueError(f"Unsupported output format: {format}")
    
        res = await client.parse_pro.parse(
            source=source,
            format=format,
        )
        if not isinstance(res, str):
            res = json.dumps(res, ensure_ascii=False)
        return res
  • The @mcp.tool() decorator registers parse_pdf as an MCP tool on the FastMCP server instance.
    @mcp.tool()
  • The function signature and docstring define the input schema: source (str, URL or file path) and format (Literal "json" or "markdown"). The function raises ValueError for unsupported formats.
    """
    Parses a PDF file and returns the extracted content in the specified format.
    
    The function supports both local file paths and remote URLs as input sources. It extracts
    the content from the PDF and formats it either as structured JSON or as a Markdown string.
    
    :param source: The source of the PDF file to be parsed.
        - If it is a string starting with "http://" or "https://", it will be treated as a remote URL.
        - Otherwise, it will be treated as a local file path (absolute path recommended, e.g. "/Users/yourname/file.pdf").
    :param format: The desired format for the parsed output. Supports:
        - "json": Returns the extracted content as a dictionary.
        - "markdown": Returns the extracted content as a Markdown-formatted string.
    :return: The extracted content in the specified format (JSON dictionary or Markdown string).
    """
  • The main() function checks for the NETMIND_API_TOKEN environment variable and runs the MCP server via stdio transport. This is the entry point that launches the tool server.
    def main():
        if not NETMIND_API_TOKEN:
            print(
                "Error: NETMIND_API_TOKEN environment variable is required",
                file=sys.stderr,
            )
            sys.exit(1)
        mcp.run(transport='stdio')
    
    
    if __name__ == "__main__":
        main()
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full behavioral burden. It describes basic functionality (content extraction, format options) but does not mention limitations like password-protected PDFs, file size limits, or error handling. This is adequate but not thorough.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the main purpose. However, it uses a docstring style with 'param' and 'return' labels, which adds some verbosity but remains clear and organized.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description explains the return type (JSON dictionary or Markdown string) but lacks detail on the structure of the JSON or the content of the Markdown. It also does not cover edge cases or error scenarios, leaving some gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description adds significant meaning to both parameters. For 'source', it explains URL vs local file detection; for 'format', it clarifies allowed values and return types. This fully compensates for the schema's lack of descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool parses a PDF and returns extracted content in specified format. It uses specific verb 'parse' and resource 'PDF', and there are no sibling tools, so differentiation is not an issue.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly explains when to use the tool and how to specify the source (local path vs URL via 'http' or 'https' prefix). It provides clear context on input types, which is comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/protagolabs/Netmind-Parse-PDF-MCP'

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