Skip to main content
Glama
KS-GEN-AI

Confluence Communication Server

execute_cql_search

Search Confluence pages using CQL queries to find specific content and retrieve results for information access.

Instructions

Execute a CQL query on Confluence to search pages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cqlYesCQL query string
limitNoNumber of results to return

Implementation Reference

  • src/index.ts:40-58 (registration)
    Registration of the 'execute_cql_search' tool in the listTools handler, including name, description, and input schema.
    {
      name: 'execute_cql_search',
      description: 'Execute a CQL query on Confluence to search pages',
      inputSchema: {
        type: 'object',
        properties: {
          cql: {
            type: 'string',
            description: 'CQL query string',
          },
          limit: {
            type: 'integer',
            description: 'Number of results to return',
            default: 10,
          },
        },
        required: ['cql'],
      },
    },
  • Input schema definition for the 'execute_cql_search' tool, specifying CQL query and optional limit.
    inputSchema: {
      type: 'object',
      properties: {
        cql: {
          type: 'string',
          description: 'CQL query string',
        },
        limit: {
          type: 'integer',
          description: 'Number of results to return',
          default: 10,
        },
      },
      required: ['cql'],
    },
  • MCP tool call handler for 'execute_cql_search': extracts parameters, validates, calls executeCQL, and formats response.
    case 'execute_cql_search': {
      const cql = String(request.params.arguments?.cql);
      const limit = Number(request.params.arguments?.limit ?? 10);
    
      if (!cql) {
        throw new Error('CQL query is required');
      }
    
      const response = await executeCQL(cql, limit);
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(response, null, 2),
          },
        ],
      };
    }
  • Core handler function that executes the CQL search via Axios GET to Confluence API, handles errors.
    async function executeCQL(cql: string, limit: number): Promise<any> {
      try {
        const params = {
          cql,
          limit,
        };
    
        const response = await axios.get(
          `${CONFLUENCE_URL}/wiki/rest/api/content/search`,
          {
            // Updated URL
            headers: getAuthHeaders().headers,
            params,
          },
        );
    
        return response.data;
      } catch (error: any) {
        return {
          error: error.response ? error.response.data : error.message,
        };
      }
    }
  • Helper function to generate authentication headers using Confluence API credentials, used in executeCQL.
    function getAuthHeaders(): AxiosRequestConfig<any> {
      const authHeader = `Basic ${Buffer.from(
        `${CONFLUENCE_API_MAIL}:${CONFLUENCE_API_KEY}`,
      ).toString('base64')}`;
      return {
        headers: {
          Authorization: authHeader,
          'Content-Type': 'application/json',
        },
      };
    }

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/KS-GEN-AI/confluence-mcp-server'

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