Create Broadcast Message
create_broadcast_messageCreate broadcast messages on GitLab to communicate important updates to users. Requires administrator access.
Instructions
Create a GitLab broadcast message. Requires administrator privileges on the GitLab instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | Yes | Message text to display | |
| starts_at | No | ISO 8601 timestamp when the message starts | |
| ends_at | No | ISO 8601 timestamp when the message ends | |
| color | No | Background color in hex format, e.g. "#E75E40" | |
| font | No | Foreground (font) color in hex format | |
| target_access_levels | No | Access levels to target: 10=Guest, 20=Reporter, 30=Developer, 40=Maintainer, 50=Owner | |
| target_path | No | Path glob for pages where the message should appear | |
| broadcast_type | No | Broadcast type: "banner" or "notification" | |
| dismissable | No | Whether users can dismiss the broadcast message | |
| theme | No | Theme name (GitLab 16.9+), e.g. "indigo", "red" | |
| userCredentials | No | Your GitLab credentials (optional — falls back to the configured env token if not provided) |
Implementation Reference
- src/tools.ts:1697-1713 (handler)The Tool object for 'create_broadcast_message' containing the handler function that validates credentials, strips userCredentials from input, and delegates to client.createBroadcastMessage() via the GitLab REST API.
const createBroadcastMessageTool: Tool = { name: 'create_broadcast_message', title: 'Create Broadcast Message', description: 'Create a GitLab broadcast message. Requires administrator privileges on the GitLab instance.', requiresAuth: true, requiresWrite: true, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: withUserAuth(z.object(BroadcastMessageFields)), handler: async (input, client, userConfig) => { const credentials = input.userCredentials ? validateUserConfig(input.userCredentials) : userConfig; if (!credentials) { throw new Error('User authentication is required for creating broadcast messages.'); } const { userCredentials, ...body } = input; return client.createBroadcastMessage(body, credentials); }, }; - src/tools.ts:1651-1662 (schema)BroadcastMessageFields schema defining all input fields: message (required), starts_at, ends_at, color, font, target_access_levels, target_path, broadcast_type, dismissable, and theme.
const BroadcastMessageFields = { message: z.string().min(1).describe('Message text to display'), starts_at: z.string().datetime().optional().describe('ISO 8601 timestamp when the message starts'), ends_at: z.string().datetime().optional().describe('ISO 8601 timestamp when the message ends'), color: z.string().optional().describe('Background color in hex format, e.g. "#E75E40"'), font: z.string().optional().describe('Foreground (font) color in hex format'), target_access_levels: z.array(z.number().int()).optional().describe('Access levels to target: 10=Guest, 20=Reporter, 30=Developer, 40=Maintainer, 50=Owner'), target_path: z.string().optional().describe('Path glob for pages where the message should appear'), broadcast_type: z.enum(['banner', 'notification']).optional().describe('Broadcast type: "banner" or "notification"'), dismissable: z.boolean().optional().describe('Whether users can dismiss the broadcast message'), theme: z.string().optional().describe('Theme name (GitLab 16.9+), e.g. "indigo", "red"'), }; - src/tools.ts:2307-2317 (registration)The writeTools array that registers 'create_broadcast_message' (via createBroadcastMessageTool) along with other write tools, making it available to the MCP server.
export const writeTools: Tool[] = [ createIssueTool, createMergeRequestTool, createNoteTool, deleteNoteTool, updateNoteTool, managePipelineTool, createBroadcastMessageTool, updateBroadcastMessageTool, deleteBroadcastMessageTool, ]; - src/gitlab-client.ts:2669-2682 (helper)GitLabGraphQLClient.createBroadcastMessage() method that takes the input fields and makes a POST request to the GitLab REST API endpoint /api/v4/broadcast_messages.
async createBroadcastMessage(input: { message: string; starts_at?: string; ends_at?: string; color?: string; font?: string; target_access_levels?: number[]; target_path?: string; broadcast_type?: 'banner' | 'notification'; dismissable?: boolean; theme?: string; }, userConfig?: UserConfig): Promise<any> { return this.restRequest('POST', '/broadcast_messages', { body: input, userConfig, requiresWrite: true }); }