from mcp.server.fastmcp import FastMCP
from dooray_mcp.controllers import template as template_controller
def register_template_tools(mcp: FastMCP) -> None:
@mcp.tool(
name="dooray_list_templates",
description="List post templates in a Dooray project",
)
async def dooray_list_templates(
project_id: str,
page: int = 0,
size: int = 20,
) -> str:
result = await template_controller.list_templates(
project_id=project_id, page=page, size=size
)
return result.content
@mcp.tool(
name="dooray_get_template",
description="Get detailed information about a specific template",
)
async def dooray_get_template(
project_id: str,
template_id: str,
) -> str:
result = await template_controller.get_template(
project_id=project_id, template_id=template_id
)
return result.content
@mcp.tool(
name="dooray_create_template",
description="Create a new post template in a project",
)
async def dooray_create_template(
project_id: str,
name: str,
body: str,
body_mime_type: str = "text/x-markdown",
) -> str:
result = await template_controller.create_template(
project_id=project_id, name=name, body=body, body_mime_type=body_mime_type
)
return result.content
@mcp.tool(
name="dooray_update_template",
description="Update an existing post template",
)
async def dooray_update_template(
project_id: str,
template_id: str,
name: str | None = None,
body: str | None = None,
body_mime_type: str = "text/x-markdown",
) -> str:
result = await template_controller.update_template(
project_id=project_id,
template_id=template_id,
name=name,
body=body,
body_mime_type=body_mime_type,
)
return result.content
@mcp.tool(
name="dooray_delete_template",
description="Delete a post template from a project",
)
async def dooray_delete_template(
project_id: str,
template_id: str,
) -> str:
result = await template_controller.delete_template(
project_id=project_id, template_id=template_id
)
return result.content