Skip to main content
Glama
aaronsb

Confluence MCP Server

search_confluence_pages

Search Confluence pages using simple text or CQL queries. Filter results by space, content type, and metadata. Get page IDs, titles, URLs, and excerpts with highlighted search terms.

Instructions

Search across Confluence pages using simple text or CQL (Confluence Query Language).

Query Types:

  1. Simple Text Search:

    • Just provide the search term directly (e.g., "documentation")

    • The system automatically wraps it in proper CQL syntax

  2. Advanced CQL Search:

    • Must include "type =" to signal raw CQL usage

    • Examples:

      • type = "page" AND text ~ "project"

      • type = "page" AND space.key = "TEAM"

      • type = "page" AND created >= "2024-01-01"

Search Capabilities:

  • Full text search across all pages

  • Space-specific searches

  • Content type filtering

  • Metadata-based filtering

CQL Operators (for advanced queries):

  • ~ : contains

  • = : equals

  • != : not equals

  • AND, OR : combine conditions

  • () : group conditions

  • = <= : date comparisons

  • IN : multiple values

Common Search Patterns:

  • Finding pages in specific space: type = "page" AND space.key = "SPACENAME" AND text ~ "searchterm"

  • Finding recent pages: type = "page" AND created >= "2024-01-01" AND text ~ "searchterm"

  • Finding pages by title: type = "page" AND title ~ "exactname"

  • Finding pages by label: type = "page" AND label = "labelname"

Response includes:

  • Page ID, title, and type

  • Space information

  • URL to the page

  • Last modified date

  • Content excerpt with search term highlighting

Pagination:

  • Use 'limit' to control results per page (default: 25)

  • Use 'start' for pagination offset

Workflow Tips:

  1. Start with list_confluence_spaces to get space keys

  2. Use space-specific searches for better results

  3. Use the returned pageId with get_confluence_page for full content

  4. Look for highlighted excerpts in results to identify most relevant matches

Best Practices:

  1. Start with simple text searches when possible

  2. Use advanced CQL (with 'type =') for complex queries

  3. Use space-specific searches for better performance

  4. Use get_confluence_page to fetch full content of found pages

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query - either simple text (e.g., 'documentation') or CQL query (must include 'type =' for CQL mode, e.g., 'type = "page" AND text ~ "project"')
limitNoMaximum number of results to return (default: 25)
startNoStarting index for pagination (default: 0)

