MCP-Projektphasen aktualisierbar machen
All checks were successful
Build and Push Docker Images / build-website (push) Successful in 22s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
Build and Push Docker Images / build-backend (push) Successful in 45s
Build and Push Docker Images / build-frontend (push) Successful in 22s
All checks were successful
Build and Push Docker Images / build-website (push) Successful in 22s
Build and Push Docker Images / build-central-services-api (push) Successful in 22s
Build and Push Docker Images / build-central-services-admin (push) Successful in 22s
Build and Push Docker Images / build-docs (push) Successful in 22s
Build and Push Docker Images / build-backend (push) Successful in 45s
Build and Push Docker Images / build-frontend (push) Successful in 22s
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { and, desc, eq, ilike, or } from "drizzle-orm"
|
||||
import { customers, events, plants, projects, tasks } from "../../../db/schema"
|
||||
import { insertHistoryItem } from "../../utils/history"
|
||||
import { activateProjectPhase } from "../projectPhases"
|
||||
import { McpTool } from "../types"
|
||||
|
||||
const limitFromArgs = (args: Record<string, unknown>, fallback = 25) => {
|
||||
@@ -136,6 +138,77 @@ export const organisationTools: McpTool[] = [
|
||||
return { project: rows[0] }
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "organisation.projects.phase.update",
|
||||
title: "Projektphase aktualisieren",
|
||||
description: "Aktiviert eine Projektphase anhand ihres Schlüssels oder ihrer eindeutigen Bezeichnung. Pflichtphasen können nicht übersprungen werden; optionale Phasen und der direkte Abschluss entsprechen dem Verhalten der Oberfläche.",
|
||||
requiredPermissions: ["organisation.projects.write"],
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
required: ["id"],
|
||||
oneOf: [
|
||||
{ required: ["phaseKey"] },
|
||||
{ required: ["phaseLabel"] },
|
||||
],
|
||||
properties: {
|
||||
id: { type: "number", description: "Projekt-ID." },
|
||||
phaseKey: { type: "string", description: "Technischer Schlüssel der zu aktivierenden Phase; alternativ zu phaseLabel." },
|
||||
phaseLabel: { type: "string", description: "Eindeutige Bezeichnung der zu aktivierenden Phase, falls kein phaseKey bekannt ist." },
|
||||
},
|
||||
},
|
||||
async handler(context, args) {
|
||||
const id = numberArg(args, "id")
|
||||
if (!id) throw new Error("id ist erforderlich")
|
||||
|
||||
const [existing] = await context.server.db
|
||||
.select()
|
||||
.from(projects)
|
||||
.where(and(eq(projects.id, id), eq(projects.tenant, context.tenantId)))
|
||||
.limit(1)
|
||||
|
||||
if (!existing) throw new Error("Projekt nicht gefunden")
|
||||
if (existing.archived) throw new Error("Die Phase eines archivierten Projekts kann nicht geändert werden")
|
||||
|
||||
const transition = activateProjectPhase(existing.phases, {
|
||||
phaseKey: stringArg(args, "phaseKey"),
|
||||
phaseLabel: stringArg(args, "phaseLabel"),
|
||||
}, context.userId)
|
||||
|
||||
const [updated] = await context.server.db
|
||||
.update(projects)
|
||||
.set({
|
||||
phases: transition.phases,
|
||||
active_phase: transition.activePhase,
|
||||
updatedAt: new Date(),
|
||||
updatedBy: context.userId,
|
||||
})
|
||||
.where(and(eq(projects.id, id), eq(projects.tenant, context.tenantId)))
|
||||
.returning()
|
||||
|
||||
if (!updated) throw new Error("Projekt nicht gefunden")
|
||||
|
||||
await insertHistoryItem(context.server, {
|
||||
tenant_id: context.tenantId,
|
||||
created_by: context.userId,
|
||||
entity: "projects",
|
||||
entityId: id,
|
||||
action: "updated",
|
||||
oldVal: existing,
|
||||
newVal: updated,
|
||||
text: transition.previousPhase
|
||||
? `Projektphase von „${transition.previousPhase}“ auf „${transition.activePhase}“ geändert`
|
||||
: `Projektphase „${transition.activePhase}“ aktiviert`,
|
||||
})
|
||||
|
||||
return {
|
||||
project: updated,
|
||||
phaseTransition: {
|
||||
previousPhase: transition.previousPhase,
|
||||
activePhase: transition.activePhase,
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "organisation.plants.list",
|
||||
title: "Anlagen auflisten",
|
||||
|
||||
Reference in New Issue
Block a user