loopctl-mcp-server 3.18.0 → 3.19.1

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 CHANGED
@@ -207,7 +207,8 @@ tool parameter.
207
207
  | `create_project` | Create a new **work** project (epics/stories/custody). Requires orchestrator+ **and** a `human_anchored` tenant; an agent-rooted tenant gets `403 custody_tier_required` and should use `create_kb_scope`. |
208
208
  | `delete_project` | **Needs a user-role key:** `LOOPCTL_USER_KEY` verbatim when set, else the default key (orchestrator role is 403 `insufficient_role`). Archives the project (status `archived`); no rows are removed and its slug stays taken. |
209
209
  | `restore_project` | Restore an archived `kind: work` project, the reverse of `delete_project`; audited as `unarchived`. Orchestrator role or higher on a human-anchored tenant. Rejected (422) at the tenant's `max_projects` cap and for a kb scope (use `restore_kb_scope`). The only way to change a project's status back: PATCH refuses `status` with 422. |
210
- | `update_project` | PATCH a project's `name`, `repo_url`, `description`, `tech_stack`, `mission` or `metadata`; a field left out is left alone, and a call naming none is refused locally. Slug and status are never set here. Orchestrator role or higher on a human-anchored tenant, sent with `LOOPCTL_ORCH_KEY` verbatim (else `LOOPCTL_USER_KEY`). A `repo_url` must be on no other active project, or `resolve_project` 409s `ambiguous_resolution` for that repo. |
210
+ | `update_project` | PATCH a project's `name`, `slug`, `repo_url`, `description`, `tech_stack`, `mission` or `metadata`; a field left out is left alone, and a call naming none is refused locally. Status is never set here. Orchestrator role or higher on a human-anchored tenant, sent with `LOOPCTL_ORCH_KEY` verbatim (else `LOOPCTL_USER_KEY`). A `repo_url` another active project holds is refused 409 `repo_already_has_project`, naming that project in `existing_project_id`. |
211
+ | `merge_project` | Merge one project into another (`POST /api/v1/projects/:id/merge_into`): every row moves to `target_project_id` in one transaction, the source is archived with `metadata.merged_into`, and a kb target becomes a work project when the source was one. `dry_run: true` reports per-table counts and conflicts and writes nothing. User role on a human-anchored tenant, sent with `LOOPCTL_USER_KEY` verbatim. 409 `merge_conflicts` lists rows both projects hold under one per-project unique key. |
211
212
  | `get_progress` | Get progress summary for a project, including story counts by status. Pass `include_cost=true` for cost data. |
