delete_tag
Delete a tag and remove it from all linked receipts and transactions.
Instructions
Delete tag. Delete a tag and remove it from all tagged items.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Tag ID |
Implementation Reference
- src/index.js:288-289 (handler)The response formatting handler for the 'delete_tag' tool. When the API call succeeds, it simply returns the string 'Tag deleted.' The actual deletion logic is delegated to an API call via executeAPICall (line 346) which uses the dynamically-generated pathMap to route to the correct API endpoint.
case "delete_tag": return "Tag deleted."; - src/index.js:140-155 (registration)Dynamic tool registration via OpenAPI spec. The 'delete_tag' tool name is the operationId from the API spec, registered dynamically in the tools array and pathMap at lines 140-155. The tool definition (name, description, inputSchema) is fetched from the API and built on startup.
tools.push({ name: operationId, description: `${operation.summary}. ${operation.description || ""}`.trim(), inputSchema: { type: "object", properties, required: required.length > 0 ? required : undefined, }, }); pathMap[operationId] = { method: method.toUpperCase(), path, parameters: operation.parameters || [], hasBody: !!operation.requestBody, }; - src/index.js:106-147 (schema)Input schema is dynamically generated from the OpenAPI spec parameters and requestBody for each operation, including 'delete_tag'. The schema properties and required fields are derived from the API spec's parameters and request body definitions.
// Build input schema from parameters and requestBody const properties = {}; const required = []; // Add parameters (path + query) if (operation.parameters) { for (const param of operation.parameters) { properties[param.name] = { type: param.schema?.type || "string", description: param.description, enum: param.schema?.enum, default: param.schema?.default, }; if (param.required) { required.push(param.name); } } } // Add request body properties if (operation.requestBody?.content?.["application/json"]?.schema?.properties) { const bodyProps = operation.requestBody.content["application/json"].schema.properties; const bodyRequired = operation.requestBody.content["application/json"].schema.required || []; for (const [name, prop] of Object.entries(bodyProps)) { properties[name] = { type: prop.type || "string", description: prop.description, enum: prop.enum, default: prop.default, }; } required.push(...bodyRequired); } tools.push({ name: operationId, description: `${operation.summary}. ${operation.description || ""}`.trim(), inputSchema: { type: "object", properties, required: required.length > 0 ? required : undefined, }, - src/index.js:165-224 (helper)The executeAPICall helper that performs the actual HTTP request for the delete_tag operation. It builds the URL with path parameters, adds query params, and sends the request with the proper method (e.g., DELETE) to the API endpoint defined in pathMap.
async function executeAPICall(pathInfo, args) { const { method, path, parameters, hasBody } = pathInfo; // Build URL with path parameters replaced let url = `${BASE_URL}${path}`; const queryParams = new URLSearchParams(); for (const param of parameters) { const value = args[param.name]; if (value === undefined) continue; if (param.in === "path") { url = url.replace(`{${param.name}}`, encodeURIComponent(value)); } else if (param.in === "query") { queryParams.set(param.name, value); } } const queryString = queryParams.toString(); if (queryString) { url += `?${queryString}`; } // Build request body (exclude path/query params) let body = undefined; if (hasBody) { const bodyParams = {}; const paramNames = new Set(parameters.map(p => p.name)); for (const [key, value] of Object.entries(args)) { if (!paramNames.has(key) && value !== undefined) { bodyParams[key] = value; } } if (Object.keys(bodyParams).length > 0) { body = JSON.stringify(bodyParams); } } const response = await fetch(url, { method, headers: { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }, body, }); let data; try { data = await response.json(); } catch { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } if (!data.success) { throw new Error(data.error?.message || `Request failed (${response.status})`); } return data; } - src/index.js:334-360 (helper)The CallToolRequestSchema handler that dispatches tool calls. When 'delete_tag' is called, it looks up the pathInfo from pathMap (line 336), calls executeAPICall (line 346) to make the HTTP request, then formats the response via formatResponse (line 347) which returns 'Tag deleted.'
server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const pathInfo = pathMap[name]; if (!pathInfo) { return { content: [{ type: "text", text: `Error: Unknown tool "${name}"` }], isError: true, }; } try { const response = await executeAPICall(pathInfo, args || {}); const formatted = formatResponse(name, response); return { content: [{ type: "text", text: formatted }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true, }; } }); const transport = new StdioServerTransport(); await server.connect(transport); console.error("Mintline MCP server running"); }