list_spaces
Generate a filtered list of accessible Confluence spaces with pagination support. Configure results limit and cursor for efficient space management.
Instructions
List all accessible Confluence spaces (filtered by allowed spaces)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cursor | No | Cursor for pagination (from _links.next) | |
| limit | No | Maximum results (default: 50) |
Implementation Reference
- src/index.ts:374-389 (handler)MCP tool handler for 'list_spaces' that extracts input parameters, calls ConfluenceClient.listSpaces(), and returns the JSON-formatted result.case 'list_spaces': { const { limit = 50, cursor } = args as { limit?: number; cursor?: string; }; const spaces = await confluenceClient.listSpaces(limit, cursor); return { content: [ { type: 'text', text: JSON.stringify(spaces, null, 2) } ] }; }
- src/index.ts:165-177 (schema)Input schema definition for the list_spaces tool, specifying optional limit and cursor parameters.inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum results (default: 50)', default: 50 }, cursor: { type: 'string', description: 'Cursor for pagination (from _links.next)' } }
- src/index.ts:162-179 (registration)Registration of the list_spaces tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'list_spaces', description: 'List all accessible Confluence spaces (filtered by allowed spaces)', inputSchema: { type: 'object', properties: { limit: { type: 'number', description: 'Maximum results (default: 50)', default: 50 }, cursor: { type: 'string', description: 'Cursor for pagination (from _links.next)' } } } },
- src/confluence-client.ts:296-318 (helper)Helper method in ConfluenceClient that implements the core listSpaces logic: API call to /spaces, filters by allowed spaces, caches results, and returns paginated response.async listSpaces(limit = 50, cursor?: string): Promise<PaginatedResult<ConfluenceSpace>> { const params: any = { limit }; if (cursor) { params.cursor = cursor; } const response: AxiosResponse<PaginatedResult<ConfluenceSpace>> = await this.client.get('/spaces', { params }); const filteredResults = response.data.results.filter(space => validateSpaceAccess(space.key, this.config.allowedSpaces) ); // Cache the spaces filteredResults.forEach(space => this.cacheSpace(space)); return { ...response.data, results: filteredResults, size: filteredResults.length }; }