feat(ai): add mcp-metadata (#13150)
Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
export const MCP_SERVER_METADATA = {
|
||||
metadata: {
|
||||
info: '📦 Objects structure your business entities in Twenty. **Standard Objects** (e.g. People, Companies, Opportunities) are built‑in, pre‑configured 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: {
|
||||
name: 'Twenty MCP Server',
|
||||
|
||||
@@ -20,7 +20,10 @@ export class JsonRpc {
|
||||
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
params?: Record<string, unknown>;
|
||||
params?: {
|
||||
name: string;
|
||||
arguments: unknown;
|
||||
};
|
||||
|
||||
@IsOptional()
|
||||
@Validate(IsNumberOrString)
|
||||
|
||||
@@ -110,6 +110,7 @@ export class McpService {
|
||||
userWorkspaceId,
|
||||
apiKey,
|
||||
);
|
||||
|
||||
const toolSet = await this.toolService.listTools(roleId, workspace.id);
|
||||
|
||||
if (method === 'tools/call' && params) {
|
||||
|
||||
+7
-2
@@ -5,14 +5,19 @@ export const wrapJsonRpcResponse = (
|
||||
payload:
|
||||
| Record<'result', Record<string, unknown>>
|
||||
| Record<'error', Record<string, unknown>>,
|
||||
omitMetadata = false,
|
||||
) => {
|
||||
const body =
|
||||
'result' in payload
|
||||
? {
|
||||
result: { ...payload.result, ...MCP_SERVER_METADATA },
|
||||
result: omitMetadata
|
||||
? payload.result
|
||||
: { ...payload.result, ...MCP_SERVER_METADATA },
|
||||
}
|
||||
: {
|
||||
error: { ...payload.error, ...MCP_SERVER_METADATA },
|
||||
error: omitMetadata
|
||||
? payload.error
|
||||
: { ...payload.error, ...MCP_SERVER_METADATA },
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user