Fügt einen geschützten MCP-JSON-RPC-Endpunkt mit Buchhaltungs-Tools und Aufgaben-Tools hinzu. Berechtigungen werden rollenbasiert pro Mandant geprüft und die Auth-Logik berücksichtigt nun alle Rollen eines Nutzers.
37 lines
864 B
TypeScript
37 lines
864 B
TypeScript
import { McpToolResult } from "./types"
|
|
|
|
export function asToolResult(payload: unknown): McpToolResult {
|
|
const structuredContent =
|
|
payload && typeof payload === "object" && !Array.isArray(payload)
|
|
? payload as Record<string, unknown>
|
|
: { result: payload }
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: JSON.stringify(payload, null, 2),
|
|
},
|
|
],
|
|
structuredContent,
|
|
}
|
|
}
|
|
|
|
export function asToolError(error: unknown): McpToolResult {
|
|
const message = error instanceof Error ? error.message : "Unbekannter Fehler"
|
|
|
|
return {
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: message,
|
|
},
|
|
],
|
|
isError: true,
|
|
structuredContent: {
|
|
error: message,
|
|
},
|
|
}
|
|
}
|
|
|