Skip to main content
Glama

workspace_switch

Switch between virtual filesystem workspaces to manage files across different storage providers and scopes.

Instructions

Switch to a different workspace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Implementation Reference

  • Registers the workspace_switch tool using @server.tool decorator, delegating to workspace_tools.workspace_switch
    @server.tool
    async def workspace_switch(name: str):
        """Switch to a different workspace."""
        return await workspace_tools.workspace_switch(name)
  • Main handler logic for the workspace_switch tool: calls workspace_manager.switch_workspace and constructs WorkspaceSwitchResponse
    async def workspace_switch(self, name: str) -> WorkspaceSwitchResponse:
        """
        Switch to a different workspace.
    
        Args:
            name: Workspace name to switch to
    
        Returns:
            WorkspaceSwitchResponse with new current workspace info
        """
        info = await self.workspace_manager.switch_workspace(name)
    
        return WorkspaceSwitchResponse(
            name=info.name,
            provider=info.provider_type,
            current_path=info.current_path,
            is_mounted=info.is_mounted,
        )
  • Pydantic model defining the response schema for workspace_switch tool
    class WorkspaceSwitchResponse(BaseModel):
        """Response from workspace switch"""
    
        name: str
        provider: ProviderType
        current_path: str
        is_mounted: bool
  • Core helper method in WorkspaceManager that performs the actual workspace switch by updating current_namespace_id
    async def switch_workspace(self, name: str) -> WorkspaceInfo:
        """
        Switch to a different workspace.
    
        Args:
            name: Workspace name
    
        Returns:
            WorkspaceInfo for the switched workspace
    
        Raises:
            ValueError: If workspace doesn't exist
        """
        # Find namespace by name
        for nid, info in self._namespace_to_info.items():
            if info.name == name:
                self._current_namespace_id = nid
                return info
    
        raise ValueError(f"Workspace '{name}' does not exist")

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/chrishayuk/chuk-mcp-vfs'

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