update_article
Update existing Intercom Help Center articles. Supports partial updates for title, body, description, state, author, and multilingual content. Modify only fields you need.
Instructions
Update an existing Intercom Help Center article. Supports partial updates and multilingual content.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Article ID (required) | |
| title | No | Updated article title (optional) | |
| body | No | Updated article content in HTML format (optional) | |
| description | No | Updated article description (optional) | |
| state | No | Updated article state (optional) | |
| author_id | No | Updated author ID (optional). Use list_admins to find valid IDs by name. | |
| translated_content | No | Updated multilingual content. Only provided fields will be updated. |
Implementation Reference
- src/index.ts:679-725 (handler)The handler function for the 'update_article' tool. It destructures the arguments (id, title, body, description, state, author_id, translated_content), validates the required 'id' field, builds a payload with only the provided fields, ensures at least one field is provided, calls the Intercom API via PUT /articles/{id}, and returns the updated article JSON.
if (name === 'update_article') { const { id, title, body, description, state, author_id, translated_content } = args as { id: string; title?: string; body?: string; description?: string; state?: 'draft' | 'published'; author_id?: number; translated_content?: { [locale: string]: { title?: string; body?: string; description?: string; state?: 'draft' | 'published'; } } }; // 驗證必填欄位 if (!id) { throw new Error('Article ID is required'); } // 建構 update payload(只包含提供的欄位) const payload: any = {}; if (title) payload.title = title; if (body) payload.body = body; if (description) payload.description = description; if (state) payload.state = state; if (author_id) payload.author_id = author_id; if (translated_content) payload.translated_content = translated_content; // 確保至少有一個欄位要更新 if (Object.keys(payload).length === 0) { throw new Error('At least one field must be provided for update'); } const article = await callIntercomAPI(`/articles/${id}`, 'PUT', payload); return { content: [{ type: 'text', text: JSON.stringify(article, null, 2) }] }; } - src/index.ts:270-328 (schema)The input schema for the 'update_article' tool, registered as part of the ListToolsRequestSchema handler. Defines the 'id' (required), 'title', 'body', 'description', 'state' (enum: draft/published), 'author_id', and 'translated_content' (with locale keys containing title, body, description, state) properties.
name: 'update_article', description: 'Update an existing Intercom Help Center article. Supports partial updates and multilingual content.', inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'Article ID (required)' }, title: { type: 'string', description: 'Updated article title (optional)' }, body: { type: 'string', description: 'Updated article content in HTML format (optional)' }, description: { type: 'string', description: 'Updated article description (optional)' }, state: { type: 'string', enum: ['draft', 'published'], description: 'Updated article state (optional)' }, author_id: { type: 'number', description: 'Updated author ID (optional). Use list_admins to find valid IDs by name.' }, translated_content: { type: 'object', description: 'Updated multilingual content. Only provided fields will be updated.', additionalProperties: { type: 'object', properties: { title: { type: 'string', description: 'Updated translated title' }, body: { type: 'string', description: 'Updated translated content in HTML' }, description: { type: 'string', description: 'Updated translated description' }, state: { type: 'string', enum: ['draft', 'published'], description: 'Updated translation state' } } } } }, required: ['id'] } - src/index.ts:269-270 (registration)The tool registration entry in the tools array returned by ListToolsRequestSchema. The 'update_article' tool is listed with its name, description, and inputSchema, making it available to MCP clients.
{ name: 'update_article', - src/index.ts:113-145 (helper)The callIntercomAPI helper function used by the handler to make the HTTP PUT request to Intercom's API at /articles/{id}.
async function callIntercomAPI( endpoint: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE' = 'GET', body?: any ): Promise<any> { const options: RequestInit = { method, headers: { 'Authorization': `Bearer ${INTERCOM_TOKEN}`, 'Accept': 'application/json', 'Content-Type': 'application/json', 'Intercom-Version': '2.14' } }; if (body && (method === 'POST' || method === 'PUT')) { options.body = JSON.stringify(body); } const response = await fetch(`${INTERCOM_API_BASE}${endpoint}`, options); if (!response.ok) { const error = await response.text(); throw new Error(`Intercom API error: ${response.status} - ${error}`); } // Handle 204 No Content response if (response.status === 204) { return { success: true }; } return response.json(); }