fix(mcp): exclude archived records

This commit is contained in:
2026-09-09 14:19:34 +02:00
parent a6f55b61e4
commit d0bc8a5e0f
5 changed files with 96 additions and 53 deletions

View File

@@ -30,7 +30,6 @@ export const organisationTools: McpTool[] = [
type: "object",
properties: {
query: { type: "string", description: "Suchtext für Name, Kundennummer, Vorname, Nachname oder Notizen." },
includeArchived: { type: "boolean", default: false },
limit: { type: "number", minimum: 1, maximum: 100 },
},
},
@@ -47,7 +46,7 @@ export const organisationTools: McpTool[] = [
ilike(customers.notes, `%${query}%`)
))
}
if (args.includeArchived !== true) conditions.push(eq(customers.archived, false))
conditions.push(eq(customers.archived, false))
const rows = await context.server.db
.select({
@@ -80,7 +79,6 @@ export const organisationTools: McpTool[] = [
query: { type: "string", description: "Suchtext für Name, Projektnummer, Kundenreferenz oder Notizen." },
customer: { type: "number" },
activePhase: { type: "string" },
includeArchived: { type: "boolean", default: false },
limit: { type: "number", minimum: 1, maximum: 100 },
},
},
@@ -100,7 +98,7 @@ export const organisationTools: McpTool[] = [
}
if (customer) conditions.push(eq(projects.customer, customer))
if (activePhase) conditions.push(eq(projects.active_phase, activePhase))
if (args.includeArchived !== true) conditions.push(eq(projects.archived, false))
conditions.push(eq(projects.archived, false))
const rows = await context.server.db
.select()
@@ -131,7 +129,7 @@ export const organisationTools: McpTool[] = [
const rows = await context.server.db
.select()
.from(projects)
.where(and(eq(projects.id, id), eq(projects.tenant, context.tenantId)))
.where(and(eq(projects.id, id), eq(projects.tenant, context.tenantId), eq(projects.archived, false)))
.limit(1)
if (!rows[0]) throw new Error("Projekt nicht gefunden")
@@ -219,7 +217,6 @@ export const organisationTools: McpTool[] = [
properties: {
query: { type: "string", description: "Suchtext für Name." },
customer: { type: "number" },
includeArchived: { type: "boolean", default: false },
limit: { type: "number", minimum: 1, maximum: 100 },
},
},
@@ -230,7 +227,7 @@ export const organisationTools: McpTool[] = [
if (query) conditions.push(ilike(plants.name, `%${query}%`))
if (customer) conditions.push(eq(plants.customer, customer))
if (args.includeArchived !== true) conditions.push(eq(plants.archived, false))
conditions.push(eq(plants.archived, false))
const rows = await context.server.db
.select()
@@ -254,7 +251,6 @@ export const organisationTools: McpTool[] = [
project: { type: "number" },
customer: { type: "number" },
eventtype: { type: "string" },
includeArchived: { type: "boolean", default: false },
limit: { type: "number", minimum: 1, maximum: 100 },
},
},
@@ -275,7 +271,7 @@ export const organisationTools: McpTool[] = [
if (project) conditions.push(eq(events.project, project))
if (customer) conditions.push(eq(events.customer, customer))
if (eventtype) conditions.push(eq(events.eventtype, eventtype))
if (args.includeArchived !== true) conditions.push(eq(events.archived, false))
conditions.push(eq(events.archived, false))
const rows = await context.server.db
.select()
@@ -298,7 +294,6 @@ export const organisationTools: McpTool[] = [
query: { type: "string", description: "Suchtext für Name, Beschreibung oder Kategorie." },
project: { type: "number" },
customer: { type: "number" },
includeArchived: { type: "boolean", default: false },
limit: { type: "number", minimum: 1, maximum: 100 },
},
},
@@ -317,7 +312,7 @@ export const organisationTools: McpTool[] = [
}
if (project) conditions.push(eq(tasks.project, project))
if (customer) conditions.push(eq(tasks.customer, customer))
if (args.includeArchived !== true) conditions.push(eq(tasks.archived, false))
conditions.push(eq(tasks.archived, false))
const rows = await context.server.db
.select()
@@ -348,7 +343,7 @@ export const organisationTools: McpTool[] = [
const rows = await context.server.db
.select()
.from(tasks)
.where(and(eq(tasks.id, id), eq(tasks.tenant, context.tenantId)))
.where(and(eq(tasks.id, id), eq(tasks.tenant, context.tenantId), eq(tasks.archived, false)))
.limit(1)
if (!rows[0]) throw new Error("Aufgabe nicht gefunden")