list_business_units
Retrieve and display all business units from the SD Elements platform using paginated results for efficient data management and integration.
Instructions
List all business units
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_size | No | Number of results per page (optional) |
Implementation Reference
- Implementation of the list_business_units tool handler, which initializes the API client if needed, builds parameters using build_params, calls the API to list business units, and returns the result as formatted JSON.@mcp.tool() async def list_business_units(ctx: Context, page_size: Optional[int] = None, include: Optional[str] = None, expand: Optional[str] = None) -> str: """List all business units""" global api_client if api_client is None: api_client = init_api_client() params = build_params({"page_size": page_size, "include": include, "expand": expand}) result = api_client.list_business_units(params) return json.dumps(result, indent=2)
- src/sde_mcp_server/tools/__init__.py:8-8 (registration)Import of business_units module in tools/__init__.py, which executes the @mcp.tool() decorator to register the list_business_units tool with the MCP server.from .business_units import *
- Shared helper function build_params that constructs the API request parameters from the tool's input arguments, filtering out None values. Used by list_business_units and likely other tools.def build_params(args: Dict[str, Any]) -> Dict[str, Any]: """Helper function for building params""" params = {} if "page_size" in args and args["page_size"] is not None: params["page_size"] = args["page_size"] if "include" in args and args["include"] is not None: params["include"] = args["include"] if "expand" in args and args["expand"] is not None: params["expand"] = args["expand"] return params