fix(ai): improve mcp metadata logic (#13991)

Fix #13801
This commit is contained in:
Antoine Moreaux
2025-08-20 12:06:13 +02:00
committed by GitHub
parent 69649e97d4
commit dcdf675000
10 changed files with 101 additions and 87 deletions
@@ -1,6 +1,6 @@
export const MCP_SERVER_METADATA = {
metadata: {
info: '📦 Objects structure your business entities in Twenty. **Standard Objects** (e.g. People, Companies, Opportunities) are builtin, preconfigured data models. **Custom Objects** let you define entities specific to your needs (like Rockets, Properties, etc.). **Fields** work like spreadsheet columns and can be standard or custom. Always use the `fields` and `objects` parameters to select only the data you need—this **strongly reduces response size and token usage**, improving performance.',
info: 'Objects structure your business entities in Twenty. **Standard Objects** (e.g. People, Companies, Opportunities) are builtin, preconfigured data models. **Custom Objects** let you define entities specific to your needs (like Rockets, Properties, etc.). **Fields** work like spreadsheet columns and can be standard or custom. Always use the `fields` and `objects` parameters to select only the data you need—this **strongly reduces response size and token usage**, improving performance.',
},
protocolVersion: '2024-11-05',
serverInfo: {
@@ -27,5 +27,5 @@ export class JsonRpc {
@IsOptional()
@Validate(IsNumberOrString)
id: string | number | null;
id: string | number;
}
@@ -39,7 +39,7 @@ export class McpService {
}
}
handleInitialize(requestId: string | number | null) {
handleInitialize(requestId: string | number) {
return wrapJsonRpcResponse(requestId, {
result: {
capabilities: {
@@ -129,7 +129,7 @@ export class McpService {
}
private async handleToolCall(
id: string | number | null,
id: string | number,
toolSet: ToolSet,
params: Record<string, unknown>,
) {
@@ -161,7 +161,7 @@ export class McpService {
);
}
private handleToolsListing(id: string | number | null, toolSet: ToolSet) {
private handleToolsListing(id: string | number, toolSet: ToolSet) {
const toolsArray = Object.entries(toolSet)
.filter(([, def]) => !!def.parameters.jsonSchema)
.map(([name, def]) => ({
@@ -1,7 +1,7 @@
import { MCP_SERVER_METADATA } from 'src/engine/core-modules/ai/constants/mcp.const';
export const wrapJsonRpcResponse = (
id: string | number | null | undefined = null,
id: string | number,
payload:
| Record<'result', Record<string, unknown>>
| Record<'error', Record<string, unknown>>,