Skip to main content
Glama
xiandan-erizo

Confluence MCP Server

search_confluence

Search Confluence documentation pages by keyword to find relevant information, with configurable result limits for efficient content discovery.

Instructions

    搜索 Confluence 页面内容

    Args:
        query: 搜索关键词(支持字符串、数字等格式,会自动转换为字符串)
        limit: 返回结果数量限制,默认10条
        ctx: MCP 上下文

    Returns:
        Dict: 包含搜索结果的字典
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
limitNo

Implementation Reference

  • Main search_confluence tool handler - decorated with @mcp.tool() for registration, accepts query parameter and optional limit, converts query to string, logs the operation, calls confluence.search_by_key(), and returns formatted results with error handling
    @mcp.tool()
    async def search_confluence(
        query: Union[str, int, float],
        ctx: Context,
        limit: int = 10
    ) -> Dict:
        """
        搜索 Confluence 页面内容
    
        Args:
            query: 搜索关键词(支持字符串、数字等格式,会自动转换为字符串)
            limit: 返回结果数量限制,默认10条
            ctx: MCP 上下文
    
        Returns:
            Dict: 包含搜索结果的字典
        """
        try:
            query_str = str(query)  # 将任何类型转换为字符串
    
            await ctx.session.send_log_message(
                level="info",
                data=f"搜索 Confluence: query='{query_str}', limit={limit}"
            )
    
            results = confluence.search_by_key(query_str, limit)
    
            return {
                "success": True,
                "query": query,
                "total": len(results),
                "results": results
            }
    
        except Exception as e:
            error_msg = f"搜索失败: {str(e)}"
            await ctx.session.send_log_message(
                level="error",
                data=error_msg
            )
            return {
                "success": False,
                "error": error_msg
            }
  • Confluence search helper method - uses CQL (Confluence Query Language) to search both title and content fields, formats results with page id, title, type, url, and excerpt
    def search_by_key(self, key, limit=10):
        """
        搜索 Confluence 页面(标题和内容)
        :param key: 搜索关键字
        :param limit: 返回结果数量限制
        :return: 搜索结果列表,每个结果包含页面基本信息
        """
    
        # 使用 CQL 搜索标题和内容
        cql = f'text ~ "{key}" OR title ~ "{key}"'
        results = self.confluence.cql(cql, limit=limit)
        
        if not results or 'results' not in results:
            return []
            
        # 格式化返回结果
        formatted_results = []
        for result in results['results']:
            formatted_results.append({
                'id': result.get('content', {}).get('id'),
                'title': result.get('content', {}).get('title'),
                'type': result.get('content', {}).get('type'),
                'url': self.page_url.format(page_id=result.get('content', {}).get('id')),
                'excerpt': result.get('excerpt', '')  # 搜索结果中的匹配内容片段
            })
        
        return formatted_results
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the return type ('Dict: 包含搜索结果的字典') but lacks details on permissions, rate limits, error handling, or what the search covers (e.g., titles only, full text). This leaves significant gaps for a search operation.

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

Conciseness4/5

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

The description is appropriately sized with a clear purpose statement followed by parameter and return details in a structured format. It's front-loaded with the main function, though the formatting includes extra whitespace that slightly reduces efficiency.

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 no annotations, no output schema, and low schema coverage, the description is incomplete. It covers basic purpose and parameters but lacks crucial context like search scope, result format details, authentication needs, or error cases, making it inadequate for a search tool with two parameters.

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 description coverage is 0%, so the description must compensate. It adds basic semantics for 'query' (search keywords, auto-converted to string) and 'limit' (result count limit, default 10), which helps beyond the bare schema. However, it doesn't fully explain parameter constraints or interactions, leaving some ambiguity.

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?

The description clearly states the tool's purpose as '搜索 Confluence 页面内容' (search Confluence page content), which is a specific verb+resource combination. However, it doesn't explicitly differentiate from the sibling tool 'get_confluence_page', which might retrieve specific pages rather than search across content.

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?

The description provides no guidance on when to use this tool versus alternatives like the sibling 'get_confluence_page'. It mentions parameters but doesn't explain the context or scenarios where searching is appropriate versus direct retrieval.

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/xiandan-erizo/ops-mcp'

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