Skip to main content
Glama
j-shelfwood

Obsidian Local REST API MCP Server

by j-shelfwood

list_directory

Browse directory contents with pagination to manage large folders and avoid context overflow in Obsidian vaults.

Instructions

List directory contents with pagination to prevent context overflow. Shows immediate contents by default.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoDirectory path to list.
recursiveNoInclude subdirectories recursively
limitNoMaximum items to return
offsetNoPagination offset

Implementation Reference

  • The core handler function that implements the list_directory tool logic by constructing query parameters and making an HTTP GET request to the Obsidian REST API endpoint `/vault/directory`.
    async listDirectory(path: string = ".", recursive: boolean = false, limit: number = 50, offset: number = 0) {
      const params = new URLSearchParams({
        path,
        recursive: recursive.toString(),
        limit: limit.toString(),
        offset: offset.toString(),
      });
      return this.request(`/vault/directory?${params}`);
    }
  • src/index.ts:276-287 (registration)
    Registers the list_directory tool in the MCP server's tool list, including its name, description, and detailed input schema for parameters.
      name: "list_directory",
      description: "List directory contents with pagination to prevent context overflow. Shows immediate contents by default.",
      inputSchema: {
        type: "object",
        properties: {
          path: { type: "string", description: "Directory path to list", default: "." },
          recursive: { type: "boolean", description: "Include subdirectories recursively", default: false },
          limit: { type: "number", description: "Maximum items to return", default: 50 },
          offset: { type: "number", description: "Pagination offset", default: 0 },
        },
      },
    },
  • Dispatch handler in the MCP CallToolRequestHandler that routes 'list_directory' tool calls to the ObsidianApiClient.listDirectory method with type-cast arguments.
    case "list_directory":
      result = await this.client.listDirectory(
        args?.path as string,
        args?.recursive as boolean,
        args?.limit as number,
        args?.offset as number
      );
      break;
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context about pagination ('to prevent context overflow') and default behavior ('Shows immediate contents by default'), which aren't in the schema. However, it doesn't cover aspects like error handling, permissions needed, rate limits, or what happens with invalid paths. For a tool with no annotations, this is adequate but leaves 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 highly concise with two sentences that efficiently convey key information: the core function and important behavioral traits. It's front-loaded with the main purpose and avoids any redundant or unnecessary wording. Every sentence earns its place by adding value beyond the tool name.

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 (4 parameters, no output schema, no annotations), the description is minimally complete. It covers the purpose and key behavior (pagination, default scope) but lacks details on return values, error cases, or integration with siblings. Without an output schema, it should ideally hint at the response format, but it's adequate for basic 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?

Schema description coverage is 100%, so the schema fully documents all 4 parameters. The description adds no specific parameter semantics beyond what's in the schema (e.g., it doesn't explain 'path' format or 'limit' constraints further). With high schema coverage, the baseline is 3, and the description doesn't compensate with extra details, but it doesn't detract either.

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 as 'List directory contents' with specific functionality ('with pagination to prevent context overflow') and scope ('Shows immediate contents by default'). It distinguishes from siblings like 'list_notes' by focusing on directory contents rather than notes, though it doesn't explicitly name alternatives. This is clear but lacks explicit sibling differentiation.

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 context through 'with pagination to prevent context overflow' and 'Shows immediate contents by default', suggesting it's for browsing directories with control over output size. However, it doesn't explicitly state when to use this tool versus alternatives like 'list_notes' or 'search_vault', nor does it provide exclusions or prerequisites. Usage is implied but not fully articulated.

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/j-shelfwood/obsidian-local-rest-api-mcp'

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