stock_item
Save articles to your Qiita stock list for later reading and reference by providing the article ID.
Instructions
指定された記事をストックします
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| itemId | Yes | 記事ID |
Implementation Reference
- src/tools/handlers.ts:108-111 (handler)Handler for the 'stock_item' MCP tool. Defines the Zod input schema and execute function that calls QiitaApiClient.stockItem with the itemId.stock_item: { schema: itemIdSchema, execute: async ({ itemId }, client) => client.stockItem(itemId), },
- src/tools/definitions.ts:292-305 (schema)MCP tool schema definition for 'stock_item', used in ListTools response. Specifies input schema requiring 'itemId'.{ name: 'stock_item', description: '指定された記事をストックします', inputSchema: { type: 'object', properties: { itemId: { type: 'string', description: '記事ID', }, }, required: ['itemId'], }, },
- src/qiitaApiClient.ts:105-109 (helper)Core implementation in QiitaApiClient that authenticates and sends PUT request to Qiita API endpoint /items/{itemId}/stock to stock the item.async stockItem(itemId: string) { this.assertAuthenticated(); await this.client.put(`/items/${itemId}/stock`); return { success: true }; }
- src/index.ts:30-65 (registration)MCP server request handler for CallToolRequestSchema, which looks up the handler by name from toolHandlers, parses args, executes the tool handler with Qiita client, and returns result as text.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const accessToken = process.env.QIITA_ACCESS_TOKEN; const qiita = new QiitaApiClient(accessToken); const handler = toolHandlers[name]; try { if (!handler) { throw new Error(`未知のツール: ${name}`); } const parsedArgs = handler.schema.parse(args ?? {}); const result = await handler.execute(parsedArgs, qiita); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error: any) { const message = error?.message ?? String(error); return { content: [ { type: 'text', text: `エラーが発生しました: ${message}`, }, ], isError: true, }; } });
- src/index.ts:26-28 (registration)MCP server request handler for ListToolsRequestSchema, which returns the array of tool definitions including 'stock_item' schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });