Skip to main content
Glama
Sofias-ai

SharePoint MCP Server

by Sofias-ai

List_SharePoint_Folders

List folders in a specified SharePoint directory or root using the SharePoint MCP Server. Simplify folder navigation and organization by retrieving folder details directly.

Instructions

List folders in the specified SharePoint directory or root if not specified

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parent_folderNo

Implementation Reference

  • MCP tool handler: decorated function that executes the tool by delegating to list_folders helper.
    @mcp.tool(name="List_SharePoint_Folders", description="List folders in the specified SharePoint directory or root if not specified")
    async def list_folders_tool(parent_folder: Optional[str] = None):
        """List folders in the specified SharePoint directory or root if not specified"""
        return list_folders(parent_folder)
  • Primary helper function implementing the folder listing logic by calling generic _load_sp_items.
    def list_folders(parent_folder: Optional[str] = None) -> List[Dict[str, Any]]:
        """List folders in the specified directory or root if not specified"""
        logger.info(f"Listing folders in {parent_folder or 'root directory'}")
        return _load_sp_items(_get_sp_path(parent_folder), "folders")
  • Core generic helper that loads SharePoint folders or files with metadata properties using office365 API.
    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 SharePoint paths from library and subpath.
    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('/')
  • Tool registration decorator specifying name and description.
    @mcp.tool(name="List_SharePoint_Folders", description="List folders in the specified SharePoint directory or root if not specified")
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 mentions the action ('List folders') and default behavior ('root if not specified'), but fails to describe critical aspects such as pagination, sorting, filtering, error handling, or authentication requirements. For a list operation with no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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 that front-loads the core action ('List folders') and includes essential details (location and default). There is no wasted verbiage, making it appropriately sized for the tool's simplicity.

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 tool's moderate complexity (listing folders in a SharePoint context), no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks information on return values (e.g., structure of folder list), error cases, permissions, or integration with sibling tools, leaving the agent with insufficient context for reliable use.

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 description adds some meaning by explaining that the parameter specifies a 'SharePoint directory' and defaults to 'root if not specified', which clarifies the optional nature and purpose of 'parent_folder'. However, with 0% schema description coverage and only 1 parameter, this provides basic context but doesn't fully compensate for the lack of schema details (e.g., format of the string).

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 verb ('List') and resource ('folders in the specified SharePoint directory'), making the purpose understandable. It distinguishes from siblings like List_SharePoint_Documents by specifying folders vs. documents, though it doesn't explicitly mention this distinction. However, it lacks full sibling differentiation (e.g., vs. Get_Document_Content).

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 by stating 'root if not specified', suggesting it can be used for both specific directories and the root, but it doesn't provide explicit guidance on when to use this tool over alternatives like List_SharePoint_Documents or other siblings. No when-not-to-use or prerequisite information is included.

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