diff --git a/state-hub/mcp_server/server.py b/state-hub/mcp_server/server.py index 8f17672..91161bb 100644 --- a/state-hub/mcp_server/server.py +++ b/state-hub/mcp_server/server.py @@ -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.