Spaces:
Running
Running
File size: 740 Bytes
7114af0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
"""Handler for publishing Datawrapper charts."""
import json
from datawrapper import get_chart
from mcp.types import TextContent
from ..utils import get_api_token
async def publish_chart(arguments: dict) -> list[TextContent]:
"""Publish a chart to make it publicly accessible."""
api_token = get_api_token()
chart_id = arguments["chart_id"]
# Get chart and publish using Pydantic instance method
chart = get_chart(chart_id, access_token=api_token)
chart.publish(access_token=api_token)
result = {
"chart_id": chart_id,
"public_url": chart.get_public_url(),
"message": "Chart published successfully!",
}
return [TextContent(type="text", text=json.dumps(result, indent=2))]
|