From aa88a53db284819d6def76a7d189683d0e1c1218 Mon Sep 17 00:00:00 2001 From: tegwick Date: Sat, 28 Mar 2026 01:32:52 +0100 Subject: [PATCH] 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 --- state-hub/mcp_server/server.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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.