get_businesses
Retrieve a list of businesses within the DevHub account, including IDs and names, to streamline business-specific operations in the DevHub CMS MCP system.
Instructions
Get all businesses within the DevHub account
Returns a list of businesses with the following fields:
- id: Business ID that can be used in the other tools
- business_name: Business name
If only one business exists in the account, you can assume that the user wants to use that business for any business_id related tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/devhub_cms_mcp/server.py:49-69 (handler)The handler and registration for the 'get_businesses' MCP tool. The @mcp.tool() decorator registers the function as a tool named 'get_businesses'. The function fetches businesses from the DevHub API endpoint, filtering non-deleted ones ordered by name, and returns the list of business objects.@mcp.tool() def get_businesses() -> list: """Get all businesses within the DevHub account Returns a list of businesses with the following fields: - id: Business ID that can be used in the other tools - business_name: Business name If only one business exists in the account, you can assume that the user wants to use that business for any business_id related tools. """ client, base_url = get_client() params = { 'deleted': 0, 'limit': 20, 'order_by': 'business_name', 'project_type': 'default', } r = client.get('{}businesses/'.format(base_url), params=params) content = json.loads(r.content) return content['objects']
- src/devhub_cms_mcp/server.py:51-58 (schema)The docstring of the get_businesses function defines the tool's schema, describing no input parameters and the output format as a list of businesses with id and business_name fields."""Get all businesses within the DevHub account Returns a list of businesses with the following fields: - id: Business ID that can be used in the other tools - business_name: Business name If only one business exists in the account, you can assume that the user wants to use that business for any business_id related tools. """
- src/devhub_cms_mcp/server.py:15-21 (helper)Helper function get_client() used by get_businesses to obtain the OAuth1 authenticated client session and DevHub API base URL from environment variables.def get_client(): """Get DevHub API client and base_url.""" client = OAuth1Session( os.environ['DEVHUB_API_KEY'], client_secret=os.environ['DEVHUB_API_SECRET']) base_url = '{}/api/v2/'.format(os.environ['DEVHUB_BASE_URL']) return client, base_url