Skip to main content
Glama

get_space_members

Retrieve a list of members with access to an Anytype space, including their IDs, names, and permission levels. Use this tool to view collaborators and manage space permissions through paginated results.

Instructions

Retrieves a list of all members who have access to a specified Anytype space. This tool provides information about each member including their ID, name, and access level. Results are paginated for spaces with many members. Use this tool when you need to understand who has access to a space or manage collaboration permissions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
space_idYesSpace ID to get members from
offsetNoPagination offset
limitNoNumber of results per page (1-1000)

Implementation Reference

  • Handler function that validates pagination parameters, makes authenticated GET request to Anytype API endpoint `/spaces/${space_id}/members`, and returns formatted JSON response or handles errors.
    async ({ space_id, offset, limit }) => { try { // Validate limit const validLimit = Math.max(1, Math.min(1000, limit)); const response = await this.makeRequest( "get", `/spaces/${space_id}/members`, null, { offset, limit: validLimit } ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } }
  • Zod input schema defining parameters for the get_space_members tool: required space_id, optional offset (default 0), optional limit (default 100).
    { space_id: z.string().describe("Space ID to get members from"), offset: z.number().optional().default(0).describe("Pagination offset"), limit: z .number() .optional() .default(100) .describe("Number of results per page (1-1000)"), },
  • src/index.ts:338-372 (registration)
    MCP server tool registration call for 'get_space_members', including description, input schema, and inline handler function.
    "get_space_members", "Retrieves a list of all members who have access to a specified Anytype space. This tool provides information about each member including their ID, name, and access level. Results are paginated for spaces with many members. Use this tool when you need to understand who has access to a space or manage collaboration permissions.", { space_id: z.string().describe("Space ID to get members from"), offset: z.number().optional().default(0).describe("Pagination offset"), limit: z .number() .optional() .default(100) .describe("Number of results per page (1-1000)"), }, async ({ space_id, offset, limit }) => { try { // Validate limit const validLimit = Math.max(1, Math.min(1000, limit)); const response = await this.makeRequest( "get", `/spaces/${space_id}/members`, null, { offset, limit: validLimit } ); return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return this.handleApiError(error); } } );
  • Helper method used by the handler to make authenticated HTTP requests to the Anytype API using axios, with Bearer token from appKey.
    private async makeRequest( method: "get" | "post" | "delete", endpoint: string, data?: any, params?: any ) { try { const config = { method, url: `${this.apiBaseUrl}${endpoint}`, headers: { Authorization: `Bearer ${this.appKey}`, "Content-Type": "application/json", }, data, params, }; return await axios(config); } catch (error) { console.error(`API request error: ${error}`); throw error; } }
  • Helper method called by the handler to standardize error handling and response formatting for API errors.
    private handleApiError(error: any) { let errorMessage = "Unknown API error"; // Handle network errors first if (error.code === "ECONNREFUSED") { errorMessage = "Anytype is not running. Launch it and try again."; return this.printError(error, errorMessage); } // Handle API response errors const status = error.response?.status; const apiError = error.response?.data?.error; switch (status) { case 400: errorMessage = apiError?.message || "Bad request"; if (apiError?.code === "validation_error") { errorMessage += ". Invalid parameters: " + (apiError.details ?.map((d: { field: string }) => d.field) .join(", ") || "unknown fields"); } break; case 401: errorMessage = "Unauthorized - Check your App Key"; break; case 403: errorMessage = "Forbidden - You don't have permission for this operation"; break; case 404: errorMessage = "Not found - The requested resource doesn't exist"; break; case 429: errorMessage = "Rate limit exceeded - Try again later"; break; case 500: errorMessage = "Internal server error - Contact Anytype support"; break; default: if (status >= 500 && status < 600) { errorMessage = `Server error (${status}) - Try again later`; } else if (apiError?.message) { errorMessage = apiError.message; } break; } return this.printError(apiError, errorMessage); } private printError(error: any, errorMessage: any) { return { content: [ { type: "text" as const, text: `Error: ${errorMessage}\n\n${error}`, }, ], isError: true, }; }

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/Qwinty/anytype-mcp'

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