Implementation Reference

  • Handler function that executes the search_confluence_pages tool logic. Calls ConfluenceClient.searchConfluenceContent, simplifies results to id/title/type/url/excerpt, and returns JSON.
    export async function handleSearchConfluencePages(
      client: ConfluenceClient,
      args: { query: string; limit?: number; start?: number }
    ): Promise<{
      content: Array<{ type: "text"; text: string }>;
    }> {
      try {
        if (!args.query) {
          throw new McpError(ErrorCode.InvalidParams, "query is required");
        }
    
        const results = await client.searchConfluenceContent(args.query, args.limit, args.start);
        const simplified = {
          results: results.results.map(result => ({
            id: result.content.id,
            title: result.content.title,
            type: result.content.type,
            url: result.url,
            excerpt: result.excerpt || null
          })),
          next: results._links.next ? true : false
        };
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(simplified),
            },
          ],
        };
      } catch (error) {
        console.error("Error searching pages:", error instanceof Error ? error.message : String(error));
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to search pages: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Schema definition for search_confluence_pages tool, including detailed description of CQL search capabilities, input parameters (query, limit, start), and required fields.
    search_confluence_pages: {
      description: "Search across Confluence pages using simple text or CQL (Confluence Query Language).\n\nQuery Types:\n\n1. Simple Text Search:\n   - Just provide the search term directly (e.g., \"documentation\")\n   - The system automatically wraps it in proper CQL syntax\n\n2. Advanced CQL Search:\n   - Must include \"type =\" to signal raw CQL usage\n   - Examples:\n     * type = \"page\" AND text ~ \"project\"\n     * type = \"page\" AND space.key = \"TEAM\"\n     * type = \"page\" AND created >= \"2024-01-01\"\n\nSearch Capabilities:\n- Full text search across all pages\n- Space-specific searches\n- Content type filtering\n- Metadata-based filtering\n\nCQL Operators (for advanced queries):\n- ~ : contains\n- = : equals\n- != : not equals\n- AND, OR : combine conditions\n- () : group conditions\n- >= <= : date comparisons\n- IN : multiple values\n\nCommon Search Patterns:\n- Finding pages in specific space: type = \"page\" AND space.key = \"SPACENAME\" AND text ~ \"searchterm\"\n- Finding recent pages: type = \"page\" AND created >= \"2024-01-01\" AND text ~ \"searchterm\"\n- Finding pages by title: type = \"page\" AND title ~ \"exactname\"\n- Finding pages by label: type = \"page\" AND label = \"labelname\"\n\nResponse includes:\n- Page ID, title, and type\n- Space information\n- URL to the page\n- Last modified date\n- Content excerpt with search term highlighting\n\nPagination:\n- Use 'limit' to control results per page (default: 25)\n- Use 'start' for pagination offset\n\nWorkflow Tips:\n1. Start with list_confluence_spaces to get space keys\n2. Use space-specific searches for better results\n3. Use the returned pageId with get_confluence_page for full content\n4. Look for highlighted excerpts in results to identify most relevant matches\n\nBest Practices:\n1. Start with simple text searches when possible\n2. Use advanced CQL (with 'type =') for complex queries\n3. Use space-specific searches for better performance\n4. Use get_confluence_page to fetch full content of found pages",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "Search query - either simple text (e.g., 'documentation') or CQL query (must include 'type =' for CQL mode, e.g., 'type = \"page\" AND text ~ \"project\"')",
          },
          limit: {
            type: "number",
            description: "Maximum number of results to return (default: 25)",
          },
          start: {
            type: "number",
            description: "Starting index for pagination (default: 0)",
          },
        },
        required: ["query"],
      },
    },
  • src/index.ts:249-258 (registration)
    Registration of search_confluence_pages in the CallToolRequestSchema handler. Extracts query/limit/start from args, validates query is present, and delegates to handleSearchConfluencePages.
    // Search operation
    case "search_confluence_pages": {
      const { query, limit, start } = (args || {}) as { 
        query: string; 
        limit?: number; 
        start?: number 
      };
      if (!query) throw new McpError(ErrorCode.InvalidParams, "query is required");
      return await handleSearchConfluencePages(this.confluenceClient, { query, limit, start });
    }
  • ConfluenceClient method that performs the actual API call to Confluence's v1 /search endpoint with CQL. If query contains 'type =', it's used as raw CQL; otherwise it's wrapped in text search syntax. Returns simplified SearchResult with content, url, lastModified, and excerpt.
    async searchConfluenceContent(query: string, limit = 25, start = 0): Promise<SearchResult> {
      try {
        console.error('Searching Confluence with CQL:', query);
        
        // Use the v1 search endpoint with CQL
        const response = await this.v1Client.get('/search', {
          params: {
            cql: query.includes('type =') ? query : `text ~ "${query}"`,
            limit,
            start,
            expand: 'content.space,content.version,content.body.view.value'
          }
        });
    
        console.error(`Found ${response.data.results?.length || 0} results`);
    
        return {
          results: (response.data.results || []).map((result: any) => ({
            content: {
              id: result.content.id,
              type: result.content.type,
              status: result.content.status,
              title: result.content.title,
              spaceId: result.content.space?.id,
              _links: result.content._links
            },
            url: `https://${this.domain}/wiki${result.content._links?.webui || ''}`,
            lastModified: result.content.version?.when,
            excerpt: result.excerpt || ''
          })),
          _links: {
            next: response.data._links?.next,
            base: this.baseURL + '/rest/api'
          }
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          console.error('Error searching content:', error.message, error.response?.data);
          throw new ConfluenceError(
            `Failed to search content: ${error.message}`,
            'SEARCH_FAILED'
          );
        }
        throw error;
      }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It explains query types, operators, search capabilities, response format (including excerpts with highlighting), and pagination. Does not explicitly mention that the tool is read-only, but the behavior described (search returning results) implies no side effects. Could be slightly more explicit about read-only nature.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-organized into labeled sections (Query Types, Search Capabilities, CQL Operators, etc.). Every sentence adds useful information—no fluff. It efficiently packs a lot of detail without being verbose, and the structure makes it easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (CQL, multiple filtering options, pagination) and lack of output schema, the description thoroughly covers what the agent needs: query syntax, operators, common patterns, pagination, response fields, and workflow integration with sibling tools. No gaps identified.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but description adds significant value: explains the two query modes and how to switch between them, provides extensive CQL examples for each operator and common patterns, clarifies default values for limit and start, and describes the response fields. Goes well beyond the schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool searches Confluence pages using either simple text or CQL. It distinguishes from sibling tools like get_confluence_page (retrieves single page) and list_confluence_pages (lists without search). The verb 'search' and resource 'Confluence pages' are specific.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides guidance on when to use simple text vs advanced CQL, with instructions like 'must include type = for CQL mode'. Includes workflow tips (start with list_confluence_spaces) and best practices (use space-specific searches, use get_confluence_page for full content). Clearly tells when to use this vs. other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/aaronsb/confluence-cloud-mcp'

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