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
| Name | Required | Description | Default |
|---|---|---|---|
| cql | Yes | CQL query string | |
| limit | No | Number 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'], }, },
- src/index.ts:43-57 (schema)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'], },
- src/index.ts:231-249 (handler)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), }, ], }; }
- src/index.ts:105-127 (handler)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, }; } }
- src/index.ts:214-224 (helper)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', }, }; }