Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: added group to mcp

Nevo David79c16653141b
diff --git a/libraries/nestjs-libraries/src/chat/load.tools.service.ts b/libraries/nestjs-libraries/src/chat/load.tools.service.ts
index 10118d94c..d252b52e5 100644
--- a/libraries/nestjs-libraries/src/chat/load.tools.service.ts
+++ b/libraries/nestjs-libraries/src/chat/load.tools.service.ts
@@ -59,7 +59,8 @@ export class LoadToolsService {
- Generate text for posts
- Show global analytics about socials
- List integrations (channels)
-
+ - List groups (customers) and filter the channels by a group
+
- We schedule posts to different integration like facebook, instagram, etc. but to the user we don't say integrations we say channels as integration is the technical name
- When scheduling a post, you must follow the social media rules and best practices.
- When scheduling a post, you can pass an array for list of posts for a social media platform, But it has different behavior depending on the platform.
diff --git a/libraries/nestjs-libraries/src/chat/tools/group.list.tool.ts b/libraries/nestjs-libraries/src/chat/tools/group.list.tool.ts
new file mode 100644
index 000000000..761a1c63f
--- /dev/null
+++ b/libraries/nestjs-libraries/src/chat/tools/group.list.tool.ts
@@ -0,0 +1,52 @@
+import { AgentToolInterface } from '@gitroom/nestjs-libraries/chat/agent.tool.interface';
+import { createTool } from '@mastra/core/tools';
+import { Injectable } from '@nestjs/common';
+import { IntegrationService } from '@gitroom/nestjs-libraries/database/prisma/integrations/integration.service';
+import z from 'zod';
+import { checkAuth } from '@gitroom/nestjs-libraries/chat/auth.context';
+
+@Injectable()
+export class GroupListTool implements AgentToolInterface {
+ constructor(private _integrationService: IntegrationService) {}
+ name = 'groupList';
+
+ run() {
+ return createTool({
+ id: 'groupList',
+ description: `This tool lists the available groups (customers). Use a group id with the integrationList tool to filter the integrations belonging to that group`,
+ inputSchema: z.object({}),
+ mcp: {
+ annotations: {
+ title: 'List Groups',
+ readOnlyHint: true,
+ destructiveHint: false,
+ idempotentHint: true,
+ openWorldHint: false,
+ },
+ },
+ outputSchema: z.object({
+ output: z.array(
+ z.object({
+ id: z.string(),
+ name: z.string(),
+ })
+ ),
+ }),
+ execute: async (inputData, context) => {
+ checkAuth(inputData, context);
+ const organizationId = JSON.parse(
+ (context?.requestContext as any)?.get('organization') as string
+ ).id;
+
+ return {
+ output: (await this._integrationService.customers(organizationId)).map(
+ (p) => ({
+ id: p.id,
+ name: p.name,
+ })
+ ),
+ };
+ },
+ });
+ }
+}
diff --git a/libraries/nestjs-libraries/src/chat/tools/integration.list.tool.ts b/libraries/nestjs-libraries/src/chat/tools/integration.list.tool.ts
index c457b00fa..3f8a032dc 100644
--- a/libraries/nestjs-libraries/src/chat/tools/integration.list.tool.ts
+++ b/libraries/nestjs-libraries/src/chat/tools/integration.list.tool.ts
@@ -15,8 +15,15 @@ export class IntegrationListTool implements AgentToolInterface {
run() {
return createTool({
id: 'integrationList',
- description: `This tool list available integrations to schedule posts to`,
- inputSchema: z.object({}),
+ description: `This tool list available integrations to schedule posts to. Optionally pass a group id (from the groupList tool) to only list integrations belonging to that group`,
+ inputSchema: z.object({
+ group: z
+ .string()
+ .optional()
+ .describe(
+ 'Optional group (customer) id from the groupList tool to filter the integrations'
+ ),
+ }),
mcp: {
annotations: {
title: 'List Integrations',
@@ -45,15 +52,23 @@ export class IntegrationListTool implements AgentToolInterface {
return {
output: (
await this._integrationService.getIntegrationsList(organizationId)
- ).map((p) => ({
- name: p.name,
- id: p.id,
- disabled: p.disabled,
- picture: p.picture || '/no-picture.jpg',
- platform: p.providerIdentifier,
- display: p.profile,
- type: p.type,
- })),
+ )
+ .filter((p) => !inputData.group || p.customer?.id === inputData.group)
+ .map((p) => ({
+ name: p.name,
+ id: p.id,
+ disabled: p.disabled,
+ picture: p.picture || '/no-picture.jpg',
+ platform: p.providerIdentifier,
+ display: p.profile,
+ type: p.type,
+ customer: p.customer
+ ? {
+ id: p.customer.id,
+ name: p.customer.name,
+ }
+ : undefined,
+ })),
};
},
});
diff --git a/libraries/nestjs-libraries/src/chat/tools/tool.list.ts b/libraries/nestjs-libraries/src/chat/tools/tool.list.ts
index d2be0fc24..b188daee4 100644
--- a/libraries/nestjs-libraries/src/chat/tools/tool.list.ts
+++ b/libraries/nestjs-libraries/src/chat/tools/tool.list.ts
@@ -6,10 +6,12 @@ import { VideoFunctionTool } from '@gitroom/nestjs-libraries/chat/tools/video.fu
import { GenerateVideoTool } from '@gitroom/nestjs-libraries/chat/tools/generate.video.tool';
import { GenerateImageTool } from '@gitroom/nestjs-libraries/chat/tools/generate.image.tool';
import { IntegrationListTool } from '@gitroom/nestjs-libraries/chat/tools/integration.list.tool';
+import { GroupListTool } from '@gitroom/nestjs-libraries/chat/tools/group.list.tool';
import { UploadFromUrlTool } from '@gitroom/nestjs-libraries/chat/tools/upload.from.url.tool';
export const toolList = [
IntegrationListTool,
+ GroupListTool,
IntegrationValidationTool,
IntegrationTriggerTool,
IntegrationSchedulePostTool,