Skip to main content
Glama
Sofias-ai

SharePoint MCP Server

by Sofias-ai

List_SharePoint_Documents

Retrieve a comprehensive list of all documents within a specified SharePoint folder using this tool, ensuring efficient document management and access.

Instructions

List all documents in a specified SharePoint folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folder_nameYes

Implementation Reference

  • MCP handler function for the 'List_SharePoint_Documents' tool. Registers the tool and delegates execution to the list_documents helper function from resources.py.
    @mcp.tool(name="List_SharePoint_Documents", description="List all documents in a specified SharePoint folder")
    async def list_documents_tool(folder_name: str):
        """List all documents in a specified SharePoint folder"""
        return list_documents(folder_name)
  • Core helper function that lists documents in the specified SharePoint folder by invoking the generic _load_sp_items with item_type='files'.
    def list_documents(folder_name: str) -> List[Dict[str, Any]]:
        """List all documents in a specified folder"""
        logger.info(f"Listing documents in folder: {folder_name}")
        return _load_sp_items(_get_sp_path(folder_name), "files")
  • Generic helper that loads SharePoint folders or files (used for documents with 'files'), retrieves properties like name, url, size, timestamps.
    def _load_sp_items(path: str, item_type: str) -> List[Dict[str, Any]]:
        """Generic function to load folders or files from SharePoint"""
        folder = sp_context.web.get_folder_by_server_relative_url(path)
        items = getattr(folder, item_type)
        props = ["ServerRelativeUrl", "Name", "TimeCreated", "TimeLastModified"] + (["Length"] if item_type == "files" else [])
        sp_context.load(items, props)
        sp_context.execute_query()
        
        return [{
            "name": item.name,
            "url": item.properties.get("ServerRelativeUrl"),
            **({"size": item.properties.get("Length")} if item_type == "files" else {}),
            "created": item.properties.get("TimeCreated").isoformat() if item.properties.get("TimeCreated") else None,
            "modified": item.properties.get("TimeLastModified").isoformat() if item.properties.get("TimeLastModified") else None
        } for item in items]
  • Helper to construct the full SharePoint server-relative path from folder name, prepending the document library.
    def _get_sp_path(sub_path: Optional[str] = None) -> str:
        """Create a properly formatted SharePoint path"""
        return f"{SHP_DOC_LIBRARY}/{sub_path or ''}".rstrip('/')
  • The @mcp.tool decorator that registers 'List_SharePoint_Documents' with MCP, including name and description.
    @mcp.tool(name="List_SharePoint_Documents", description="List all documents in a specified SharePoint folder")
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but only states the basic operation. It doesn't mention whether this is a read-only operation, what permissions are required, how results are returned (pagination, format), rate limits, or error conditions. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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, clear sentence that efficiently communicates the core functionality without unnecessary words. It's appropriately sized for a simple list operation and front-loads the essential information.

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

Completeness2/5

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

Given the lack of annotations, 0% schema description coverage, and no output schema, the description is insufficiently complete. A list operation typically needs information about result format, pagination, sorting, filtering options, and error handling - none of which are addressed. The description only covers the most basic 'what' without the 'how' or 'what to expect.'

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

Parameters2/5

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

With 0% schema description coverage for the single parameter 'folder_name', the description adds no semantic information about what this parameter represents, valid formats, examples, or constraints. The schema only provides a title 'Folder Name' with no description, so the tool definition lacks essential parameter documentation.

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 action ('List all documents') and resource ('in a specified SharePoint folder'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'List_SharePoint_Folders' or 'Get_Document_Content', which would require more specific scope clarification.

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 like 'List_SharePoint_Folders' for folders or 'Get_Document_Content' for document details. There's no mention of prerequisites, limitations, or appropriate contexts for selecting this tool over siblings.

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

Related 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/Sofias-ai/mcp-sharepoint'

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