innov-mcp-tasks 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.mjs +65 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,6 +57,7 @@ Na raiz do repo existe [`.cursor/mcp.json`](../.cursor/mcp.json) com **dois** se
|
|
|
57
57
|
- `projects_list` — lista projetos visíveis (`GET /api/v1/projects`)
|
|
58
58
|
- `project_create` — cria projeto (`POST /api/v1/projects`)
|
|
59
59
|
- `task_get`, `task_create`, `task_update_status`, `task_assign`, `task_assign_to_me`
|
|
60
|
+
- `task_attachment_download` — baixa anexo por `attachment_id` (conteúdo em base64; ids em `task_get` → `attachments`)
|
|
60
61
|
|
|
61
62
|
### Anotações / documentação
|
|
62
63
|
|
package/index.mjs
CHANGED
|
@@ -50,6 +50,43 @@ async function apiFetch(path, init = {}) {
|
|
|
50
50
|
return data;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
async function apiFetchBinary(path) {
|
|
54
|
+
if (!base || !token) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'Defina INNOV_API_BASE_URL e INNOV_API_TOKEN no ambiente ou num .env.',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const url = `${base}${path.startsWith('/') ? path : `/${path}`}`;
|
|
60
|
+
const res = await fetch(url, {
|
|
61
|
+
headers: {
|
|
62
|
+
Authorization: `Bearer ${token}`,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
if (!res.ok) {
|
|
66
|
+
const text = await res.text();
|
|
67
|
+
let msg = text.slice(0, 800);
|
|
68
|
+
try {
|
|
69
|
+
const data = text ? JSON.parse(text) : null;
|
|
70
|
+
if (data && (data.message || data.error)) {
|
|
71
|
+
msg = String(data.message || data.error);
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
/* texto bruto */
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`HTTP ${res.status}: ${msg}`);
|
|
77
|
+
}
|
|
78
|
+
const buffer = Buffer.from(await res.arrayBuffer());
|
|
79
|
+
const disposition = res.headers.get('content-disposition') || '';
|
|
80
|
+
const filenameMatch = disposition.match(/filename="?([^";\n]+)"?/i);
|
|
81
|
+
const filename = filenameMatch?.[1]?.trim() || 'attachment';
|
|
82
|
+
return {
|
|
83
|
+
buffer,
|
|
84
|
+
contentType: res.headers.get('content-type') || 'application/octet-stream',
|
|
85
|
+
filename,
|
|
86
|
+
size: buffer.length,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
53
90
|
const server = new McpServer({ name: 'innov-tasks', version: '1.0.0' });
|
|
54
91
|
|
|
55
92
|
server.registerTool(
|
|
@@ -105,6 +142,34 @@ server.registerTool(
|
|
|
105
142
|
},
|
|
106
143
|
);
|
|
107
144
|
|
|
145
|
+
server.registerTool(
|
|
146
|
+
'task_attachment_download',
|
|
147
|
+
{
|
|
148
|
+
description:
|
|
149
|
+
'Baixa anexo de tarefa (GET /task-attachments/{id}/download). Requer Bearer Sanctum. ' +
|
|
150
|
+
'Retorna metadados e conteúdo em base64 (útil para zip, pdf, docx, txt, srt, etc.). ' +
|
|
151
|
+
'Use task_get para listar attachments[].id da tarefa.',
|
|
152
|
+
inputSchema: { attachment_id: z.number().int().positive() },
|
|
153
|
+
},
|
|
154
|
+
async (args) => {
|
|
155
|
+
try {
|
|
156
|
+
const file = await apiFetchBinary(
|
|
157
|
+
`/api/v1/task-attachments/${args.attachment_id}/download`,
|
|
158
|
+
);
|
|
159
|
+
return jsonText({
|
|
160
|
+
attachment_id: args.attachment_id,
|
|
161
|
+
filename: file.filename,
|
|
162
|
+
content_type: file.contentType,
|
|
163
|
+
size_bytes: file.size,
|
|
164
|
+
content_base64: file.buffer.toString('base64'),
|
|
165
|
+
hint: 'Decodifique content_base64 para gravar o ficheiro localmente.',
|
|
166
|
+
});
|
|
167
|
+
} catch (e) {
|
|
168
|
+
return jsonError(e instanceof Error ? e.message : String(e));
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
);
|
|
172
|
+
|
|
108
173
|
server.registerTool(
|
|
109
174
|
'projects_list',
|
|
110
175
|
{
|