Skip to main content
Glama
brevdev

Brev

Official
by brevdev

create_workspace

Generate a workspace by specifying an instance type and cloud provider, enabling efficient deployment and management of ML models on Brev's MCP server.

Instructions

Create a workspace from an instance type and cloud provider

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cloud_providerYesThe cloud provider for the workspace
instance_typeNoThe instance type of the workspace
nameNoThe name of the workspace

Implementation Reference

  • The primary MCP tool handler for 'create_workspace'. Validates input arguments (name, cloud_provider, instance_type), constructs CloudProvider, calls helper create_provider_workspace, and returns the workspace JSON as TextContent.
    async def create_workspace_tool(args: dict[str, str]) -> TextContent:
        if "name" not in args or "cloud_provider" not in args or "instance_type" not in args:
            raise ValueError("missing required arguments for create_workspace tool")
    
        cloud_provider = CloudProvider(args["cloud_provider"])
        workspace = await create_provider_workspace(args["name"], cloud_provider, args["instance_type"])
        return [
            TextContent(
                type="text", 
                text=workspace
            )
        ]
  • Registration of the 'create_workspace' tool in the tool_models dictionary, including Tool definition with name, description, input schema, and reference to the handler function.
    "create_workspace": ToolModel(
        tool=Tool(
            name="create_workspace",
            description="Create a workspace from an instance type and cloud provider",
            inputSchema={
                "type": "object",
                "properties": {
                    "name": {
                        "description": "The name of the workspace",
                        "type": "string",
                    },
                    "cloud_provider": {
                        "description": "The cloud provider for the workspace",
                        "enum": [provider.value for provider in CloudProvider]
                    },
                    "instance_type": {
                        "description": "The instance type of the workspace",
                        "type": "string",
                    }
                },
                "required": ["cloud_provider"]
            }
        ),
        call_tool=create_workspace_tool
    )
  • Pydantic model defining the request schema for creating a workspace, used internally by the API client.
    class CreateWorkspaceRequest(BaseModel):
        # version: Optional[str] = None
        name: str
        # description: Optional[str] = None
        workspace_group_id: Optional[str] = Field(None, alias="workspaceGroupId")
        # workspace_template_id: Optional[str] = Field(None, alias="workspaceTemplateId")
        # workspace_class: Optional[WorkspaceClassID] = Field(None, alias="workspaceClassId")
        # git_repo: Optional[str] = Field(None, alias="gitRepo")
        # is_stoppable: Optional[bool] = Field(None, alias="isStoppable")
        # tunnel: Optional[WorkspaceTunnel] = None
        # primary_application_id: Optional[str] = Field(None, alias="primaryApplicationId")
        # startup_script: Optional[str] = Field(None, alias="startupScript")
        # startup_script_path: Optional[str] = Field(None, alias="startupScriptPath")
        # ide_config: Optional[ClientConfig] = Field(None, alias="ideConfig")
        # dont_check_ssh_keys: bool = Field(False, alias="dontCheckSSHKeys")
        # repos: ReposV0
        # execs: ExecsV0
        # init_branch: Optional[str] = Field(None, alias="initBranch")
        # dot_brev_path: Optional[str] = Field(None, alias="dotBrevPath")
        # repos_v1: Optional[ReposV1] = Field(None, alias="reposV1")
        # execs_v1: Optional[ExecsV1] = Field(None, alias="execsV1")
        instance_type: Optional[str] = Field(None, alias="instanceType")
        # disk_storage: Optional[str] = Field(None, alias="diskStorage")
        # region: Optional[str] = None
        # image: Optional[str] = None
        # architecture: Optional[Architecture] = None
        # spot: bool = False
        # on_container: bool = Field(False, alias="onContainer")
        # initial_container_image: Optional[str] = Field(None, alias="containerImage")
        verb_yaml: Optional[str] = Field(DEFAULT_VERB_CONFIG, alias="verbYaml")
        # base_image: Optional[str] = Field(None, alias="baseImage")
        # custom_container: Optional[CustomContainer] = Field(None, alias="customContainer")
        # port_mappings: Optional[Dict[str, str]] = Field(None, alias="portMappings")
        workspace_version: Optional[Literal["v1", "v0"]] = Field("v1", alias="workspaceVersion")
        # retry_for: Optional[str] = Field(None, alias="retryFor")
        # vm_only_mode: bool = Field(False, alias="vmOnlyMode")
        # files: Optional[List[FileRequest]] = None
        # labels: Optional[Dict[str, str]] = None
        # launch_jupyter_on_start: bool = Field(False, alias="launchJupyterOnStart")
    
        class Config:
            populate_by_name = True
  • Helper function that builds the CreateWorkspaceRequest using provider-specific workspace group ID and calls the API create_workspace function.
    async def create_provider_workspace(name: str, cloud_provider: CloudProvider, instance_type: str) -> str:
        req = CreateWorkspaceRequest(
            name=name,
            workspaceGroupId=cloud_provider.get_workspace_group_id(),
            instanceType=instance_type,
        )
        workspace = await create_workspace(req)
        return json.dumps(workspace.model_dump(), indent=2)
  • Core API integration helper that sends HTTP POST request to Brev's API to create the workspace, using authentication and org ID.
    async def create_workspace(request: CreateWorkspaceRequest) -> Workspace:
        access_token = get_acess_token() 
        org_id = get_active_org_id()
        try:
            async with httpx.AsyncClient(timeout=httpx.Timeout(25.0)) as client:
                json = request.model_dump(by_alias=True)
                response = await client.post(
                    f"{BASE_API_URL}/organizations/{org_id}/workspaces",
                    headers={
                        "Authorization": f"Bearer {access_token}",
                        "Content-Type": "application/json"
                    },
                    json=json            
                )
                response.raise_for_status()
                data = response.json()
                workspace = Workspace.model_validate(data)
                return workspace
        except ValidationError as e:    
            raise RuntimeError(f"Failed to validate workspace: {str(e)}")
        except Exception as e:
            raise RuntimeError(f"Failed to create workspace: {str(e)}")
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states this is a creation tool, implying a write/mutation operation, but doesn't mention permission requirements, whether the operation is idempotent, what happens on failure, or any rate limits. This leaves significant behavioral gaps for a tool that creates resources.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It's appropriately sized and front-loaded with the essential information, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a resource creation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what a 'workspace' represents in this context, what happens after creation, whether there are dependencies or constraints, or what the return value might be. The combination of mutation behavior and lack of structured metadata creates significant contextual gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters well-documented in the schema itself. The description mentions 'instance type and cloud provider' as inputs, which aligns with two of the three parameters, but doesn't add meaningful semantic context beyond what the schema already provides. The baseline of 3 is appropriate given the comprehensive schema documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and resource ('workspace') with specific inputs ('from an instance type and cloud provider'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from the sibling tool 'get_instance_types', which appears to be a read-only counterpart rather than a direct alternative for creation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives or any prerequisites for its use. While it mentions 'instance type and cloud provider' as inputs, it doesn't clarify if this is the only way to create a workspace or if there are other methods available.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

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/brevdev/brev-mcp'

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