watson_list_spaces
List your Watson deployment spaces in any IBM Cloud region to organize and manage your AI deployments.
Instructions
List Watson deployment spaces
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | No |
Implementation Reference
- src/tools/watson/index.ts:56-58 (handler)The handler for the watson_list_spaces tool. It makes a GET request to the Watson ML API at /v2/spaces (with optional region override) and returns the list of deployment spaces, wrapped in safeTool error handling.
server.tool("watson_list_spaces", "List Watson deployment spaces", { region: z.string().optional(), }, async (p) => safeTool(() => client.get(`${ml(p.region||r)}/v2/spaces`, {version:ver}))); - src/tools/watson/index.ts:56-58 (registration)The tool is registered via server.tool() call within registerWatsonTools(). This function is invoked from src/server.ts line 68.
server.tool("watson_list_spaces", "List Watson deployment spaces", { region: z.string().optional(), }, async (p) => safeTool(() => client.get(`${ml(p.region||r)}/v2/spaces`, {version:ver}))); - src/tools/watson/index.ts:57-57 (schema)Input schema for watson_list_spaces: accepts an optional 'region' string parameter. No output schema is explicitly defined; the raw API response is returned.
region: z.string().optional(), - src/config.ts:75-77 (helper)The WATSON_ML endpoint helper constructs the base URL (e.g., https://us-south.ml.cloud.ibm.com) used by the handler to form the /v2/spaces request.
WATSON_ML: (region: string) => `https://${region}.ml.cloud.ibm.com`, - src/lib/utils.ts:70-77 (helper)The safeTool helper wraps the handler's async function, catching errors and returning properly formatted MCP success/error responses.
export async function safeTool<T>(fn: () => Promise<T>): Promise<ReturnType<typeof successContent> | ReturnType<typeof errorContent>> { try { const result = await fn(); return successContent(result); } catch (error) { return errorContent(error); } }