get_project_users
Retrieve users linked to a specific project by providing its ID. Ideal for managing project access and collaboration on the Goodday platform through the MCP server.
Instructions
Get users associated with a specific project.
Args: project_id: The ID of the project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes |
Implementation Reference
- goodday_mcp/main.py:651-670 (handler)The handler function for the 'get_project_users' tool. It is registered via the @mcp.tool() decorator. Fetches project users from the Goodday API and formats them for output.async def get_project_users(project_id: str) -> str: """Get users associated with a specific project. Args: project_id: The ID of the project """ data = await make_goodday_request(f"project/{project_id}/users") if not data: return "No users found for this project." if isinstance(data, dict) and "error" in data: return f"Unable to fetch project users: {data.get('error', 'Unknown error')}" if not isinstance(data, list): return f"Unexpected response format: {str(data)}" users = [format_user(user) for user in data] return "\n---\n".join(users)
- goodday_mcp/main.py:135-149 (helper)Helper function to format user data into a readable multi-line string, used in get_project_users to display users.def format_user(user: dict) -> str: """Format a user into a readable string with safe checks.""" if not isinstance(user, dict): return f"Invalid user data: {repr(user)}" # Defensive defaults in case nested keys are not dicts role = user.get('role') if isinstance(user.get('role'), dict) else {} return f""" User ID: {user.get('id', 'N/A')} Name: {user.get('name', 'N/A')} Email: {user.get('email', 'N/A')} Role: {role.get('name', 'N/A')} Status: {user.get('status', 'N/A')} """.strip()
- goodday_mcp/main.py:15-57 (helper)Core helper function that makes authenticated HTTP requests to the Goodday API, used by get_project_users to fetch the user list.async def make_goodday_request(endpoint: str, method: str = "GET", data: dict = None, subfolders: bool = True) -> dict[str, Any] | list[Any] | None: """Make a request to the Goodday API with proper error handling.""" api_token = os.getenv("GOODDAY_API_TOKEN") if not api_token: raise ValueError("GOODDAY_API_TOKEN environment variable is required") headers = { "User-Agent": USER_AGENT, "gd-api-token": api_token, "Content-Type": "application/json" } # Automatically add subfolders=true for project task and document endpoints if not already present if subfolders and endpoint.startswith("project/") and ("/tasks" in endpoint or "/documents" in endpoint): if "?" in endpoint: if "subfolders=" not in endpoint: endpoint += "&subfolders=true" else: endpoint += "?subfolders=true" url = f"{GOODDAY_API_BASE}/{endpoint.lstrip('/')}" async with httpx.AsyncClient() as client: try: if method.upper() == "POST": response = await client.post(url, headers=headers, json=data, timeout=30.0) elif method.upper() == "PUT": response = await client.put(url, headers=headers, json=data, timeout=30.0) elif method.upper() == "DELETE": response = await client.delete(url, headers=headers, timeout=30.0) else: response = await client.get(url, headers=headers, timeout=30.0) response.raise_for_status() return response.json() except httpx.HTTPStatusError as e: raise Exception(f"HTTP error {e.response.status_code}: {e.response.text}") except httpx.RequestError as e: raise Exception(f"Request error: {str(e)}") except Exception as e: raise Exception(f"Unexpected error: {str(e)}")