Skip to main content
Glama
omniwaifu

Pydantic AI Documentation Server

by omniwaifu

get_document_by_path

Retrieve Pydantic AI documentation by specifying the file path relative to the documentation root, returning the parsed document content when available.

Instructions

Retrieves a specific document by its path relative to the Pydantic documentation root (e.g., 'usage/models.md'). Returns the ParsedDocument if found, otherwise None.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The `get_document_by_path` tool handler, implemented in `server.py` using `FastMCP`. It validates the path, resolves it to a file, and parses it using `parse_markdown_file`.
    @app.tool()
    async def get_document_by_path(path: str) -> Optional[ParsedDocument]:
        """
        Retrieves a specific document by its path relative to the Pydantic documentation root (e.g., 'usage/models.md').
        Returns the ParsedDocument if found, otherwise None.
        """
        logger.info(f"Attempting to get document by path: {path}")
        try:
            pydantic_docs_root = get_pydantic_docs_path()
            full_file_path = (pydantic_docs_root / path).resolve()
    
            if not str(full_file_path).startswith(str(pydantic_docs_root.resolve())):
                logger.warning(
                    f"Path traversal attempt or invalid path for get_document_by_path: {path}"
                )
                return None
    
            if not full_file_path.is_file():
                logger.info(
                    f"Document not found or not a file at path: {path} (resolved: {full_file_path})"
                )
                return None
    
            document = parse_markdown_file(
                file_path=full_file_path, docs_base_dir=pydantic_docs_root
            )
    
            if document:
                logger.info(f"Successfully retrieved document: {document.path}")
                return document
            else:
                logger.warning(
                    f"Failed to parse document at path: {path} (resolved: {full_file_path})"
                )
                return None
    
        except Exception as e:
            logger.error(
                f"Error in get_document_by_path for path '{path}': {e}", exc_info=True
            )
            return None
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's a read operation ('Retrieves'), specifies the return type ('ParsedDocument if found, otherwise None'), and mentions the path format ('relative to the Pydantic documentation root'). However, it doesn't cover error handling, performance, or authentication needs.

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?

Two sentences with zero waste: the first defines the tool's purpose and parameter, the second specifies the return behavior. It's front-loaded with the core functionality and appropriately sized for a simple retrieval tool.

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

Completeness4/5

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

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is largely complete: it covers purpose, parameter semantics, and return values. However, it lacks details on error cases beyond 'None' and doesn't mention if there are rate limits or permissions required.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining the 'path' parameter as 'relative to the Pydantic documentation root' and provides an example ('usage/models.md'), which clarifies the expected format beyond the schema's basic string type.

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 specific action ('Retrieves'), resource ('a specific document'), and mechanism ('by its path relative to the Pydantic documentation root'). It distinguishes from siblings by focusing on path-based retrieval rather than listing topics/changelogs or updating documentation.

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

Usage Guidelines3/5

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

The description implies usage when you need a document by its path (e.g., 'usage/models.md'), but provides no explicit guidance on when to use this versus alternatives like list_topics or update_documentation. The context is clear but lacks sibling differentiation or exclusions.

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/omniwaifu/pydantic-ai-docs-server'

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