list_confluence_spaces
List all Confluence spaces to discover available content. Returns space IDs, names, and keys for use with other tools. Ideal first step in a content discovery workflow.
Instructions
List all available Confluence spaces. Best used as the first step in a content discovery workflow. Returns space IDs, names, and keys that you can use with other tools. TIP: Use a higher limit (e.g., 100) on first call to get a comprehensive view of available spaces.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of spaces to return (default: 25) | |
| start | No | Starting index for pagination (default: 0) |
Implementation Reference
- src/handlers/space-handlers.ts:6-39 (handler)The main handler function for the 'list_confluence_spaces' tool. Calls ConfluenceClient.getConfluenceSpaces(), transforms results to a simplified format (id, name, key, status), and returns paginated JSON. Includes error handling with McpError.
export async function handleListConfluenceSpaces( client: ConfluenceClient, args: { limit?: number; start?: number } ): Promise<{ content: Array<{ type: "text"; text: string }>; }> { try { const spaces = await client.getConfluenceSpaces(args.limit, args.start); // Transform to minimal format const simplified = { results: spaces.results.map(space => ({ id: space.id, name: space.name, key: space.key, status: space.status })), next: spaces._links.next ? true : false }; return { content: [ { type: "text", text: JSON.stringify(simplified), }, ], }; } catch (error) { console.error("Error listing spaces:", error instanceof Error ? error.message : String(error)); throw new McpError( ErrorCode.InternalError, `Failed to list spaces: ${error instanceof Error ? error.message : String(error)}` ); } } - src/schemas/tool-schemas.ts:2-17 (schema)Input schema definition for 'list_confluence_spaces'. Describes the tool as listing all available Confluence spaces as a first step in content discovery. Accepts optional 'limit' (number, default 25) and 'start' (number, default 0) for pagination.
list_confluence_spaces: { description: "List all available Confluence spaces. Best used as the first step in a content discovery workflow. Returns space IDs, names, and keys that you can use with other tools. TIP: Use a higher limit (e.g., 100) on first call to get a comprehensive view of available spaces.", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Maximum number of spaces to return (default: 25)", }, start: { type: "number", description: "Starting index for pagination (default: 0)", }, }, }, }, - src/index.ts:196-201 (registration)Tool registration in the main server's CallToolRequestSchema handler. The tool name 'list_confluence_spaces' is matched in a switch statement, extracts limit/start from args, and delegates to handleListConfluenceSpaces().
switch (name) { // Space operations case "list_confluence_spaces": { const { limit, start } = (args || {}) as { limit?: number; start?: number }; return await handleListConfluenceSpaces(this.confluenceClient, { limit, start }); } - src/index.ts:120-131 (registration)Tool listing registration via ListToolsRequestSchema. Iterates over toolSchemas object (which includes 'list_confluence_spaces') to expose each tool's name, description, and inputSchema to the MCP protocol.
// Set up required MCP protocol handlers this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: Object.entries(toolSchemas).map(([key, schema]) => ({ name: key, description: schema.description, inputSchema: { type: "object", properties: schema.inputSchema.properties, ...(("required" in schema.inputSchema) ? { required: schema.inputSchema.required } : {}), }, })), })); - The underlying ConfluenceClient method 'getConfluenceSpaces()' that makes the actual HTTP GET request to /api/v2/spaces with limit/start params. Returns a PaginatedResponse<Space>.
// Space operations async getConfluenceSpaces(limit = 25, start = 0): Promise<PaginatedResponse<Space>> { if (!this.verified) { await this.verifyApiConnection(); this.verified = true; } const response = await this.v2Client.get('/spaces', { params: { limit, start } }); return response.data; }