ask-confluence-page
Ask questions about Confluence page content to extract specific information using page ID, title, or space key.
Instructions
Ask a question about a specific Confluence page content
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_id | No | The ID of the Confluence page | |
| title | No | The title of the Confluence page | |
| space_key | No | The key of the Confluence space | |
| question | No | The question to ask about the page content | |
| context_type | No | Type of context needed to answer the question | summary |
Implementation Reference
- src/mcp_jira_confluence/server.py:785-807 (registration)Tool 'ask-confluence-page' is registered in the list_tools handler with its name, description, and input schema definition.
types.Tool( name="ask-confluence-page", description="Ask a question about a specific Confluence page content", inputSchema={ "type": "object", "properties": { "page_id": {"type": "string", "description": "The ID of the Confluence page"}, "title": {"type": "string", "description": "The title of the Confluence page"}, "space_key": {"type": "string", "description": "The key of the Confluence space"}, "question": {"type": "string", "description": "The question to ask about the page content"}, "context_type": { "type": "string", "enum": ["summary", "details", "specific"], "default": "summary", "description": "Type of context needed to answer the question" } }, "anyOf": [ {"required": ["page_id", "question"]}, {"required": ["title", "space_key", "question"]} ] } ), - Handler implementation for 'ask-confluence-page' tool. Fetches a Confluence page by ID or title+space_key, converts content to markdown, and returns relevant context to answer the user's question. Supports three context types: summary, details, and specific.
elif name == "ask-confluence-page": page_id = arguments.get("page_id") title = arguments.get("title") space_key = arguments.get("space_key") question = arguments.get("question") context_type = arguments.get("context_type", "summary") if not question: raise ValueError("Missing required argument: question") if not page_id and (not title or not space_key): raise ValueError("Missing required arguments: either page_id or both title and space_key") # Fetch the page content page_data = None if page_id: page_data = await confluence_client.get_page(page_id, expand="body.storage,version,space") else: # Search by title and space key cql = f'title = "{title}" AND space.key = "{space_key}"' search_result = await confluence_client.search(cql, limit=1) if search_result.get("results"): page_id = search_result["results"][0]["id"] page_data = await confluence_client.get_page(page_id, expand="body.storage,version,space") else: raise ValueError("Page not found") page_title = page_data["title"] content = page_data["body"]["storage"]["value"] space_name = page_data.get("space", {}).get("name", "Unknown Space") # Convert content to markdown for better readability markdown_content = ConfluenceFormatter.confluence_to_markdown(content) # Extract context based on the context type if context_type == "summary": # Use first 1000 characters for summary context context = markdown_content[:1000] + "..." if len(markdown_content) > 1000 else markdown_content elif context_type == "details": context = markdown_content else: # For specific context, use full content but note it's not specifically filtered context = markdown_content # Create a response that answers the question based on the page content response = f"**Question:** {question}\n\n" response += f"**Page:** {page_title}\n" response += f"**Space:** {space_name}\n\n" response += f"**Answer based on page content:**\n\n" response += f"Here is the relevant content from the Confluence page to help answer your question:\n\n" response += f"**Context ({context_type}):**\n{context}\n\n" if context_type == "details": response += f"**Full Content:**\n{markdown_content}" else: response += f"Please note: This is a {context_type} view. For complete details, use context_type='details'." return [ types.TextContent( type="text", text=response, ) ]