Skip to main content
Glama
Olson3R
by Olson3R

get_space_by_key

Retrieve detailed information about a specific Confluence space using its unique key. Ideal for managing and organizing Confluence spaces efficiently.

Instructions

Get detailed information about a specific Confluence space by key

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spaceKeyYesSpace key

Implementation Reference

  • MCP tool handler for 'get_space_by_key': extracts spaceKey argument, calls ConfluenceClient.getSpaceByKey(), and returns the space object as formatted JSON text content.
    case 'get_space_by_key': {
      const { spaceKey } = args as {
        spaceKey: string;
      };
      
      const space = await confluenceClient.getSpaceByKey(spaceKey);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(space, null, 2)
          }
        ]
      };
    }
  • Tool schema definition including name, description, and input schema requiring 'spaceKey' string.
    {
      name: 'get_space_by_key',
      description: 'Get detailed information about a specific Confluence space by key',
      inputSchema: {
        type: 'object',
        properties: {
          spaceKey: {
            type: 'string',
            description: 'Space key'
          }
        },
        required: ['spaceKey']
      }
    },
  • Core implementation of getSpaceByKey in ConfluenceClient: validates space access, checks/uses cache, paginates listSpaces to find matching space by key, handles caching, and returns ConfluenceSpace.
    async getSpaceByKey(spaceKey: string): Promise<ConfluenceSpace> {
      if (!validateSpaceAccess(spaceKey, this.config.allowedSpaces)) {
        throw new Error(`Access denied to space: ${spaceKey}`);
      }
    
      // Check cache first
      if (this.isSpaceCacheValid(spaceKey)) {
        const cachedSpace = this.spaceCache.get(spaceKey);
        if (cachedSpace) {
          return cachedSpace;
        }
      }
    
      // Search through all pages using cursor-based pagination
      let cursor: string | undefined;
      let found = false;
      let space: ConfluenceSpace | undefined;
      
      do {
        const spaces = await this.listSpaces(100, cursor);
        space = spaces.results.find(s => s.key === spaceKey);
        
        if (space) {
          found = true;
          break;
        }
        
        // Extract cursor from _links.next if available
        cursor = undefined;
        if (spaces._links?.next) {
          const nextUrl = new URL(spaces._links.next);
          cursor = nextUrl.searchParams.get('cursor') || undefined;
        }
      } while (cursor);
      
      if (!found || !space) {
        throw new Error(`Space not found: ${spaceKey}`);
      }
      
      return space;
    }
Install Server

Other Tools

Related 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/Olson3R/confluence-mcp'

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