Skip to main content
Glama

monica_manage_contact_field

Manage contact fields in Monica CRM by creating, updating, deleting, or retrieving email addresses, phone numbers, and social media handles for specific contacts.

Instructions

List, get, create, update, or delete contact fields like email addresses, phone numbers, social media handles, etc. Use this simplified tool instead of monica_manage_contact when managing contact fields. Provide contactId and fieldPayload with data and contactFieldTypeName (e.g., "Email", "Phone").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
contactIdNo
contactFieldIdNo
fieldPayloadNo
limitNo
pageNo

Implementation Reference

  • Registration of the 'monica_manage_contact_field' tool, including its title, description, input schema, and thin wrapper handler that calls handleContactOperation with section='field'.
    server.registerTool( 'monica_manage_contact_field', { title: 'Manage contact fields', description: 'List, get, create, update, or delete contact fields like email addresses, phone numbers, social media handles, etc. Use this simplified tool instead of monica_manage_contact when managing contact fields. Provide contactId and fieldPayload with data and contactFieldTypeName (e.g., "Email", "Phone").', inputSchema: fieldInputSchema }, async (rawInput) => { const input = z.object(fieldInputSchema).parse(rawInput); return handleContactOperation( { section: 'field', action: input.action, contactId: input.contactId, contactFieldId: input.contactFieldId, fieldPayload: input.fieldPayload, limit: input.limit, page: input.page }, context ); } );
  • Core handler logic for contact field management (list, get, create, update, delete) executed when section='field' in handleContactOperation, which is called by the tool's wrapper handler.
    case 'field': { switch (input.action) { case 'list': { const response = await client.listContactFields({ contactId: input.contactId!, limit: input.limit, page: input.page }); const fields = response.data.map(normalizeContactField); return { content: [ { type: 'text' as const, text: fields.length ? `Fetched ${fields.length} contact field${fields.length === 1 ? '' : 's'} for contact ${input.contactId}.` : `No contact fields found for contact ${input.contactId}.` } ], structuredContent: { section: input.section, action: input.action, contactId: input.contactId, fields, pagination: { currentPage: response.meta.current_page, lastPage: response.meta.last_page, perPage: response.meta.per_page, total: response.meta.total } } }; } case 'get': { const response = await client.getContactField(input.contactFieldId!); const field = normalizeContactField(response.data); return { content: [ { type: 'text' as const, text: `Retrieved contact field ${field.type.name} (ID ${field.id}).` } ], structuredContent: { section: input.section, action: input.action, field } }; } case 'create': { const payload = input.fieldPayload!; const contactFieldTypeId = await resolveContactFieldTypeId(client, { contactFieldTypeId: payload.contactFieldTypeId, contactFieldTypeName: payload.contactFieldTypeName }); const result = await client.createContactField( toContactFieldPayloadInput({ ...payload, contactFieldTypeId }) ); const field = normalizeContactField(result.data); logger.info({ contactFieldId: field.id, contactId: field.contactId }, 'Created Monica contact field'); return { content: [ { type: 'text' as const, text: `Created contact field ${field.type.name} (ID ${field.id}) for contact ${field.contactId}.` } ], structuredContent: { section: input.section, action: input.action, field } }; } case 'update': { const payload = input.fieldPayload!; const contactFieldTypeId = await resolveContactFieldTypeId(client, { contactFieldTypeId: payload.contactFieldTypeId, contactFieldTypeName: payload.contactFieldTypeName }); const result = await client.updateContactField( input.contactFieldId!, toContactFieldPayloadInput({ ...payload, contactFieldTypeId }) ); const field = normalizeContactField(result.data); logger.info({ contactFieldId: input.contactFieldId }, 'Updated Monica contact field'); return { content: [ { type: 'text' as const, text: `Updated contact field ${field.type.name} (ID ${field.id}).` } ], structuredContent: { section: input.section, action: input.action, contactFieldId: input.contactFieldId, field } }; } case 'delete': { const result = await client.deleteContactField(input.contactFieldId!); logger.info({ contactFieldId: input.contactFieldId }, 'Deleted Monica contact field'); return { content: [ { type: 'text' as const, text: `Deleted contact field ID ${input.contactFieldId}.` } ], structuredContent: { section: input.section, action: input.action, contactFieldId: input.contactFieldId, result } }; } default: return unreachable(input.action as never); } }
  • Zod schema for contact field payload, used in create and update operations, with validation requiring either contactFieldTypeId or contactFieldTypeName.
    const contactFieldPayloadSchema = z .object({ contactId: z.number().int().positive(), contactFieldTypeId: z.number().int().positive().optional(), contactFieldTypeName: z.string().min(1).max(255).optional(), data: z.string().min(1).max(255) }) .superRefine((data, ctx) => { if (typeof data.contactFieldTypeId !== 'number' && !data.contactFieldTypeName) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Provide contactFieldTypeId or contactFieldTypeName.' }); } });
  • Input schema for the monica_manage_contact_field tool, defining parameters like action, contactId, contactFieldId, fieldPayload, etc.
    const fieldInputSchema = { action: z.enum(['list', 'get', 'create', 'update', 'delete']), contactId: z.number().int().positive().optional(), contactFieldId: z.number().int().positive().optional(), fieldPayload: contactFieldPayloadSchema.optional(), limit: z.number().int().min(1).max(100).optional(), page: z.number().int().min(1).optional()

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