Python Example
Complete example showing the two-step process:Copy
import requests
import base64
API_KEY = "pk_your_api_key_here"
BASE_URL = "https://poe.poesius.com/api/v1/mcp"
def call_mcp_tool(tool_name, arguments):
response = requests.post(
f"{BASE_URL}/messages",
headers={
"X-API-Key": API_KEY,
"Content-Type": "application/json"
},
json={
"method": "tools/call",
"params": {
"name": tool_name,
"arguments": arguments
}
}
)
response.raise_for_status()
return response.json()
def read_document(file_path):
with open(file_path, 'rb') as f:
return base64.b64encode(f.read()).decode('utf-8')
# Step 1: Generate content
document_base64 = read_document("document.pdf")
content_result = call_mcp_tool("generate_presentation_content", {
"topic": "AI in Healthcare",
"instructions": "Generate comprehensive content for 20 slides covering applications, benefits, and challenges",
"num_slides": 20,
"document_base64": document_base64
})
presentation_id = content_result["result"]["presentation_id"]
markdown_content = content_result["result"]["content"]
conversation_id = content_result["result"]["conversation_id"]
print("=" * 50)
print("STEP 1: Content Generated")
print("=" * 50)
print(f"Presentation ID: {presentation_id}")
print(f"Conversation ID: {conversation_id}")
print(f"\nContent Preview:\n{markdown_content[:500]}...")
print("\n" + "=" * 50)
# Optional: Review and edit content
# You can modify markdown_content here before proceeding
# Step 2: Create slides from content
print("\nSTEP 2: Creating slides from content...")
print("=" * 50)
slide_result = call_mcp_tool("slide_from_content", {
"content": markdown_content,
"instructions": "Create professional slides with consistent styling. Use appropriate layouts for each slide type.",
"template_id": "123e4567-e89b-12d3-a456-426614174000",
"presentation_id": presentation_id,
"conversation_id": conversation_id
})
print(f"Created {len(slide_result['result']['slides'])} slides")
print(f"Presentation URL: https://app.poesius.com/presentations/{presentation_id}")
print(f"Download URL: {slide_result['result'].get('download_url', 'N/A')}")
With Content Review
Example that allows content review before creating slides:Copy
import requests
import base64
API_KEY = "pk_your_api_key_here"
BASE_URL = "https://poe.poesius.com/api/v1/mcp"
def generate_and_review(document_path, topic, instructions, num_slides, template_id):
"""Generate content, allow review, then create slides"""
# Step 1: Generate content
document_base64 = read_document(document_path)
content_result = call_mcp_tool("generate_presentation_content", {
"topic": topic,
"instructions": instructions,
"num_slides": num_slides,
"document_base64": document_base64
})
presentation_id = content_result["result"]["presentation_id"]
markdown_content = content_result["result"]["content"]
# Step 2: Review content
print("Generated content:")
print("-" * 50)
print(markdown_content)
print("-" * 50)
# Ask user if they want to proceed
user_input = input("\nProceed with slide creation? (y/n): ")
if user_input.lower() != 'y':
print("Slide creation cancelled.")
return None
# Optional: Allow content editing
edit = input("Edit content before creating slides? (y/n): ")
if edit.lower() == 'y':
# In a real application, you'd use a text editor
print("Content editing not implemented in this example.")
print("You can modify markdown_content here.")
# Step 3: Create slides
slide_result = call_mcp_tool("slide_from_content", {
"content": markdown_content,
"instructions": "Create professional slides",
"template_id": template_id,
"presentation_id": presentation_id
})
return slide_result
Multiple Template Generation
Generate content once, create slides with different templates:Copy
def generate_with_multiple_templates(document_path, topic, instructions, num_slides):
"""Generate content once, create slides with different templates"""
# Step 1: Generate content (once)
document_base64 = read_document(document_path)
content_result = call_mcp_tool("generate_presentation_content", {
"topic": topic,
"instructions": instructions,
"num_slides": num_slides,
"document_base64": document_base64
})
markdown_content = content_result["result"]["content"]
base_presentation_id = content_result["result"]["presentation_id"]
# Step 2: Get available templates
templates_result = call_mcp_tool("list_templates", {})
templates = templates_result["result"]["templates"]
# Step 3: Create slides with each template
results = []
for template in templates[:3]: # Use first 3 templates
template_id = template["template_id"]
template_name = template["template_name"]
print(f"Creating slides with template: {template_name}")
slide_result = call_mcp_tool("slide_from_content", {
"content": markdown_content,
"instructions": "Create professional slides",
"template_id": template_id,
"presentation_id": base_presentation_id
})
results.append({
"template_name": template_name,
"template_id": template_id,
"slides": slide_result["result"]["slides"],
"download_url": slide_result["result"].get("download_url")
})
return results
Error Handling
Copy
def two_step_with_error_handling(document_path, topic, instructions, num_slides, template_id):
"""Two-step process with comprehensive error handling"""
try:
# Step 1: Generate content
document_base64 = read_document(document_path)
content_result = call_mcp_tool("generate_presentation_content", {
"topic": topic,
"instructions": instructions,
"num_slides": num_slides,
"document_base64": document_base64
})
if "error" in content_result:
raise Exception(f"Content generation failed: {content_result['error']}")
presentation_id = content_result["result"]["presentation_id"]
markdown_content = content_result["result"]["content"]
if not markdown_content:
raise Exception("Generated content is empty")
# Step 2: Create slides
slide_result = call_mcp_tool("slide_from_content", {
"content": markdown_content,
"instructions": "Create professional slides",
"template_id": template_id,
"presentation_id": presentation_id
})
if "error" in slide_result:
raise Exception(f"Slide creation failed: {slide_result['error']}")
return slide_result
except FileNotFoundError:
raise Exception(f"Document not found: {document_path}")
except requests.exceptions.RequestException as e:
raise Exception(f"Network error: {e}")
except Exception as e:
raise Exception(f"Error in two-step process: {e}")
Two-Step Process Guide
Learn more about the two-step process
MCP Examples
See more MCP examples

