set-organization
Assigns an organization ID to scope all subsequent API requests to a specific organization.
Instructions
Set the organization ID for subsequent requests
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orgId | Yes | Organization ID |
Implementation Reference
- build/index.js:573-592 (handler)The handler for the 'set-organization' tool. It accepts an orgId (number), stores it in the global 'orgId' variable, and returns a success message. The stored orgId is then automatically attached to subsequent API requests via the authenticatedRequest helper.
// Set organization ID tool server.tool("set-organization", "Set the organization ID for subsequent requests", { orgId: z.number().describe("Organization ID") }, async ({ orgId: newOrgId }) => { try { orgId = newOrgId; return { content: [{ type: "text", text: `Organization ID set to ${newOrgId}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error setting organization ID: ${getErrorMessage(error)}` }] }; } }); - build/index.js:574-576 (schema)Schema definition for 'set-organization' tool. Defines the input parameter: orgId as a Zod number with description 'Organization ID'.
server.tool("set-organization", "Set the organization ID for subsequent requests", { orgId: z.number().describe("Organization ID") }, async ({ orgId: newOrgId }) => { - build/index.js:574-592 (registration)Registration of the 'set-organization' tool on the MCP server using server.tool() with name 'set-organization', description 'Set the organization ID for subsequent requests'.
server.tool("set-organization", "Set the organization ID for subsequent requests", { orgId: z.number().describe("Organization ID") }, async ({ orgId: newOrgId }) => { try { orgId = newOrgId; return { content: [{ type: "text", text: `Organization ID set to ${newOrgId}` }] }; } catch (error) { return { isError: true, content: [{ type: "text", text: `Error setting organization ID: ${getErrorMessage(error)}` }] }; } }); - build/index.js:42-42 (helper)Global variable 'orgId' that stores the organization ID set by the tool, initialized to null.
let orgId = null; - build/index.js:66-69 (helper)The authenticatedRequest helper uses the stored orgId by appending it as a query parameter (orgId.toString()) to all API requests when orgId is not null.
// Add orgId if available if (orgId !== null) { queryParams.orgId = orgId.toString(); }