Skip to main content
Glama

parse_document

Extract plain text from PDF or DOCX files to enable automated test scenario generation from user stories in development workflows.

Instructions

Read a PDF or DOCX and return plain text.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • server.py:18-31 (handler)
    The main handler function for the 'parse_document' tool, registered via @mcp.tool() decorator. It extracts plain text from PDF or DOCX files using pypdf or docx libraries and stores it in an in-memory dictionary.
    @mcp.tool()
    def parse_document(file_path: str) -> str:
        """Read a PDF or DOCX and return plain text."""
        if file_path.endswith(".pdf"):
            reader = pypdf.PdfReader(file_path)
            text = " ".join([page.extract_text() or "" for page in reader.pages])
        elif file_path.endswith(".docx"):
            doc = docx.Document(file_path)
            text = " ".join([p.text for p in doc.paragraphs])
        else:
            raise ValueError("Only PDF and DOCX supported")
        
        parsed_docs[file_path] = text
        return text
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool reads files and returns plain text, but lacks details on error handling (e.g., invalid file paths, unsupported formats), performance (e.g., file size limits, processing time), or side effects (e.g., whether the file is modified). For a tool with no annotations, this is a significant gap in transparency.

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

Conciseness5/5

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

The description is a single, efficient sentence: 'Read a PDF or DOCX and return plain text.' It is front-loaded with the core action and outcome, with zero wasted words. Every part of the sentence contributes essential information, making it highly concise and well-structured.

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 the tool's moderate complexity (reading documents) and the presence of an output schema (which likely describes the plain text return), the description is minimally adequate. It covers the basic purpose and input type but lacks details on usage context, behavioral traits, and parameter specifics. With no annotations and incomplete parameter guidance, it meets the baseline but has clear gaps.

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

Parameters3/5

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

The input schema has 1 parameter with 0% description coverage, so the schema provides no semantic details. The description implies the parameter is a file path for PDF or DOCX files, adding some context beyond the schema's bare 'File Path' title. However, it doesn't specify format requirements (e.g., absolute vs. relative paths, supported extensions), so it partially compensates but not fully.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Read a PDF or DOCX and return plain text.' It specifies the verb ('Read'), resource ('PDF or DOCX'), and outcome ('return plain text'), making the function unambiguous. However, it doesn't explicitly differentiate from the sibling tool 'export_scenarios', which might be a related but distinct operation, so it doesn't reach the highest score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention the sibling tool 'export_scenarios' or any other potential tools for document processing, nor does it specify prerequisites like file accessibility or supported formats beyond PDF/DOCX. This leaves the agent without context for tool selection.

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/debabhinav1-hub/mcptestgenwithClaude'

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