Skip to main content
Glama

cwiki_search_pages

Search pages within an Apache Incubator Confluence workspace. Use keywords to find relevant pages and optionally specify result count or start index.

Instructions

Search pages in the configured Apache Incubator Confluence space.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo
startNo
force_refreshNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the cwiki_search_pages tool. Decorated with @mcp.tool(), it accepts a query string, limit, start, and force_refresh parameters. It validates inputs, builds a CQL query searching the configured Confluence space for pages matching the text query, calls the Confluence REST API, and returns results including page summaries and text excerpts.
    @mcp.tool()
    def cwiki_search_pages(
        query: str,
        limit: int = 10,
        start: int = 0,
        force_refresh: bool = False,
    ) -> dict[str, Any]:
        """Search pages in the configured Apache Incubator Confluence space."""
        if not query.strip():
            raise ValueError("query must not be empty")
        validate_range("limit", limit, 1, 50)
        validate_range("start", start, 0, 1_000_000)
    
        cql = f'space = "{escape_cql(client.SPACE_KEY)}" and type = page and text ~ "{escape_cql(query)}"'
        pages = client.confluence_get(
            "/rest/api/content/search",
            {
                "cql": cql,
                "limit": str(limit),
                "start": str(start),
                "expand": "body.view,version",
            },
            force_refresh=force_refresh,
        )
    
        return {
            "cql": cql,
            **client.pagination(pages),
            "pages": [
                {
                    **client.page_summary(page),
                    "excerpt": html_to_text(page.get("body", {}).get("view", {}).get("value", ""))[:800],
                }
                for page in pages.get("results", [])
            ],
        }
  • The @mcp.tool() decorator registers cwiki_search_pages as an MCP tool on the FastMCP instance 'mcp' (defined on line 12).
    @mcp.tool()
  • Helper function that escapes backslashes and double quotes in CQL values to prevent injection.
    def escape_cql(value: str) -> str:
        return value.replace("\\", "\\\\").replace('"', '\\"')
  • Helper function to validate numeric parameters are within a given range.
    def validate_range(name: str, value: int, minimum: int, maximum: int) -> None:
        if value < minimum or value > maximum:
            raise ValueError(f"{name} must be between {minimum} and {maximum}")
  • Helper function that converts HTML to plain text for the excerpt, using the _TextExtractor HTMLParser subclass.
    def html_to_text(html: str) -> str:
        parser = _TextExtractor()
        parser.feed(html)
        parser.close()
        text = parser.text()
        lines = [line.strip() for line in text.splitlines()]
        return "\n".join(line for line in lines if line)
Behavior2/5

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

No annotations, and description provides no behavioral details such as pagination behavior, caching effects of force_refresh, or scope of search (titles only vs full text).

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

Conciseness3/5

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

Extremely concise, but this comes at the cost of omitting necessary detail. One sentence with no structure or additional context.

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

Completeness2/5

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

Given the presence of 4 parameters and sibling tools, the description is too sparse. It does not address output format, pagination, or how caching works, leaving the agent underinformed.

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

Parameters2/5

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

Schema has 0% description coverage; the description does not explain any parameters. The meaning of 'query', 'limit', 'start', and 'force_refresh' is left to inference from names, which may be insufficient.

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

Purpose4/5

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

Clearly states it searches pages in a specific Confluence space. However, it does not differentiate from sibling tools like cwiki_list_pages or cwiki_get_page, which might have overlapping functionality.

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 vs alternatives (e.g., search vs list). Lacks context about prerequisites or typical use cases.

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/justinmclean/CwikiMCP'

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