loopctl-mcp-server 3.18.0 → 3.19.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 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
  }
@@ -3871,7 +3882,8 @@ const TOOLS = [
3871
3882
  "403 custody_tier_required, by design — a tenant must not be able to open a custody " +
3872
3883
  "surface for itself. If you only need a project row to scope KNOWLEDGE to the repo you " +
3873
3884
  "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.",
3885
+ "first and read `capabilities` to see which of the two applies to your tenant. " +
3886
+ "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
3887
  inputSchema: {
3876
3888
  type: "object",
3877
3889
  properties: {
@@ -3896,7 +3908,8 @@ const TOOLS = [
3896
3908
  {
3897
3909
  name: "create_kb_scope",
3898
3910
  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.",
3911
+ "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. " +
3912
+ "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
3913
  inputSchema: {
3901
3914
  type: "object",
3902
3915
  properties: {
@@ -4352,7 +4365,8 @@ const TOOLS = [
4352
4365
  {
4353
4366
  name: "restore_project",
4354
4367
  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.",
4368
+ "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. " +
4369
+ "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
4370
  inputSchema: {
4357
4371
  type: "object",
4358
4372
  properties: {
@@ -4364,10 +4378,31 @@ const TOOLS = [
4364
4378
  required: ["project_id"],
4365
4379
  },
4366
4380
  },
4381
+ {
4382
+ name: "merge_project",
4383
+ description:
4384
+ "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.",
4385
+ inputSchema: {
4386
+ type: "object",
4387
+ properties: {
4388
+ project_id: { type: "string", description: "UUID of the project to merge away (it is archived)." },
4389
+ target_project_id: {
4390
+ type: "string",
4391
+ description: "UUID of the project that keeps everything (the repo's kb scope or work project).",
4392
+ },
4393
+ dry_run: {
4394
+ type: "boolean",
4395
+ description: "true: report per-table counts and conflicts, write nothing. Default false.",
4396
+ },
4397
+ },
4398
+ required: ["project_id", "target_project_id"],
4399
+ },
4400
+ },
4367
4401
  {
4368
4402
  name: "update_project",
4369
4403
  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.",
4404
+ "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. " +
4405
+ "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
4406
  inputSchema: {
4372
4407
  type: "object",
4373
4408
  properties: {
@@ -9372,7 +9407,9 @@ const TOOLS = [
9372
9407
  "issue can reach a queue. It is also the binding place_dispatch reads — a project bound " +
9373
9408
  "to no source refuses 409 `no_intake_source`, and one bound to two refuses 409 " +
9374
9409
  "`ambiguous_intake_source`; this tool is what those two refusals mean by enrolling a " +
9375
- "source.\n\n" +
9410
+ "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). " +
9411
+ "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)." +
9412
+ "\n\n" +
9376
9413
  "THE WEBHOOK SECRET IS RETURNED ONCE AND CAN NEVER BE READ AGAIN. The column is " +
9377
9414
  "encrypted at rest and redacted on the schema, so neither intake_source_list nor " +
9378
9415
  "intake_source_update ever carries it; losing it costs a revoke, a second enrolment and " +
@@ -10508,6 +10545,8 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
10508
10545
  return await updateProject(args);
10509
10546
  case "restore_project":
10510
10547
  return await restoreProject(args);
10548
+ case "merge_project":
10549
+ return await mergeProject(args);
10511
10550
 
10512
10551
  case "get_progress":
10513
10552
  return await getProgress(args);
@@ -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.0",
4
4
  "description": "MCP server for loopctl — structural trust for AI development loops",
5
5
  "type": "module",
6
6
  "main": "index.js",