Skip to main content
Glama
workspaces.py5.53 kB
from typing import List, Dict, Any from mcp.types import Tool, TextContent import json class WorkspaceTools: """Workspace management tools for ClickUp MCP""" def __init__(self, client): self.client = client def get_tools(self) -> List[Tool]: """Get all workspace-related tools""" return [ Tool( name="get_workspaces", description="Get all workspaces accessible to the user", inputSchema={ "type": "object", "properties": {}, "required": [] } ), Tool( name="get_workspace_members", description="Get members of a specific workspace", inputSchema={ "type": "object", "properties": { "workspace_id": { "type": "string", "description": "The ID of the workspace" } }, "required": ["workspace_id"] } ), Tool( name="get_spaces", description="Get all spaces in a workspace", inputSchema={ "type": "object", "properties": { "workspace_id": { "type": "string", "description": "The ID of the workspace" } }, "required": ["workspace_id"] } ), Tool( name="create_workspace_audit_log", description="Create a workspace audit log entry (Enterprise plan only)", inputSchema={ "type": "object", "properties": { "workspace_id": { "type": "string", "description": "The ID of the workspace" }, "action": { "type": "string", "description": "The action that was performed" }, "resource_type": { "type": "string", "description": "The type of resource affected" }, "resource_id": { "type": "string", "description": "The ID of the resource affected" }, "details": { "type": "object", "description": "Additional details about the action" }, "timestamp": { "type": "string", "description": "Unix timestamp of when the action occurred" } }, "required": ["workspace_id", "action", "resource_type", "resource_id"] } ) ] async def handle_tool_call(self, name: str, arguments: Dict[str, Any]) -> List[TextContent]: """Handle workspace tool calls""" try: if name == "get_workspaces": result = await self._get_workspaces(arguments) elif name == "get_workspace_members": result = await self._get_workspace_members(arguments) elif name == "get_spaces": result = await self._get_spaces(arguments) elif name == "create_workspace_audit_log": result = await self._create_workspace_audit_log(arguments) else: raise ValueError(f"Unknown tool: {name}") return [TextContent(type="text", text=json.dumps(result, indent=2))] except Exception as e: return [TextContent(type="text", text=f"Error: {str(e)}")] async def _get_workspaces(self, args: Dict[str, Any]) -> Dict[str, Any]: """Get user's workspaces""" workspaces = self.client.get_workspaces() return {"workspaces": workspaces, "count": len(workspaces)} async def _get_workspace_members(self, args: Dict[str, Any]) -> Dict[str, Any]: """Get workspace members""" workspace_id = args["workspace_id"] members = self.client.get_workspace_members(workspace_id) return {"members": members, "count": len(members), "workspace_id": workspace_id} async def _get_spaces(self, args: Dict[str, Any]) -> Dict[str, Any]: """Get spaces in workspace""" workspace_id = args["workspace_id"] spaces = self.client.get_spaces(workspace_id) return {"spaces": spaces, "count": len(spaces), "workspace_id": workspace_id} async def _create_workspace_audit_log(self, args: Dict[str, Any]) -> Dict[str, Any]: """Create workspace audit log entry""" workspace_id = args["workspace_id"] log_data = { "action": args["action"], "resource_type": args["resource_type"], "resource_id": args["resource_id"] } if "details" in args: log_data["details"] = args["details"] if "timestamp" in args: log_data["timestamp"] = args["timestamp"] return self.client.create_workspace_audit_log(workspace_id, log_data)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yihaoWang/clickup-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server