@artyfacts/mcp-server 1.1.5 → 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/dist/chunk-MQM6RARV.js +654 -0
- package/dist/chunk-U2KVKQ6X.js +692 -0
- package/dist/index.cjs +59 -0
- package/dist/index.js +1 -1
- package/dist/server.cjs +59 -0
- package/dist/server.js +1 -1
- package/package.json +2 -2
- package/src/server.ts +61 -0
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
// src/server.ts
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import {
|
|
5
|
+
CallToolRequestSchema,
|
|
6
|
+
ListToolsRequestSchema
|
|
7
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
+
var ARTYFACTS_TOOLS = [
|
|
9
|
+
// Organization tools
|
|
10
|
+
{
|
|
11
|
+
name: "get_organization",
|
|
12
|
+
description: "Get details about the current organization",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {},
|
|
16
|
+
required: []
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
// Project tools
|
|
20
|
+
{
|
|
21
|
+
name: "list_projects",
|
|
22
|
+
description: "List all projects in the organization",
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
limit: { type: "number", description: "Max results (default 50)" },
|
|
27
|
+
offset: { type: "number", description: "Pagination offset" }
|
|
28
|
+
},
|
|
29
|
+
required: []
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "get_project",
|
|
34
|
+
description: "Get details about a specific project",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
project_id: { type: "string", description: "Project ID" }
|
|
39
|
+
},
|
|
40
|
+
required: ["project_id"]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
// Artifact tools
|
|
44
|
+
{
|
|
45
|
+
name: "list_artifacts",
|
|
46
|
+
description: "List artifacts, optionally filtered by project",
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
project_id: { type: "string", description: "Filter by project" },
|
|
51
|
+
type: { type: "string", description: "Filter by type (goal, spec, research, etc.)" },
|
|
52
|
+
status: { type: "string", description: "Filter by status" },
|
|
53
|
+
limit: { type: "number", description: "Max results" }
|
|
54
|
+
},
|
|
55
|
+
required: []
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "get_artifact",
|
|
60
|
+
description: "Get a specific artifact by ID",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
artifact_id: { type: "string", description: "Artifact ID" }
|
|
65
|
+
},
|
|
66
|
+
required: ["artifact_id"]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "create_artifact",
|
|
71
|
+
description: "Create a new artifact (document, goal, spec, etc.)",
|
|
72
|
+
inputSchema: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
title: { type: "string", description: "Artifact title" },
|
|
76
|
+
type: { type: "string", description: "Artifact type: goal, spec, research, report, experiment, decision, doc" },
|
|
77
|
+
content: { type: "string", description: "Markdown content" },
|
|
78
|
+
goal_id: { type: "string", description: "The goal UUID this artifact belongs to \u2014 always pass this when working on a task" },
|
|
79
|
+
parent_id: { type: "string", description: "Parent artifact ID for nested artifacts" },
|
|
80
|
+
tags: { type: "array", items: { type: "string" }, description: "Tags for categorization" }
|
|
81
|
+
},
|
|
82
|
+
required: ["title", "type"]
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "update_artifact",
|
|
87
|
+
description: "Update an existing artifact",
|
|
88
|
+
inputSchema: {
|
|
89
|
+
type: "object",
|
|
90
|
+
properties: {
|
|
91
|
+
artifact_id: { type: "string", description: "Artifact ID" },
|
|
92
|
+
title: { type: "string", description: "New title" },
|
|
93
|
+
content: { type: "string", description: "New content" },
|
|
94
|
+
status: { type: "string", description: "New status" }
|
|
95
|
+
},
|
|
96
|
+
required: ["artifact_id"]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
// Section tools
|
|
100
|
+
{
|
|
101
|
+
name: "list_sections",
|
|
102
|
+
description: "List sections of an artifact",
|
|
103
|
+
inputSchema: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: {
|
|
106
|
+
artifact_id: { type: "string", description: "Artifact ID" }
|
|
107
|
+
},
|
|
108
|
+
required: ["artifact_id"]
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "get_section",
|
|
113
|
+
description: "Get a specific section",
|
|
114
|
+
inputSchema: {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: {
|
|
117
|
+
artifact_id: { type: "string", description: "Artifact ID" },
|
|
118
|
+
section_id: { type: "string", description: "Section ID" }
|
|
119
|
+
},
|
|
120
|
+
required: ["artifact_id", "section_id"]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "create_section",
|
|
125
|
+
description: "Create a new section on an artifact",
|
|
126
|
+
inputSchema: {
|
|
127
|
+
type: "object",
|
|
128
|
+
properties: {
|
|
129
|
+
artifact_id: { type: "string", description: "Artifact ID" },
|
|
130
|
+
section_id: { type: "string", description: "Section identifier (slug)" },
|
|
131
|
+
heading: { type: "string", description: "Section heading" },
|
|
132
|
+
content: { type: "string", description: "Markdown content" },
|
|
133
|
+
type: { type: "string", description: "Type: content, task, decision, blocker" },
|
|
134
|
+
position: { type: "number", description: "Order position" }
|
|
135
|
+
},
|
|
136
|
+
required: ["artifact_id", "section_id", "heading", "content"]
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "update_section",
|
|
141
|
+
description: "Update an existing section",
|
|
142
|
+
inputSchema: {
|
|
143
|
+
type: "object",
|
|
144
|
+
properties: {
|
|
145
|
+
artifact_id: { type: "string", description: "Artifact ID" },
|
|
146
|
+
section_id: { type: "string", description: "Section ID" },
|
|
147
|
+
heading: { type: "string", description: "New heading" },
|
|
148
|
+
content: { type: "string", description: "New content" },
|
|
149
|
+
task_status: { type: "string", description: "Task status if type=task" }
|
|
150
|
+
},
|
|
151
|
+
required: ["artifact_id", "section_id"]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: "delete_section",
|
|
156
|
+
description: "Delete a section",
|
|
157
|
+
inputSchema: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
artifact_id: { type: "string", description: "Artifact ID" },
|
|
161
|
+
section_id: { type: "string", description: "Section ID" }
|
|
162
|
+
},
|
|
163
|
+
required: ["artifact_id", "section_id"]
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
// Task tools
|
|
167
|
+
{
|
|
168
|
+
name: "list_tasks",
|
|
169
|
+
description: "List tasks (sections with type=task)",
|
|
170
|
+
inputSchema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
properties: {
|
|
173
|
+
artifact_id: { type: "string", description: "Filter by artifact" },
|
|
174
|
+
status: { type: "string", description: "Filter by status: pending, in_progress, done, blocked" },
|
|
175
|
+
assignee: { type: "string", description: "Filter by assignee agent" }
|
|
176
|
+
},
|
|
177
|
+
required: []
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "claim_task",
|
|
182
|
+
description: "Claim a task for the current agent",
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
task_id: { type: "string", description: "Task ID (section UUID)" }
|
|
187
|
+
},
|
|
188
|
+
required: ["task_id"]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "complete_task",
|
|
193
|
+
description: "Mark a task as complete. Always pass output_artifact_id if you created an artifact. Always pass output_references listing every entity you created or touched.",
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: "object",
|
|
196
|
+
properties: {
|
|
197
|
+
task_id: { type: "string", description: "Task ID" },
|
|
198
|
+
output_text: { type: "string", description: "Completion summary / what was done" },
|
|
199
|
+
output_url: { type: "string", description: "URL to deliverable (PR, doc, etc.)" },
|
|
200
|
+
output_artifact_id: { type: "string", description: "UUID of the primary artifact produced by this task" },
|
|
201
|
+
output_references: {
|
|
202
|
+
type: "array",
|
|
203
|
+
description: "All entities created or interacted with: artifacts, tasks, agents, goals",
|
|
204
|
+
items: {
|
|
205
|
+
type: "object",
|
|
206
|
+
properties: {
|
|
207
|
+
type: { type: "string", description: "artifact | task | agent | goal" },
|
|
208
|
+
id: { type: "string", description: "Entity UUID" },
|
|
209
|
+
title: { type: "string", description: "Display name for the reference card" },
|
|
210
|
+
subtitle: { type: "string", description: "Optional: type label, status, role, etc." }
|
|
211
|
+
},
|
|
212
|
+
required: ["type", "id", "title"]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
required: ["task_id"]
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
name: "block_task",
|
|
221
|
+
description: "Mark a task as blocked",
|
|
222
|
+
inputSchema: {
|
|
223
|
+
type: "object",
|
|
224
|
+
properties: {
|
|
225
|
+
task_id: { type: "string", description: "Task ID" },
|
|
226
|
+
reason: { type: "string", description: "Why it is blocked" },
|
|
227
|
+
blocker_type: { type: "string", description: "Type: decision, dependency, resource, external" }
|
|
228
|
+
},
|
|
229
|
+
required: ["task_id", "reason"]
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
name: "report_progress",
|
|
234
|
+
description: 'Report what you are currently doing on a task. Call this at meaningful milestones so your work is visible in the platform (e.g., "Analyzed 12 PRs, now writing the summary section", "Completed API design, starting implementation"). This is how your progress appears to humans watching the work.',
|
|
235
|
+
inputSchema: {
|
|
236
|
+
type: "object",
|
|
237
|
+
properties: {
|
|
238
|
+
task_id: { type: "string", description: "Task ID" },
|
|
239
|
+
message: { type: "string", description: "What you are doing right now \u2014 be specific and human-readable" },
|
|
240
|
+
metadata: { type: "object", description: "Optional extra context (step number, percentage, etc.)" }
|
|
241
|
+
},
|
|
242
|
+
required: ["task_id", "message"]
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "create_task",
|
|
247
|
+
description: "Create a new task under a goal. Use this to create actionable tasks \u2014 NOT create_artifact or create_section.",
|
|
248
|
+
inputSchema: {
|
|
249
|
+
type: "object",
|
|
250
|
+
properties: {
|
|
251
|
+
goal_id: { type: "string", description: "The goal UUID this task belongs to (required)" },
|
|
252
|
+
title: { type: "string", description: "Task title" },
|
|
253
|
+
description: { type: "string", description: "Task description / what needs to be done" },
|
|
254
|
+
priority: { type: "string", description: "Priority: low, medium, high, urgent" },
|
|
255
|
+
assigned_to: { type: "string", description: "Agent UUID to assign the task to" },
|
|
256
|
+
depends_on: { type: "array", items: { type: "string" }, description: "List of task UUIDs this task depends on" },
|
|
257
|
+
estimated_minutes: { type: "number", description: "Estimated time in minutes" }
|
|
258
|
+
},
|
|
259
|
+
required: ["goal_id", "title"]
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
// Agent tools
|
|
263
|
+
{
|
|
264
|
+
name: "list_agents",
|
|
265
|
+
description: "List all agents in the organization",
|
|
266
|
+
inputSchema: {
|
|
267
|
+
type: "object",
|
|
268
|
+
properties: {
|
|
269
|
+
status: { type: "string", description: "Filter by status: active, inactive" }
|
|
270
|
+
},
|
|
271
|
+
required: []
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: "get_agent",
|
|
276
|
+
description: "Get details about an agent",
|
|
277
|
+
inputSchema: {
|
|
278
|
+
type: "object",
|
|
279
|
+
properties: {
|
|
280
|
+
agent_id: { type: "string", description: "Agent ID" }
|
|
281
|
+
},
|
|
282
|
+
required: ["agent_id"]
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: "create_agent",
|
|
287
|
+
description: "Register a new AI agent with role, capabilities, and permissions",
|
|
288
|
+
inputSchema: {
|
|
289
|
+
type: "object",
|
|
290
|
+
properties: {
|
|
291
|
+
agentId: { type: "string", description: 'Unique agent ID (e.g., "engineering-agent", "qa-agent")' },
|
|
292
|
+
name: { type: "string", description: "Agent display name" },
|
|
293
|
+
role: { type: "string", description: "Role: pm, engineering, qa, research, content, design" },
|
|
294
|
+
description: { type: "string", description: "What this agent does - detailed description" },
|
|
295
|
+
capabilities: { type: "array", items: { type: "string" }, description: 'List of capabilities (e.g., ["code-review", "testing", "debugging"])' },
|
|
296
|
+
permissions: {
|
|
297
|
+
type: "object",
|
|
298
|
+
description: "Permission settings",
|
|
299
|
+
properties: {
|
|
300
|
+
write: { type: "boolean", description: "Can create/edit artifacts" },
|
|
301
|
+
delete: { type: "boolean", description: "Can delete artifacts" },
|
|
302
|
+
delegate_tasks: { type: "boolean", description: "Can assign tasks to other agents" }
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
systemPrompt: { type: "string", description: "System prompt for the agent" },
|
|
306
|
+
reportsToAgentId: { type: "string", description: 'Agent ID or UUID of the parent agent this agent reports to. Use agent slugs like "chief-of-staff" for readability.' }
|
|
307
|
+
},
|
|
308
|
+
required: ["agentId", "name", "role", "description"]
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "update_agent",
|
|
313
|
+
description: "Update an agent",
|
|
314
|
+
inputSchema: {
|
|
315
|
+
type: "object",
|
|
316
|
+
properties: {
|
|
317
|
+
agent_id: { type: "string", description: "Agent ID" },
|
|
318
|
+
name: { type: "string", description: "New name" },
|
|
319
|
+
status: { type: "string", description: "New status" },
|
|
320
|
+
config: { type: "object", description: "Updated config" }
|
|
321
|
+
},
|
|
322
|
+
required: ["agent_id"]
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
// Inbox tools (human-in-the-loop)
|
|
326
|
+
{
|
|
327
|
+
name: "create_inbox_item",
|
|
328
|
+
description: "Request human approval, a decision, or an answer before proceeding. Automatically blocks the task. Use for agent creation, risky actions, or anything requiring human sign-off.",
|
|
329
|
+
inputSchema: {
|
|
330
|
+
type: "object",
|
|
331
|
+
properties: {
|
|
332
|
+
task_id: { type: "string", description: "UUID of the task being blocked (required)" },
|
|
333
|
+
type: { type: "string", description: "Type: approval, decision, question" },
|
|
334
|
+
title: { type: "string", description: "Short summary shown to the human in the inbox" },
|
|
335
|
+
content: { type: "string", description: "Full context and details for the human" },
|
|
336
|
+
action: { type: "string", description: "Action to auto-execute if approved (e.g. agent.create)" },
|
|
337
|
+
action_payload: { type: "object", description: "Data for the action (e.g. full agent spec for agent.create)" },
|
|
338
|
+
options: { type: "array", description: "Options for decision type: [{id, label, description}]" }
|
|
339
|
+
},
|
|
340
|
+
required: ["task_id", "type", "title"]
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: "list_inbox",
|
|
345
|
+
description: "List pending inbox items (approvals, decisions, questions) waiting for human resolution.",
|
|
346
|
+
inputSchema: {
|
|
347
|
+
type: "object",
|
|
348
|
+
properties: {
|
|
349
|
+
status: { type: "string", description: "Filter by status: pending (default), resolved" },
|
|
350
|
+
type: { type: "string", description: "Filter by type: approval, decision, question" },
|
|
351
|
+
limit: { type: "number", description: "Max results (default 50)" }
|
|
352
|
+
},
|
|
353
|
+
required: []
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "resolve_inbox",
|
|
358
|
+
description: "Resolve an inbox item from the agent side. Humans resolve via the UI \u2014 only use this for automated resolution.",
|
|
359
|
+
inputSchema: {
|
|
360
|
+
type: "object",
|
|
361
|
+
properties: {
|
|
362
|
+
item_id: { type: "string", description: "Inbox item UUID" },
|
|
363
|
+
approved: { type: "boolean", description: "For approvals: true to approve, false to deny" },
|
|
364
|
+
chosen_option: { type: "string", description: "For decisions: the selected option ID" },
|
|
365
|
+
answer: { type: "string", description: "For questions: the answer text" },
|
|
366
|
+
notes: { type: "string", description: "Optional notes" }
|
|
367
|
+
},
|
|
368
|
+
required: ["item_id"]
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
// Search tools
|
|
372
|
+
{
|
|
373
|
+
name: "search_artifacts",
|
|
374
|
+
description: "Search artifacts by text query",
|
|
375
|
+
inputSchema: {
|
|
376
|
+
type: "object",
|
|
377
|
+
properties: {
|
|
378
|
+
query: { type: "string", description: "Search query" },
|
|
379
|
+
type: { type: "string", description: "Filter by type" },
|
|
380
|
+
limit: { type: "number", description: "Max results" }
|
|
381
|
+
},
|
|
382
|
+
required: ["query"]
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
// Goal management
|
|
386
|
+
{
|
|
387
|
+
name: "update_goal",
|
|
388
|
+
description: "Update a goal's title, description, or status. Use when human feedback reveals the goal was based on wrong premises and needs to be corrected before re-planning.",
|
|
389
|
+
inputSchema: {
|
|
390
|
+
type: "object",
|
|
391
|
+
properties: {
|
|
392
|
+
goal_id: { type: "string", description: "Goal UUID" },
|
|
393
|
+
title: { type: "string", description: "New title" },
|
|
394
|
+
description: { type: "string", description: "New description" },
|
|
395
|
+
status: { type: "string", description: "New status: active, completed, paused, cancelled" },
|
|
396
|
+
priority: { type: "string", description: "New priority: low, medium, high, urgent" }
|
|
397
|
+
},
|
|
398
|
+
required: ["goal_id"]
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
// Task cancellation
|
|
402
|
+
{
|
|
403
|
+
name: "cancel_task",
|
|
404
|
+
description: "Cancel and remove a task that should no longer be executed \u2014 e.g. because human feedback revealed it was based on wrong premises. Use alongside create_task to replace stale tasks with corrected ones.",
|
|
405
|
+
inputSchema: {
|
|
406
|
+
type: "object",
|
|
407
|
+
properties: {
|
|
408
|
+
task_id: { type: "string", description: "Task UUID to cancel" }
|
|
409
|
+
},
|
|
410
|
+
required: ["task_id"]
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
// Context tools
|
|
414
|
+
{
|
|
415
|
+
name: "get_task_context",
|
|
416
|
+
description: "Get full context for a task (org, project, artifact, related sections)",
|
|
417
|
+
inputSchema: {
|
|
418
|
+
type: "object",
|
|
419
|
+
properties: {
|
|
420
|
+
task_id: { type: "string", description: "Task ID" }
|
|
421
|
+
},
|
|
422
|
+
required: ["task_id"]
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
];
|
|
426
|
+
var ArtyfactsApiClient = class {
|
|
427
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
428
|
+
this.baseUrl = baseUrl;
|
|
429
|
+
this.apiKey = apiKey;
|
|
430
|
+
this.agentId = agentId;
|
|
431
|
+
}
|
|
432
|
+
async request(method, path, body) {
|
|
433
|
+
const url = `${this.baseUrl}${path}`;
|
|
434
|
+
const headers = {
|
|
435
|
+
"Authorization": `Bearer ${this.apiKey}`,
|
|
436
|
+
"Content-Type": "application/json"
|
|
437
|
+
};
|
|
438
|
+
if (this.agentId) {
|
|
439
|
+
headers["X-Agent-Id"] = this.agentId;
|
|
440
|
+
}
|
|
441
|
+
const response = await fetch(url, {
|
|
442
|
+
method,
|
|
443
|
+
headers,
|
|
444
|
+
body: body ? JSON.stringify(body) : void 0
|
|
445
|
+
});
|
|
446
|
+
if (!response.ok) {
|
|
447
|
+
const error = await response.json().catch(() => ({ error: "Request failed" }));
|
|
448
|
+
throw new Error(error.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
449
|
+
}
|
|
450
|
+
return response.json();
|
|
451
|
+
}
|
|
452
|
+
get(path) {
|
|
453
|
+
return this.request("GET", path);
|
|
454
|
+
}
|
|
455
|
+
getAgentId() {
|
|
456
|
+
return this.agentId;
|
|
457
|
+
}
|
|
458
|
+
post(path, body) {
|
|
459
|
+
return this.request("POST", path, body);
|
|
460
|
+
}
|
|
461
|
+
patch(path, body) {
|
|
462
|
+
return this.request("PATCH", path, body);
|
|
463
|
+
}
|
|
464
|
+
put(path, body) {
|
|
465
|
+
return this.request("PUT", path, body);
|
|
466
|
+
}
|
|
467
|
+
delete(path) {
|
|
468
|
+
return this.request("DELETE", path);
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
var toolHandlers = {
|
|
472
|
+
// Organization
|
|
473
|
+
get_organization: (client) => client.get("/org"),
|
|
474
|
+
// Projects
|
|
475
|
+
list_projects: (client, args) => {
|
|
476
|
+
const params = new URLSearchParams();
|
|
477
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
478
|
+
if (args.offset) params.set("offset", String(args.offset));
|
|
479
|
+
return client.get(`/projects?${params}`);
|
|
480
|
+
},
|
|
481
|
+
get_project: (client, args) => client.get(`/projects/${args.project_id}`),
|
|
482
|
+
// Artifacts
|
|
483
|
+
list_artifacts: (client, args) => {
|
|
484
|
+
const params = new URLSearchParams();
|
|
485
|
+
if (args.project_id) params.set("project_id", String(args.project_id));
|
|
486
|
+
if (args.type) params.set("type", String(args.type));
|
|
487
|
+
if (args.status) params.set("status", String(args.status));
|
|
488
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
489
|
+
return client.get(`/artifacts?${params}`);
|
|
490
|
+
},
|
|
491
|
+
get_artifact: (client, args) => client.get(`/artifacts/${args.artifact_id}`),
|
|
492
|
+
create_artifact: (client, args) => {
|
|
493
|
+
const envelope = {
|
|
494
|
+
aah_version: "0.3",
|
|
495
|
+
artifact: {
|
|
496
|
+
id: args.id || `artifact-${Date.now()}`,
|
|
497
|
+
title: args.title,
|
|
498
|
+
type: args.type || "document/sectioned",
|
|
499
|
+
artifact_type: args.artifact_type || args.type || "doc",
|
|
500
|
+
goal_id: args.goal_id,
|
|
501
|
+
parent_id: args.parent_id,
|
|
502
|
+
tags: args.tags
|
|
503
|
+
},
|
|
504
|
+
content: args.content ? {
|
|
505
|
+
media_type: "text/markdown",
|
|
506
|
+
body: args.content
|
|
507
|
+
} : void 0,
|
|
508
|
+
source: {
|
|
509
|
+
agent_id: client.getAgentId() || "mcp-agent"
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
return client.post("/artifacts", envelope);
|
|
513
|
+
},
|
|
514
|
+
update_artifact: (client, args) => {
|
|
515
|
+
const { artifact_id, ...body } = args;
|
|
516
|
+
return client.patch(`/artifacts/${artifact_id}`, body);
|
|
517
|
+
},
|
|
518
|
+
// Sections
|
|
519
|
+
list_sections: (client, args) => client.get(`/artifacts/${args.artifact_id}/sections`),
|
|
520
|
+
get_section: (client, args) => client.get(`/artifacts/${args.artifact_id}/sections/${args.section_id}`),
|
|
521
|
+
create_section: (client, args) => {
|
|
522
|
+
const { artifact_id, section_id, ...rest } = args;
|
|
523
|
+
const body = { id: section_id, ...rest };
|
|
524
|
+
return client.post(`/artifacts/${artifact_id}/sections`, body);
|
|
525
|
+
},
|
|
526
|
+
update_section: (client, args) => {
|
|
527
|
+
const { artifact_id, section_id, ...body } = args;
|
|
528
|
+
return client.patch(`/artifacts/${artifact_id}/sections/${section_id}`, body);
|
|
529
|
+
},
|
|
530
|
+
delete_section: (client, args) => client.delete(`/artifacts/${args.artifact_id}/sections/${args.section_id}`),
|
|
531
|
+
// Tasks
|
|
532
|
+
list_tasks: (client, args) => {
|
|
533
|
+
const params = new URLSearchParams();
|
|
534
|
+
if (args.artifact_id) params.set("artifact_id", String(args.artifact_id));
|
|
535
|
+
if (args.status) params.set("status", String(args.status));
|
|
536
|
+
if (args.assignee) params.set("assignee", String(args.assignee));
|
|
537
|
+
return client.get(`/tasks?${params}`);
|
|
538
|
+
},
|
|
539
|
+
claim_task: (client, args) => client.post(`/tasks/${args.task_id}/claim`),
|
|
540
|
+
complete_task: (client, args) => {
|
|
541
|
+
const { task_id, ...body } = args;
|
|
542
|
+
return client.post(`/tasks/${task_id}/complete`, body);
|
|
543
|
+
},
|
|
544
|
+
block_task: (client, args) => {
|
|
545
|
+
const { task_id, ...body } = args;
|
|
546
|
+
return client.post(`/tasks/${task_id}/block`, body);
|
|
547
|
+
},
|
|
548
|
+
report_progress: (client, args) => {
|
|
549
|
+
const { task_id, message, metadata } = args;
|
|
550
|
+
return client.post(`/tasks/${task_id}/activity`, {
|
|
551
|
+
type: "progress",
|
|
552
|
+
content: message,
|
|
553
|
+
metadata: metadata ?? {}
|
|
554
|
+
});
|
|
555
|
+
},
|
|
556
|
+
create_task: (client, args) => {
|
|
557
|
+
const { goal_id, title, description, priority, assigned_to, depends_on, estimated_minutes } = args;
|
|
558
|
+
return client.post("/tasks", { goal_id, title, description, priority, assigned_to, depends_on, estimated_minutes });
|
|
559
|
+
},
|
|
560
|
+
// Agents
|
|
561
|
+
list_agents: (client, args) => {
|
|
562
|
+
const params = new URLSearchParams();
|
|
563
|
+
if (args.status) params.set("status", String(args.status));
|
|
564
|
+
return client.get(`/agents?${params}`);
|
|
565
|
+
},
|
|
566
|
+
get_agent: (client, args) => client.get(`/agents/${args.agent_id}`),
|
|
567
|
+
create_agent: (client, args) => {
|
|
568
|
+
const body = {
|
|
569
|
+
agentId: args.agentId,
|
|
570
|
+
name: args.name,
|
|
571
|
+
role: args.role,
|
|
572
|
+
description: args.description,
|
|
573
|
+
reportsToAgentId: args.reportsToAgentId,
|
|
574
|
+
permissions: args.permissions || { write: true, delete: false, delegate_tasks: false },
|
|
575
|
+
metadata: {
|
|
576
|
+
capabilities: args.capabilities || [],
|
|
577
|
+
systemPrompt: args.systemPrompt,
|
|
578
|
+
createdVia: "mcp"
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
return client.post("/agents", body);
|
|
582
|
+
},
|
|
583
|
+
update_agent: (client, args) => {
|
|
584
|
+
const { agent_id, ...body } = args;
|
|
585
|
+
return client.patch(`/agents/${agent_id}`, body);
|
|
586
|
+
},
|
|
587
|
+
// Inbox (human-in-the-loop)
|
|
588
|
+
create_inbox_item: (client, args) => {
|
|
589
|
+
const { task_id, type, title, content, action, action_payload, options } = args;
|
|
590
|
+
return client.post("/inbox", { task_id, type, title, content, action, action_payload, options });
|
|
591
|
+
},
|
|
592
|
+
list_inbox: (client, args) => {
|
|
593
|
+
const params = new URLSearchParams();
|
|
594
|
+
if (args.status) params.set("status", String(args.status));
|
|
595
|
+
if (args.type) params.set("type", String(args.type));
|
|
596
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
597
|
+
return client.get(`/inbox?${params}`);
|
|
598
|
+
},
|
|
599
|
+
resolve_inbox: (client, args) => {
|
|
600
|
+
const { item_id, ...body } = args;
|
|
601
|
+
return client.post(`/inbox/${item_id}/resolve`, body);
|
|
602
|
+
},
|
|
603
|
+
// Goals
|
|
604
|
+
update_goal: (client, args) => {
|
|
605
|
+
const { goal_id, ...body } = args;
|
|
606
|
+
return client.put(`/goals/${goal_id}`, body);
|
|
607
|
+
},
|
|
608
|
+
// Task cancellation
|
|
609
|
+
cancel_task: (client, args) => client.delete(`/tasks/${args.task_id}`),
|
|
610
|
+
// Search
|
|
611
|
+
search_artifacts: (client, args) => {
|
|
612
|
+
const params = new URLSearchParams();
|
|
613
|
+
params.set("q", String(args.query));
|
|
614
|
+
if (args.type) params.set("type", String(args.type));
|
|
615
|
+
if (args.limit) params.set("limit", String(args.limit));
|
|
616
|
+
return client.get(`/search?${params}`);
|
|
617
|
+
},
|
|
618
|
+
// Context
|
|
619
|
+
get_task_context: (client, args) => client.get(`/tasks/${args.task_id}/context`)
|
|
620
|
+
};
|
|
621
|
+
var ArtyfactsMcpServer = class {
|
|
622
|
+
server;
|
|
623
|
+
client;
|
|
624
|
+
config;
|
|
625
|
+
constructor(config) {
|
|
626
|
+
this.config = config;
|
|
627
|
+
this.client = new ArtyfactsApiClient(
|
|
628
|
+
config.baseUrl || "https://artyfacts.dev/api/v1",
|
|
629
|
+
config.apiKey,
|
|
630
|
+
config.agentId
|
|
631
|
+
);
|
|
632
|
+
this.server = new Server(
|
|
633
|
+
{
|
|
634
|
+
name: config.name || "artyfacts-mcp",
|
|
635
|
+
version: config.version || "1.0.0"
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
capabilities: {
|
|
639
|
+
tools: {}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
);
|
|
643
|
+
this.setupHandlers();
|
|
644
|
+
}
|
|
645
|
+
setupHandlers() {
|
|
646
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
647
|
+
return { tools: ARTYFACTS_TOOLS };
|
|
648
|
+
});
|
|
649
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
650
|
+
const { name, arguments: args } = request.params;
|
|
651
|
+
const handler = toolHandlers[name];
|
|
652
|
+
if (!handler) {
|
|
653
|
+
return {
|
|
654
|
+
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
655
|
+
isError: true
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
try {
|
|
659
|
+
const result = await handler(this.client, args || {});
|
|
660
|
+
return {
|
|
661
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
662
|
+
};
|
|
663
|
+
} catch (error) {
|
|
664
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
665
|
+
return {
|
|
666
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
667
|
+
isError: true
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
async start() {
|
|
673
|
+
const transport = new StdioServerTransport();
|
|
674
|
+
await this.server.connect(transport);
|
|
675
|
+
console.error(`Artyfacts MCP server running (${ARTYFACTS_TOOLS.length} tools)`);
|
|
676
|
+
}
|
|
677
|
+
getServer() {
|
|
678
|
+
return this.server;
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
function createMcpServer(config) {
|
|
682
|
+
return new ArtyfactsMcpServer(config);
|
|
683
|
+
}
|
|
684
|
+
async function startServer(server) {
|
|
685
|
+
await server.start();
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
export {
|
|
689
|
+
ArtyfactsMcpServer,
|
|
690
|
+
createMcpServer,
|
|
691
|
+
startServer
|
|
692
|
+
};
|