Skip to main content
Glama

search_pages

Finds Confluence pages matching a query by title or content. Use space key to limit search to a specific space.

Instructions

Search for Confluence pages by title or content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query string to match against page titles and content
space_keyNoOptional space key to limit search to a specific space
limitNoMaximum number of results to return (default: 10, max: 50)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @mcp.tool() decorated function 'search_pages' that implements the MCP tool handler for searching Confluence pages via CQL queries.
    @mcp.tool()
    def search_pages(query: str, space_key: Optional[str] = None, limit: int = 10) -> str:
        """
        Search for Confluence pages by title or content.
        
        Args:
            query: Search query string to match against page titles and content
            space_key: Optional space key to limit search to a specific space
            limit: Maximum number of results to return (default: 10, max: 50)
        
        Returns:
            JSON string containing matching pages with titles, IDs, spaces, and URLs
        """
        try:
            if not query or not query.strip():
                return "Error: query parameter is required and cannot be empty"
            
            if limit < 1 or limit > 50:
                return "Error: limit must be between 1 and 50"
            
            pages = confluence.search_pages(query=query, space_key=space_key, limit=limit)
            
            # Format response
            result = {
                "total": len(pages),
                "query": query,
                "space_key": space_key,
                "pages": [
                    {
                        "id": page.get("id"),
                        "title": page.get("title"),
                        "type": page.get("type"),
                        "space": {
                            "key": page.get("space", {}).get("key"),
                            "name": page.get("space", {}).get("name")
                        },
                        "version": page.get("version", {}).get("number"),
                        "url": f"{CONFLUENCE_URL}/wiki{page.get('_links', {}).get('webui', '')}"
                    }
                    for page in pages
                ]
            }
            
            import json
            return json.dumps(result, indent=2)
        
        except Exception as e:
            logger.error(f"Error searching pages: {e}")
            return f"Error: {str(e)}"
  • The function signature defines the input schema: query (str, required), space_key (Optional[str]), and limit (int, default=10). The return type is str (JSON).
    def search_pages(query: str, space_key: Optional[str] = None, limit: int = 10) -> str:
        """
        Search for Confluence pages by title or content.
        
        Args:
            query: Search query string to match against page titles and content
            space_key: Optional space key to limit search to a specific space
            limit: Maximum number of results to return (default: 10, max: 50)
        
        Returns:
            JSON string containing matching pages with titles, IDs, spaces, and URLs
  • The JSON output schema returned by the handler, containing total count, query, space_key, and pages array with id, title, type, space, version, and url.
    # Format response
    result = {
        "total": len(pages),
        "query": query,
        "space_key": space_key,
        "pages": [
            {
                "id": page.get("id"),
                "title": page.get("title"),
                "type": page.get("type"),
                "space": {
                    "key": page.get("space", {}).get("key"),
                    "name": page.get("space", {}).get("name")
                },
                "version": page.get("version", {}).get("number"),
                "url": f"{CONFLUENCE_URL}/wiki{page.get('_links', {}).get('webui', '')}"
            }
            for page in pages
        ]
    }
    
    import json
    return json.dumps(result, indent=2)
  • server.py:154-154 (registration)
    The tool is registered as an MCP tool via the @mcp.tool() decorator on line 154.
    @mcp.tool()
  • The ConfluenceClient.search_pages() helper method that constructs a CQL query and calls the Confluence REST API /content/search endpoint.
    def search_pages(
        self, 
        query: str, 
        space_key: Optional[str] = None, 
        limit: int = 10
    ) -> list[dict]:
        """Search for Confluence pages by title or content."""
        cql = f'type=page and (title~"{query}" or text~"{query}")'
        if space_key:
            cql += f' and space="{space_key}"'
        
        params = {
            "cql": cql,
            "limit": limit,
            "expand": "space,version"
        }
        response = self._make_request("GET", "/content/search", params=params)
        return response.get("results", [])
Behavior2/5

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

No annotations provided. Description does not disclose behavioral traits such as pagination, rate limits, or error handling. Minimal beyond basic action.

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?

Single sentence, front-loaded, no unnecessary words.

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

Completeness3/5

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

Given output schema exists and 3 parameters, description is adequate but lacks details on result format, sorting, or edge cases. Not severely lacking but minimal.

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

Parameters3/5

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

Schema descriptions cover all parameters (100% coverage). Description adds no new meaning beyond schema; 'title or content' is already in query parameter description.

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?

Clearly states verb 'Search' and resource 'Confluence pages' with criteria 'by title or content'. Distinct from sibling tools fetch_page_markdown and list_spaces.

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

Usage Guidelines2/5

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

No guidance on when to use this tool versus alternatives. No mention of when not to use or prerequisites.

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/mazhar480/awesome-confluence-mcp'

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