feat(mcp) - optimize instruction prompt and hide get_tool_catalog (#21183)

Workspace-aware initialize.instructions

- Deleted the static mcp-server-instructions.const.ts
- Created build-mcp-server-instructions.util.ts — a comprehensive system
prompt with identity, object list, tool grammar, routing decision tree,
intent mapping, skills vs tools, safety constraints, and data efficiency
guidelines
- Created McpInstructionBuilderService — fetches workspace-specific
object names + skill names and injects them into the instructions


Hide/deprecate get_tool_catalog

Benefit : skip first MCP call (tools are included in instruction)
This commit is contained in:
Etienne
2026-06-03 18:58:32 +02:00
committed by GitHub
parent 4b15b949f3
commit dd0039ca1c
20 changed files with 313 additions and 96 deletions
@@ -0,0 +1,18 @@
import { isDefined } from 'twenty-shared/utils';
import { isWorkflowRelatedObject } from 'src/engine/metadata-modules/ai/ai-agent/utils/is-workflow-related-object.util';
type FlatObjectWithActivityAndIdentifier = {
isActive: boolean;
universalIdentifier: string;
};
export const getDatabaseCrudToolFlatObjects = <
T extends FlatObjectWithActivityAndIdentifier,
>(
byUniversalIdentifier: Partial<Record<string, T>>,
): T[] => {
return Object.values(byUniversalIdentifier)
.filter(isDefined)
.filter((obj) => obj.isActive && !isWorkflowRelatedObject(obj));
};