Skip to main content
Glama

Manage Monica activities

monica_manage_activity

Manage CRM activities like meetings and events: list, create, update, or delete interactions with contacts using activity types and details.

Instructions

List, inspect, create, update, or delete activities (meetings, events, shared interactions). Provide either activityTypeId or activityTypeName.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
activityIdNo
contactIdNo
limitNo
pageNo
payloadNo

Implementation Reference

  • Registration of the 'monica_manage_activity' tool via server.registerTool, including schema and handler.
    export function registerActivityTools(context: ToolRegistrationContext): void {
      const { server, client, logger } = context;
    
      server.registerTool(
        'monica_manage_activity',
        {
          title: 'Manage Monica activities',
          description:
            'List, inspect, create, update, or delete activities (meetings, events, shared interactions). Provide either activityTypeId or activityTypeName.',
          inputSchema: {
            action: z.enum(['list', 'get', 'create', 'update', 'delete']),
            activityId: z.number().int().positive().optional(),
            contactId: z.number().int().positive().optional(),
            limit: z.number().int().min(1).max(100).optional(),
            page: z.number().int().min(1).optional(),
            payload: activityPayloadSchema.optional()
          }
        },
        async ({ action, activityId, contactId, limit, page, payload }) => {
          if (action === 'list') {
            const response = await client.listActivities({ contactId, limit, page });
            const activities = response.data.map(normalizeActivity);
            const scope = contactId ? `contact ${contactId}` : 'your account';
            const summary = activities.length
              ? `Fetched ${activities.length} activit${activities.length === 1 ? 'y' : 'ies'} for ${scope}.`
              : `No activities found for ${scope}.`;
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: summary
                }
              ],
              structuredContent: {
                action,
                contactId,
                activities,
                pagination: {
                  currentPage: response.meta.current_page,
                  lastPage: response.meta.last_page,
                  perPage: response.meta.per_page,
                  total: response.meta.total
                }
              }
            };
          }
    
          if (action === 'get') {
            if (!activityId) {
              return {
                isError: true as const,
                content: [
                  {
                    type: 'text' as const,
                    text: 'Provide activityId when retrieving an activity.'
                  }
                ]
              };
            }
    
            const response = await client.getActivity(activityId);
            const activity = normalizeActivity(response.data);
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Activity ${activity.summary || `#${activity.id}`} (ID ${activity.id}).`
                }
              ],
              structuredContent: {
                action,
                activity
              }
            };
          }
    
          if (action === 'create') {
            if (!payload) {
              return {
                isError: true as const,
                content: [
                  { type: 'text' as const, text: 'Provide an activity payload when creating an activity.' }
                ]
              };
            }
    
            const activityTypeId = await resolveActivityTypeId(client, {
              activityTypeId: payload.activityTypeId,
              activityTypeName: payload.activityTypeName
            });
    
            const result = await client.createActivity(
              toActivityPayloadInput({ ...payload, activityTypeId })
            );
            const activity = normalizeActivity(result.data);
            logger.info({ activityId: activity.id }, 'Created Monica activity');
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Created activity ${activity.summary || `#${activity.id}`} (ID ${activity.id}).`
                }
              ],
              structuredContent: {
                action,
                activity
              }
            };
          }
    
          if (action === 'update') {
            if (!activityId) {
              return {
                isError: true as const,
                content: [
                  { type: 'text' as const, text: 'Provide activityId when updating an activity.' }
                ]
              };
            }
    
            if (!payload) {
              return {
                isError: true as const,
                content: [
                  { type: 'text' as const, text: 'Provide an activity payload when updating an activity.' }
                ]
              };
            }
    
            const activityTypeId = await resolveActivityTypeId(client, {
              activityTypeId: payload.activityTypeId,
              activityTypeName: payload.activityTypeName
            });
    
            const result = await client.updateActivity(
              activityId,
              toActivityPayloadInput({ ...payload, activityTypeId })
            );
            const activity = normalizeActivity(result.data);
            logger.info({ activityId }, 'Updated Monica activity');
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Updated activity ${activity.summary || `#${activity.id}`} (ID ${activity.id}).`
                }
              ],
              structuredContent: {
                action,
                activityId,
                activity
              }
            };
          }
    
          if (!activityId) {
            return {
              isError: true as const,
              content: [
                { type: 'text' as const, text: 'Provide activityId when deleting an activity.' }
              ]
            };
          }
    
          const result = await client.deleteActivity(activityId);
          logger.info({ activityId }, 'Deleted Monica activity');
    
          return {
            content: [
              { type: 'text' as const, text: `Deleted activity ID ${activityId}.` }
            ],
            structuredContent: {
              action,
              activityId,
              result
            }
          };
        }
      );
    
    }
  • Handler function implementing list, get, create, update, delete operations for activities using MonicaClient methods.
    async ({ action, activityId, contactId, limit, page, payload }) => {
      if (action === 'list') {
        const response = await client.listActivities({ contactId, limit, page });
        const activities = response.data.map(normalizeActivity);
        const scope = contactId ? `contact ${contactId}` : 'your account';
        const summary = activities.length
          ? `Fetched ${activities.length} activit${activities.length === 1 ? 'y' : 'ies'} for ${scope}.`
          : `No activities found for ${scope}.`;
    
        return {
          content: [
            {
              type: 'text' as const,
              text: summary
            }
          ],
          structuredContent: {
            action,
            contactId,
            activities,
            pagination: {
              currentPage: response.meta.current_page,
              lastPage: response.meta.last_page,
              perPage: response.meta.per_page,
              total: response.meta.total
            }
          }
        };
      }
    
      if (action === 'get') {
        if (!activityId) {
          return {
            isError: true as const,
            content: [
              {
                type: 'text' as const,
                text: 'Provide activityId when retrieving an activity.'
              }
            ]
          };
        }
    
        const response = await client.getActivity(activityId);
        const activity = normalizeActivity(response.data);
    
        return {
          content: [
            {
              type: 'text' as const,
              text: `Activity ${activity.summary || `#${activity.id}`} (ID ${activity.id}).`
            }
          ],
          structuredContent: {
            action,
            activity
          }
        };
      }
    
      if (action === 'create') {
        if (!payload) {
          return {
            isError: true as const,
            content: [
              { type: 'text' as const, text: 'Provide an activity payload when creating an activity.' }
            ]
          };
        }
    
        const activityTypeId = await resolveActivityTypeId(client, {
          activityTypeId: payload.activityTypeId,
          activityTypeName: payload.activityTypeName
        });
    
        const result = await client.createActivity(
          toActivityPayloadInput({ ...payload, activityTypeId })
        );
        const activity = normalizeActivity(result.data);
        logger.info({ activityId: activity.id }, 'Created Monica activity');
    
        return {
          content: [
            {
              type: 'text' as const,
              text: `Created activity ${activity.summary || `#${activity.id}`} (ID ${activity.id}).`
            }
          ],
          structuredContent: {
            action,
            activity
          }
        };
      }
    
      if (action === 'update') {
        if (!activityId) {
          return {
            isError: true as const,
            content: [
              { type: 'text' as const, text: 'Provide activityId when updating an activity.' }
            ]
          };
        }
    
        if (!payload) {
          return {
            isError: true as const,
            content: [
              { type: 'text' as const, text: 'Provide an activity payload when updating an activity.' }
            ]
          };
        }
    
        const activityTypeId = await resolveActivityTypeId(client, {
          activityTypeId: payload.activityTypeId,
          activityTypeName: payload.activityTypeName
        });
    
        const result = await client.updateActivity(
          activityId,
          toActivityPayloadInput({ ...payload, activityTypeId })
        );
        const activity = normalizeActivity(result.data);
        logger.info({ activityId }, 'Updated Monica activity');
    
        return {
          content: [
            {
              type: 'text' as const,
              text: `Updated activity ${activity.summary || `#${activity.id}`} (ID ${activity.id}).`
            }
          ],
          structuredContent: {
            action,
            activityId,
            activity
          }
        };
      }
    
      if (!activityId) {
        return {
          isError: true as const,
          content: [
            { type: 'text' as const, text: 'Provide activityId when deleting an activity.' }
          ]
        };
      }
    
      const result = await client.deleteActivity(activityId);
      logger.info({ activityId }, 'Deleted Monica activity');
    
      return {
        content: [
          { type: 'text' as const, text: `Deleted activity ID ${activityId}.` }
        ],
        structuredContent: {
          action,
          activityId,
          result
        }
      };
    }
  • Zod schema for activity payload used in create/update actions.
    const activityPayloadSchema = z
      .object({
        activityTypeId: z.number().int().positive().optional(),
        activityTypeName: z.string().min(1).max(255).optional(),
        summary: z.string().min(1).max(255),
        description: z.string().max(1_000_000).optional().nullable(),
        happenedAt: z
          .string()
          .regex(/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/u, 'happenedAt must be in YYYY-MM-DD format.'),
        contactIds: z.array(z.number().int().positive()).min(1, 'Provide at least one contact ID.'),
        emotionIds: z.array(z.number().int().positive()).optional()
      })
      .superRefine((data, ctx) => {
        if (typeof data.activityTypeId !== 'number' && !data.activityTypeName) {
          ctx.addIssue({
            code: z.ZodIssueCode.custom,
            message: 'Provide activityTypeId or activityTypeName.'
          });
        }
      });
  • Helper function to transform validated payload into API payload format.
    function toActivityPayloadInput(
      payload: ActivityPayloadForm & { activityTypeId: number }
    ): CreateActivityPayload & UpdateActivityPayload {
      return {
        activityTypeId: payload.activityTypeId,
        summary: payload.summary,
        description: payload.description ?? null,
        happenedAt: payload.happenedAt,
        contactIds: payload.contactIds,
        emotionIds: payload.emotionIds && payload.emotionIds.length ? payload.emotionIds : undefined
      };
    }
  • Top-level call to registerActivityTools during overall tools registration.
    registerActivityTools(context);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool can 'create, update, or delete' which implies mutation capabilities, but doesn't disclose permissions needed, whether deletions are permanent, rate limits, or what happens with partial updates. The description is insufficient for a multi-action tool with destructive capabilities.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences. The first sentence clearly states the tool's purpose and scope. The second provides specific parameter guidance. There's no wasted language, though it could benefit from better front-loading of key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex tool with 6 parameters, nested objects, multiple actions (including destructive ones), and no output schema, the description is inadequate. It doesn't explain return values, error conditions, or behavioral differences between actions. The lack of annotations exacerbates the incompleteness, leaving the agent with insufficient context for proper tool selection and invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description adds minimal value beyond the schema. It mentions 'Provide either activityTypeId or activityTypeName' which clarifies a relationship between payload fields, but doesn't explain the purpose of action, activityId, contactId, limit, page, or most payload fields. The description doesn't adequately compensate for the complete lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: to 'List, inspect, create, update, or delete activities (meetings, events, shared interactions).' This is a specific verb+resource combination that distinguishes it from siblings like monica_list_contacts or monica_manage_task_reminder. However, it doesn't explicitly differentiate from monica_manage_activity_type, which might cause confusion.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions 'Provide either activityTypeId or activityTypeName' but this is parameter guidance, not usage context. There's no indication of when to choose list vs. get vs. create actions, or how this differs from other activity-related tools like monica_manage_call.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Jacob-Stokes/monica-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server