Skip to main content
Glama
KS-GEN-AI

Confluence Communication Server

execute_cql_search

Run CQL queries on Confluence to search and retrieve pages, specifying the query string and results limit for targeted content discovery.

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

  • Core handler function that executes the CQL query against Confluence API using axios.get, handles errors, and returns results.
    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, }; } }
  • MCP CallToolRequestSchema handler case that validates input, calls executeCQL, and formats response as MCP content.
    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), }, ], }; }
  • src/index.ts:40-58 (registration)
    Registers the execute_cql_search tool in the ListTools response, 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'], }, },
  • Defines the input schema for the execute_cql_search tool, specifying cql as required string and optional limit integer.
    inputSchema: { type: 'object', properties: { cql: { type: 'string', description: 'CQL query string', }, limit: { type: 'integer', description: 'Number of results to return', default: 10, }, }, required: ['cql'], },
  • Helper function to generate authentication headers using Basic Auth from environment variables, 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', }, };

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

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