update_qiita_article
Modify an existing Qiita article by updating its title, body, tags, privacy status, organization, or slide mode using the article ID. Simplifies content management on Qiita.
Instructions
update an existing Qiita article
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | Markdown formatted content | |
| item_id | Yes | The ID of the article to update | |
| organization_url_name | No | The url_name of the organization for the article | |
| private | No | Whether the article is private | |
| slide | No | Whether to enable slide mode | |
| tags | No | List of tags for the article | |
| title | Yes | Article title |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"body": {
"description": "Markdown formatted content",
"type": "string"
},
"item_id": {
"description": "The ID of the article to update",
"type": "string"
},
"organization_url_name": {
"description": "The url_name of the organization for the article",
"type": "string"
},
"private": {
"description": "Whether the article is private",
"type": "boolean"
},
"slide": {
"description": "Whether to enable slide mode",
"type": "boolean"
},
"tags": {
"description": "List of tags for the article",
"items": {
"additionalProperties": false,
"properties": {
"name": {
"description": "Tag name",
"type": "string"
},
"versions": {
"description": "Versions (optional)",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"name"
],
"type": "object"
},
"type": "array"
},
"title": {
"description": "Article title",
"type": "string"
}
},
"required": [
"item_id",
"title",
"body"
],
"type": "object"
}
Implementation Reference
- src/tools/qiitaTools.ts:104-117 (handler)The handler function that implements the 'update_qiita_article' tool logic. It destructures the params, calls the QiitaApiService.updateItem method, formats a success response with Japanese text, or returns an error response.const updateQiitaArticle = async (params: UpdateArticleParams): Promise<any> => { try { const { item_id, ...updateParams } = params; const updatedItem = await apiService.updateItem(item_id, updateParams); return createSuccessResponse( `記事が正常に更新されました。\nタイトル: ${updatedItem.title}\nURL: ${updatedItem.url}\n\n` + JSON.stringify(updatedItem, null, 2) ); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return createErrorResponse(`Error updating Qiita article: ${errorMessage}`); } };
- src/tools/qiitaTools.ts:90-102 (schema)Zod schema defining the input parameters for the update_qiita_article tool, including item_id, title, body, optional tags, private, organization_url_name, and slide.const updateArticleSchema = z.object({ item_id: z.string().describe("The ID of the article to update"), title: z.string().describe("Article title"), body: z.string().describe("Markdown formatted content"), tags: z.array(z.object({ name: z.string().describe("Tag name"), versions: z.array(z.string()).optional().describe("Versions (optional)") })).optional().describe("List of tags for the article"), private: z.boolean().optional().describe("Whether the article is private"), organization_url_name: z.string().optional().describe("The url_name of the organization for the article"), slide: z.boolean().optional().describe("Whether to enable slide mode") }); type UpdateArticleParams = z.infer<typeof updateArticleSchema>;
- src/tools/qiitaTools.ts:143-148 (registration)Registration of the 'update_qiita_article' tool within the getToolDefinitions() export, specifying name, description, parameters schema, and handler.{ name: "update_qiita_article", description: "update an existing Qiita article", parameters: updateArticleSchema.shape, handler: (params: UpdateArticleParams) => updateQiitaArticle(params) },
- src/services/qiita.ts:148-178 (helper)The QiitaApiService.updateItem method, which performs the actual PATCH request to the Qiita API to update the article, handles authentication, removes undefined fields, and filters the response.updateItem = async ( item_id: string, params: { title: string; body: string; tags?: Array<{ name: string; versions?: string[] }>; private?: boolean; organization_url_name?: string; slide?: boolean; } ): Promise<any> => { this.validateToken(); const requestBody = this.removeUndefinedFields(params); const response = await fetch( `${this.baseUrl}/items/${item_id}`, { method: 'PATCH', headers: this.getHeaders(), body: JSON.stringify(requestBody) } ); if (!response.ok) { await this.handleErrorResponse(response); } const item = await response.json(); return this.filterItem(item); };