212
213
  | `import_stories` | Import stories into a project from a structured payload (Epic 12 import format). Pass `merge: true` to add stories to epics that already exist (otherwise duplicates return 409). For large payloads, use `payload_path` to read JSON from disk instead of passing it inline. With `merge: true`, `report_orphans: true` adds `stories_orphaned` (the project's stories the payload does not mention; nothing is detached) — a signal only on a FULL round-trip of an export; without it the key is absent (#880). |
213
214
 
package/index.js CHANGED
@@ -98,6 +98,7 @@ import {
98
98
  setGithubCredential as setGithubCredentialRequest,
99
99
  } from "./lib/github-credential.js";
100
100
  import { updateProject as updateProjectRequest } from "./lib/project-update.js";
101
+ import { mergeProject as mergeProjectRequest } from "./lib/project-merge.js";
101
102
  import {
102
103
  createEpic as createEpicRequest,
103
104
  deleteEpic as deleteEpicRequest,
@@ -147,7 +148,6 @@ const WITNESS_FS = { readFileSync, writeFileSync, renameSync, lstatSync, unlinkS
147
148
  // `apiCall(..., { timeoutMs })` — e.g. the init-time generated-tools listing fetch,
148
149
  // which must degrade to static tools quickly rather than block connection setup.
149
150
  const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
150
-
151
151
  // One witness client PER API KEY (#298 review HIGH-2): the STH is per-tenant and
152
152
  // each key resolves to a tenant server-side, so distinct keys must NOT share an
153
153
  // in-memory cache or a state file (a collision causes spurious 409s + false
@@ -980,6 +980,17 @@ async function restoreProject({ project_id }) {
980
980
  return toContent(result);
981
981
  }
982
982
 
983
+ // US-52.2: user role, so LOOPCTL_USER_KEY verbatim when set, as deleteProject does.
984
+ async function mergeProject(args) {
985
+ const key = process.env.LOOPCTL_USER_KEY;
986
+ const userApiCall = key
987
+ ? (method, path, body) =>
988
+ apiCall(method, path, body, key, { exactKey: true, keyHint: "LOOPCTL_USER_KEY" })
989
+ : apiCall;
990
+
991
+ return toContent(await mergeProjectRequest(args, { apiCall: userApiCall }));
992
+ }
993
+
983
994
  async function updateProject(args) {
984
995
  return toContent(await updateProjectRequest(args, { apiCall: orchestratorPinnedApiCall }));
985
996
  }
@@ -3824,12 +3835,18 @@ const TOOLS = [
3824
3835
  name: "list_projects",
3825
3836
  description:
3826
3837
  "List projects in the current tenant. Paginated (page/page_size); advance " +
3827
- "`page` to enumerate all projects. Response includes pagination meta.",
3838
+ "`page` to enumerate all projects. Response includes pagination meta. " +
3839
+ "Archived projects (a project merged into another, an archived kb scope) are " +
3840
+ "left out unless include_archived is true.",
3828
3841
  inputSchema: {
3829
3842
  type: "object",
3830
3843
  properties: {
3831
3844
  page: { type: "integer", description: "Page number (default 1)." },
3832
3845
  page_size: { type: "integer", description: "Items per page (default 20)." },
3846
+ include_archived: {
3847
+ type: "boolean",
3848
+ description: "true: list archived projects too. Default false.",
3849
+ },
3833
3850
  },
3834
3851
  required: [],
3835
3852
  },
@@ -3871,7 +3888,8 @@ const TOOLS = [
3871
3888
  "403 custody_tier_required, by design — a tenant must not be able to open a custody " +
3872
3889
  "surface for itself. If you only need a project row to scope KNOWLEDGE to the repo you " +
3873
3890
  "are on, use create_kb_scope instead (agent role, no human anchor). Call get_tenant " +
3874
- "first and read `capabilities` to see which of the two applies to your tenant.",
3891
+ "first and read `capabilities` to see which of the two applies to your tenant. " +
3892
+ "A repo has one project: a repo_url another active project of the tenant already holds is refused 409 repo_already_has_project, and error.existing_project_id names the project to use instead (resolve_project({repo_url}) finds it too).",
3875
3893
  inputSchema: {
3876
3894
  type: "object",
3877
3895
  properties: {
@@ -3896,7 +3914,8 @@ const TOOLS = [
3896
3914
  {
3897
3915
  name: "create_kb_scope",
3898
3916
  description:
3899
- "Create a knowledge-only project scope (kind: kb) for the current tenant. Unlike create_project (work project, orchestrator+ / human-anchored), this is available to an agent-rooted (KB-tier) tenant with an agent key: a kb scope carries NO chain-of-custody / work-breakdown surface (it cannot host epics/stories/dispatch/ui-tests), it exists only to partition knowledge articles by repo so captured/created articles can be project-scoped. Then resolve_project by its repo_url/slug and pass the returned id as project_id on article/knowledge writes. Counts toward the tenant's max_projects budget.",
3917
+ "Create a knowledge-only project scope (kind: kb) for the current tenant. Unlike create_project (work project, orchestrator+ / human-anchored), this is available to an agent-rooted (KB-tier) tenant with an agent key: a kb scope carries NO chain-of-custody / work-breakdown surface (it cannot host epics/stories/dispatch/ui-tests), it exists only to partition knowledge articles by repo so captured/created articles can be project-scoped. Then resolve_project by its repo_url/slug and pass the returned id as project_id on article/knowledge writes. Counts toward the tenant's max_projects budget. " +
3918
+ "A repo has one project: a repo_url another active project of the tenant already holds is refused 409 repo_already_has_project, and error.existing_project_id names the project to use instead (resolve_project({repo_url}) finds it too).",
3900
3919
  inputSchema: {
3901
3920
  type: "object",
3902
3921
  properties: {
@@ -4352,7 +4371,8 @@ const TOOLS = [
4352
4371
  {
4353
4372
  name: "restore_project",
4354
4373
  description:
4355
- "RESTORE an archived kind: work project (POST /api/v1/projects/:id/restore, the reverse of delete_project). Audited as unarchived; an already-active project comes back unchanged. Status cannot be changed any other way: PATCH /api/v1/projects/:id refuses a body carrying status with 422. Sent with the default key; the route needs orchestrator role or higher. Refusals: 422 when the tenant is at its max_projects cap (re-activating takes an active slot), 422 for a kind: kb scope (use restore_kb_scope), 403 insufficient_role below orchestrator role, 403 custody_tier_required on an agent-rooted tenant (the human-anchor gate), 404 for an id not in your tenant.",
4374
+ "RESTORE an archived kind: work project (POST /api/v1/projects/:id/restore, the reverse of delete_project). Audited as unarchived; an already-active project comes back unchanged. Status cannot be changed any other way: PATCH /api/v1/projects/:id refuses a body carrying status with 422. Sent with the default key; the route needs orchestrator role or higher. Refusals: 422 when the tenant is at its max_projects cap (re-activating takes an active slot), 422 for a kind: kb scope (use restore_kb_scope), 403 insufficient_role below orchestrator role, 403 custody_tier_required on an agent-rooted tenant (the human-anchor gate), 404 for an id not in your tenant. " +
4375
+ "A repo has one project: a repo_url another active project of the tenant already holds is refused 409 repo_already_has_project, and error.existing_project_id names the project to use instead (resolve_project({repo_url}) finds it too).",
4356
4376
  inputSchema: {
4357
4377
  type: "object",
4358
4378
  properties: {
@@ -4364,10 +4384,31 @@ const TOOLS = [
4364
4384
  required: ["project_id"],
4365
4385
  },
4366
4386
  },
4387
+ {
4388
+ name: "merge_project",
4389
+ description:
4390
+ "MERGE one project into another (POST /api/v1/projects/:id/merge_into, US-52.2): every row of project_id (stories, epics, intake sources, channel posts and claims, articles, memories and the rest) moves to target_project_id in one transaction, project_id is archived with metadata.merged_into, and a kb target becomes a work project when project_id was one. The audit log and search telemetry keep naming project_id. Use it when a repo has two projects (a kb scope holding the repo_url and a '-delivery' work project): merge the work project INTO the kb scope, which keeps the channel id sessions already use. Run with dry_run: true first: it returns per-table counts and conflicts and writes nothing. A repeat call on an already-merged project returns already_merged: true and moves only rows written to the archived project since (run it again to sweep stragglers). A project-scoped token budget moves too. Sent with LOOPCTL_USER_KEY verbatim, else the default key. Refusals: 409 merge_conflicts when both projects hold a row under one per-project unique key (a story or epic number, a claim ref, a keyed channel post), with error.conflicts listing each; nothing moves. 422 for the same project twice, an archived target, or an archived project_id not merged into this target. 403 insufficient_role below user role, 403 custody_tier_required on an agent-rooted tenant, 404 for an id not in your tenant.",
4391
+ inputSchema: {
4392
+ type: "object",
4393
+ properties: {
4394
+ project_id: { type: "string", description: "UUID of the project to merge away (it is archived)." },
4395
+ target_project_id: {
4396
+ type: "string",
4397
+ description: "UUID of the project that keeps everything (the repo's kb scope or work project).",
4398
+ },
4399
+ dry_run: {
4400
+ type: "boolean",
4401
+ description: "true: report per-table counts and conflicts, write nothing. Default false.",
4402
+ },
4403
+ },
4404
+ required: ["project_id", "target_project_id"],
4405
+ },
4406
+ },
4367
4407
  {
4368
4408
  name: "update_project",
4369
4409
  description:
4370
- "UPDATE a project's fields (PATCH /api/v1/projects/:id): name, slug, repo_url, description, tech_stack, mission, metadata. Send only what changes; a field left out is left alone, and a call naming none is refused locally. A slug change renames the project's channel (kb scope or work project); when no name is sent and the name equaled the old slug, the name follows. A kb name different from its slug is 422, and a slug another project holds (archived included) is 422. Status is not settable here (archive with delete_project, restore with restore_project). Setting repo_url makes resolve_project({repo_url}) and SessionStart find the project, so it must be the ONLY active project carrying that URL: a second one makes every lookup for the repo 409 ambiguous_resolution fleet-wide. Sent with LOOPCTL_ORCH_KEY verbatim, else LOOPCTL_USER_KEY, else the default key. Refusals: 403 insufficient_role below orchestrator role, 403 custody_tier_required on an agent-rooted tenant (the human-anchor gate), 404 for an id not in your tenant, 422 for an invalid field.",
4410
+ "UPDATE a project's fields (PATCH /api/v1/projects/:id): name, slug, repo_url, description, tech_stack, mission, metadata. Send only what changes; a field left out is left alone, and a call naming none is refused locally. A slug change renames the project's channel (kb scope or work project); when no name is sent and the name equaled the old slug, the name follows. A kb name different from its slug is 422, and a slug another project holds (archived included) is 422. Status is not settable here (archive with delete_project, restore with restore_project). Setting repo_url makes resolve_project({repo_url}) and SessionStart find the project. Sent with LOOPCTL_ORCH_KEY verbatim, else LOOPCTL_USER_KEY, else the default key. Refusals: 403 insufficient_role below orchestrator role, 403 custody_tier_required on an agent-rooted tenant (the human-anchor gate), 404 for an id not in your tenant, 422 for an invalid field. " +
4411
+ "A repo has one project: a repo_url another active project of the tenant already holds is refused 409 repo_already_has_project, and error.existing_project_id names the project to use instead (resolve_project({repo_url}) finds it too).",
4371
4412
  inputSchema: {
4372
4413
  type: "object",
4373
4414
  properties: {
@@ -9372,7 +9413,9 @@ const TOOLS = [
9372
9413
  "issue can reach a queue. It is also the binding place_dispatch reads — a project bound " +
9373
9414
  "to no source refuses 409 `no_intake_source`, and one bound to two refuses 409 " +
9374
9415
  "`ambiguous_intake_source`; this tool is what those two refusals mean by enrolling a " +
9375
- "source.\n\n" +
9416
+ "source. Bind the repository to the project that already holds its repo_url; a pr or chg source on that repo's kb scope promotes the scope to a work project (US-52.3). " +
9417
+ "A repo has one project: a repo_url another active project of the tenant already holds is refused 409 repo_already_has_project, and error.existing_project_id names the project to use instead (resolve_project({repo_url}) finds it too)." +
9418
+ "\n\n" +
9376
9419
  "THE WEBHOOK SECRET IS RETURNED ONCE AND CAN NEVER BE READ AGAIN. The column is " +
9377
9420
  "encrypted at rest and redacted on the schema, so neither intake_source_list nor " +
9378
9421
  "intake_source_update ever carries it; losing it costs a revoke, a second enrolment and " +
@@ -10508,6 +10551,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
10508
10551
  return await updateProject(args);
10509
10552
  case "restore_project":
10510
10553
  return await restoreProject(args);
10554
+ case "merge_project":
10555
+ return await mergeProject(args);
10511
10556
 
10512
10557
  case "get_progress":
10513
10558
  return await getProgress(args);
@@ -26,15 +26,17 @@ export function buildQuery(pairs) {
26
26
  }
27
27
 
28
28
  /**
29
- * Path for `list_projects`, honoring page/page_size (#247, mcp-01).
29
+ * Path for `list_projects`, honoring page/page_size (#247, mcp-01) and
30
+ * include_archived (a merged-away project is archived, US-52.2).
30
31
  *
31
- * @param {{ page?: number, page_size?: number }} [args]
32
+ * @param {{ page?: number, page_size?: number, include_archived?: boolean }} [args]
32
33
  * @returns {string}
33
34
  */
34
- export function projectsPath({ page, page_size } = {}) {
35
+ export function projectsPath({ page, page_size, include_archived } = {}) {
35
36
  return `/api/v1/projects${buildQuery([
36
37
  ["page", page],
37
38
  ["page_size", page_size],
39
+ ["include_archived", include_archived],
38
40
  ])}`;
39
41
  }
40
42
 
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `merge_project`: the MCP half of `POST /api/v1/projects/:id/merge_into`
3
+ * (`ProjectController.merge_into`, US-52.2). It moves every row of one project into another
4
+ * and archives the first, so a repo that grew two projects (a kb scope and a `-delivery` work
5
+ * project) ends with one project and one channel.
6
+ *
7
+ * KEY: user role on a human-anchored tenant; index.js sends it with LOOPCTL_USER_KEY verbatim
8
+ * when set, as delete_project does.
9
+ */
10
+
11
+ import { uuid as uuidRefusal } from "./delivery-loop.js";
12
+
13
+ export function mergePath(projectId) {
14
+ return `/api/v1/projects/${encodeURIComponent(projectId)}/merge_into`;
15
+ }
16
+
17
+ export async function mergeProject(args = {}, { apiCall } = {}) {
18
+ const refused =
19
+ uuidRefusal(args.project_id, "project_id") ??
20
+ uuidRefusal(args.target_project_id, "target_project_id");
21
+ if (refused) return refused;
22
+
23
+ return apiCall("POST", mergePath(args.project_id), {
24
+ target_project_id: args.target_project_id,
25
+ dry_run: args.dry_run === true,
26
+ });
27
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loopctl-mcp-server",
3
- "version": "3.18.0",
3
+ "version": "3.19.1",
4
4
  "description": "MCP server for loopctl — structural trust for AI development loops",
5
5
  "type": "module",
6
6
  "main": "index.js",