cortex_create_organization
Create a new organization in Cortex. Requires superadmin API key. Input name and description.
Instructions
Create a new organization in Cortex (requires superadmin API key)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Organization name (used as ID, no spaces recommended) | |
| description | Yes | Organization description |
Implementation Reference
- src/tools/organizations.ts:103-157 (handler)The MCP tool handler for 'cortex_create_organization'. Validates that the superadmin key is available, then calls client.createOrganization with name and description from the Zod schema, and returns a formatted JSON response with the new organization details.
server.tool( "cortex_create_organization", "Create a new organization in Cortex (requires superadmin API key)", { name: z .string() .describe("Organization name (used as ID, no spaces recommended)"), description: z.string().describe("Organization description"), }, async ({ name, description }) => { try { if (!client.superadminAvailable) { return { content: [ { type: "text" as const, text: "Organization management requires CORTEX_SUPERADMIN_KEY environment variable to be set.", }, ], isError: true, }; } const org = await client.createOrganization({ name, description }); return { content: [ { type: "text" as const, text: JSON.stringify( { id: org.id, name: org.name, description: org.description, status: org.status, message: `Organization "${org.name}" created successfully.`, }, null, 2, ), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error creating organization: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, ); - src/tools/organizations.ts:106-111 (schema)The Zod input schema for the cortex_create_organization tool, requiring 'name' (string) and 'description' (string).
{ name: z .string() .describe("Organization name (used as ID, no spaces recommended)"), description: z.string().describe("Organization description"), }, - src/tools/organizations.ts:5-235 (registration)The registerOrganizationTools function registers all organization tools on the MCP server, including cortex_create_organization via server.tool().
export function registerOrganizationTools( server: McpServer, client: CortexClient, ): void { server.tool( "cortex_list_organizations", "List all organizations (requires superadmin API key via CORTEX_SUPERADMIN_KEY)", {}, async () => { try { if (!client.superadminAvailable) { return { content: [ { type: "text" as const, text: "Organization management requires CORTEX_SUPERADMIN_KEY environment variable to be set.", }, ], isError: true, }; } const orgs = await client.listOrganizations(); const summary = orgs.map((o) => ({ id: o.id, name: o.name, description: o.description, status: o.status, createdAt: o.createdAt ? new Date(o.createdAt).toISOString() : undefined, })); return { content: [ { type: "text" as const, text: JSON.stringify(summary, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error listing organizations: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, ); server.tool( "cortex_get_organization", "Get details about a specific organization (requires superadmin API key)", { orgId: z.string().describe("The organization ID or name"), }, async ({ orgId }) => { try { if (!client.superadminAvailable) { return { content: [ { type: "text" as const, text: "Organization management requires CORTEX_SUPERADMIN_KEY environment variable to be set.", }, ], isError: true, }; } const org = await client.getOrganization(orgId); return { content: [ { type: "text" as const, text: JSON.stringify(org, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error getting organization: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, ); server.tool( "cortex_create_organization", "Create a new organization in Cortex (requires superadmin API key)", { name: z .string() .describe("Organization name (used as ID, no spaces recommended)"), description: z.string().describe("Organization description"), }, async ({ name, description }) => { try { if (!client.superadminAvailable) { return { content: [ { type: "text" as const, text: "Organization management requires CORTEX_SUPERADMIN_KEY environment variable to be set.", }, ], isError: true, }; } const org = await client.createOrganization({ name, description }); return { content: [ { type: "text" as const, text: JSON.stringify( { id: org.id, name: org.name, description: org.description, status: org.status, message: `Organization "${org.name}" created successfully.`, }, null, 2, ), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error creating organization: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, ); server.tool( "cortex_update_organization", "Update an organization's description or status (requires superadmin API key)", { orgId: z.string().describe("The organization ID or name"), description: z .string() .optional() .describe("New description for the organization"), status: z .enum(["Active", "Locked"]) .optional() .describe('New status: "Active" or "Locked"'), }, async ({ orgId, description, status }) => { try { if (!client.superadminAvailable) { return { content: [ { type: "text" as const, text: "Organization management requires CORTEX_SUPERADMIN_KEY environment variable to be set.", }, ], isError: true, }; } const updates: Record<string, string> = {}; if (description !== undefined) updates.description = description; if (status !== undefined) updates.status = status; if (Object.keys(updates).length === 0) { return { content: [ { type: "text" as const, text: "No updates provided. Specify at least description or status.", }, ], isError: true, }; } const org = await client.updateOrganization(orgId, updates); return { content: [ { type: "text" as const, text: JSON.stringify( { id: org.id, name: org.name, description: org.description, status: org.status, message: `Organization "${org.name}" updated successfully.`, }, null, 2, ), }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error updating organization: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, ); } - src/index.ts:12-44 (registration)The main entry point imports and calls registerOrganizationTools to wire up the organization tools (including cortex_create_organization) on the MCP server.
import { registerOrganizationTools } from "./tools/organizations.js"; import { registerUserTools } from "./tools/users.js"; import { registerResources } from "./resources.js"; import { registerPrompts } from "./prompts.js"; async function main(): Promise<void> { const config = getConfig(); if (!config.verifySsl) { process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; } const server = new McpServer({ name: "cortex-mcp", version: "1.2.0", description: "MCP server for Cortex - observable analysis and active response engine by StrangeBee/TheHive Project", }); const client = new CortexClient(config); // Core analysis tools registerAnalyzerTools(server, client); registerJobTools(server, client); registerResponderTools(server, client); registerBulkTools(server, client); // Administration tools registerAnalyzerDefinitionTools(server, client); registerResponderDefinitionTools(server, client); registerStatusTools(server, client); registerOrganizationTools(server, client); registerUserTools(server, client); - src/client.ts:359-376 (helper)The CortexClient.createOrganization method that makes the actual HTTP POST request to the /organization API endpoint with superadmin auth (useSuperadmin=true). It sends name, description, and defaults status to 'Active'.
async createOrganization(data: { name: string; description: string; status?: string; }): Promise<Organization> { return this.request<Organization>( "/organization", { method: "POST", body: JSON.stringify({ name: data.name, description: data.description, status: data.status ?? "Active", }), }, true, ); }