Skip to main content
Glama
simplifyaimm

MCP Demo - Document Search Server

by simplifyaimm

list_documents

Retrieve a complete list of indexed documents with their word counts.

Instructions

List every document currently in the index, along with its word count.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main MCP tool handler for list_documents. Decorated with @mcp.tool(), it calls _index.list_documents() and formats the output as a human-readable string listing each document's filename and word count.
    @mcp.tool()
    def list_documents() -> str:
        """
        List every document currently in the index, along with its word count.
        """
        docs = _index.list_documents()
    
        if not docs:
            return (
                "No documents found. Add .txt or .md files to the documents/ directory "
                "and restart the server."
            )
    
        lines = [f"Indexed {len(docs)} document(s) from {DOCUMENTS_DIR}:\n"]
        for d in docs:
            lines.append(f"  - {d['filename']}  ({d['word_count']} words)")
    
        return "\n".join(lines)
  • The DocumentIndex.list_documents() helper method that returns a list of dicts with 'filename' and 'word_count' for each indexed document, sorted alphabetically by filename.
    def list_documents(self) -> list[dict[str, Any]]:
        return [
            {"filename": name, "word_count": len(text.split())}
            for name, text in sorted(self.documents.items())
        ]
  • server/main.py:68-68 (registration)
    The tool is registered via the @mcp.tool() decorator on the list_documents function in server/main.py. FastMCP automatically registers it as an available MCP tool.
    @mcp.tool()
  • The return type of list_documents is list[dict[str, Any]], where each dict has keys 'filename' (str) and 'word_count' (int). No input parameters are needed.
    def list_documents(self) -> list[dict[str, Any]]:
        return [
            {"filename": name, "word_count": len(text.split())}
            for name, text in sorted(self.documents.items())
        ]
Behavior4/5

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

With no annotations, the description carries the full burden. It accurately describes a read-only operation that returns all documents and word counts. No hidden behaviors are mentioned, but for this straightforward task, it is sufficient.

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 extremely concise, using a single sentence that conveys the purpose and output. No wasted words, front-loaded with the action.

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

Completeness5/5

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

Given the tool's simplicity (no parameters, output schema exists), the description is complete. It explains what the tool does and what it returns, leaving no ambiguity for selection or invocation.

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?

The tool has no parameters, so schema coverage is 100% trivially. The description adds no parameter information, but baseline is 4 for zero parameters. The description aligns with the tool's function.

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 lists every document with word count. The verb 'list' and resource 'documents' are specific. While siblings exist (get_document, search_documents), the description implies a full index listing, but does not explicitly differentiate.

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?

No explicit guidance on when to use this tool versus siblings. The description 'list every document' implies it is for unfiltered retrieval, but does not mention alternatives or situations to avoid. This is adequate for a simple tool with no parameters.

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/simplifyaimm/mcp-demo'

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