Skip to main content
Glama
ttpears

BookStack MCP Server

by ttpears

get_attachments

Retrieve files and links from BookStack with filtering and sorting options to organize documentation attachments.

Instructions

List attachments (files and links) with filtering and sorting

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
offsetNoPagination offset
countNoNumber of results to return
sortNoSort field
filterNoFilter criteria

Implementation Reference

  • The backend client method 'getAttachments' that performs the API request.
    async getAttachments(options?: {
      offset?: number;
      count?: number;
      sort?: string;
      filter?: Record<string, any>;
    }): Promise<ListResponse<Attachment>> {
      const params: any = {
        offset: options?.offset || 0,
        count: Math.min(options?.count || 50, 500)
      };
      
      if (options?.sort) params.sort = options.sort;
      if (options?.filter) params.filter = JSON.stringify(options.filter);
      
      const response = await this.client.get('/attachments', { params });
      const data = response.data;
      
      return {
        ...data,
        data: data.data.map((attachment: Attachment) => ({
          ...attachment,
          page_url: `${this.baseUrl}/books/${Math.floor(attachment.uploaded_to / 1000)}/page/${attachment.uploaded_to}`,
          direct_link: `[${attachment.name}](${this.baseUrl}/attachments/${attachment.id})`
        }))
      };
    }
  • src/index.ts:403-425 (registration)
    MCP tool registration for 'get_attachments' and the handler implementation that calls the client.
    server.registerTool(
      "get_attachments",
      {
        title: "List Attachments",
        description: "List attachments (files and links) with filtering and sorting",
        inputSchema: {
          offset: z.coerce.number().default(0).describe("Pagination offset"),
          count: z.coerce.number().max(500).default(50).describe("Number of results to return"),
          sort: z.string().optional().describe("Sort field"),
          filter: z.record(z.any()).optional().describe("Filter criteria")
        }
      },
      async (args) => {
        const attachments = await client.getAttachments({
          offset: args.offset,
          count: args.count,
          sort: args.sort,
          filter: args.filter
        });
        return {
          content: [{ type: "text", text: JSON.stringify(attachments, null, 2) }]
        };
      }
  • Input schema definition for the 'get_attachments' tool.
    inputSchema: {
      offset: z.coerce.number().default(0).describe("Pagination offset"),
      count: z.coerce.number().max(500).default(50).describe("Number of results to return"),
      sort: z.string().optional().describe("Sort field"),
      filter: z.record(z.any()).optional().describe("Filter criteria")
    }

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/ttpears/bookstack-mcp'

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