feat(mcp): add create_topic tool

POST /topics/ was already implemented in the REST API but had no MCP
wrapper, so agents couldn't create topics (e.g. inter_hub) via MCP.
Tool follows the same pattern as create_domain.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-28 01:32:52 +01:00
parent 9d7d1f0647
commit aa88a53db2

View File

@@ -273,6 +273,25 @@ def get_topic(slug: str) -> str:
return json.dumps({"topic": topic_detail, "recent_progress": recent}, indent=2)
@mcp.tool()
def create_topic(slug: str, title: str, domain: str, description: str | None = None) -> str:
"""Create a new topic under an existing domain.
Args:
slug: URL-safe identifier, e.g. "inter_hub" (must be unique).
title: Human-readable name, e.g. "Inter-Hub Federation".
domain: Domain slug the topic belongs to, e.g. "custodian".
description: Optional one-sentence description.
Returns the created TopicRead on success, or an error dict if the slug
already exists or the domain is not found.
"""
payload: dict = {"slug": slug, "title": title, "domain": domain}
if description:
payload["description"] = description
return json.dumps(_post("/topics", payload), indent=2)
@mcp.tool()
def list_tasks(workstream_id: str, status: str | None = None) -> str:
"""List all tasks in a workstream, optionally filtered by status.