create_project
Initialize a new Coroot project by specifying a unique name. Ensures the project name adheres to specific format rules for integration with the observability platform.
Instructions
Create a new project.
Creates a new Coroot project with the specified name. The name must contain only lowercase letters, numbers, and hyphens.
Args: name: Project name (must match ^a-z0-9?$)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- src/mcp_coroot/server.py:196-206 (registration)MCP tool registration for 'create_project' with input schema defined in docstring (name: str).@mcp.tool() async def create_project(name: str) -> dict[str, Any]: """Create a new project. Creates a new Coroot project with the specified name. The name must contain only lowercase letters, numbers, and hyphens. Args: name: Project name (must match ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$) """ return await create_project_impl(name) # type: ignore[no-any-return]
- src/mcp_coroot/server.py:185-193 (handler)Primary handler logic that invokes CorootClient.create_project and formats the response.@handle_errors async def create_project_impl(name: str) -> dict[str, Any]: """Create a new project.""" project = await get_client().create_project(name) return { "success": True, "message": "Project created successfully", "project": project, }
- src/mcp_coroot/client.py:315-337 (handler)CorootClient.create_project: Performs HTTP POST to Coroot API /api/project/ endpoint to create the project.async def create_project(self, name: str) -> dict[str, Any]: """Create a new project. Args: name: Project name (must match ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$). Returns: Created project information. """ data = {"name": name} response = await self._request("POST", "/api/project/", json=data) # Handle different response types try: if response.headers.get("content-type", "").startswith("application/json"): result: dict[str, Any] = response.json() return result else: # If not JSON, return a success indicator with the name return {"id": name, "name": name} except Exception: # If parsing fails, return minimal success response return {"id": name, "name": name}
- src/mcp_coroot/server.py:44-86 (helper)Error handling decorator applied to create_project_impl for standardized error responses.def handle_errors(func: Callable[..., Any]) -> Callable[..., Any]: """Decorator to handle common errors in tool implementations.""" @wraps(func) async def wrapper(*args: Any, **kwargs: Any) -> dict[str, Any]: try: return await func(*args, **kwargs) # type: ignore[no-any-return] except ValueError as e: # Handle missing credentials or other validation errors return { "success": False, "error": str(e), "error_type": "validation", } except CorootError as e: # Handle Coroot API errors (including authentication) error_msg = str(e) if "Authentication failed" in error_msg: return { "success": False, "error": error_msg, "error_type": "authentication", } elif "401" in error_msg or "Unauthorized" in error_msg: return { "success": False, "error": "Authentication required. Please check your credentials.", "error_type": "authentication", } return { "success": False, "error": error_msg, "error_type": "api_error", } except Exception as e: # Handle unexpected errors return { "success": False, "error": f"Unexpected error: {str(e)}", "error_type": "unknown", } return wrapper