Skip to main content
Glama

monica_manage_tag

Manage contact tags in Monica CRM to organize and categorize your contacts effectively. Perform actions like listing, creating, updating, or deleting tags for better contact management.

Instructions

List, inspect, create, update, or delete tags. Tags allow you to group and categorize contacts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYes
tagIdNo
limitNo
pageNo
payloadNo

Implementation Reference

  • Handler function for 'monica_manage_tag' tool that supports listing, getting, creating, updating, and deleting tags using MonicaClient methods.
    async ({ action, tagId, payload, limit, page }) => { switch (action) { case 'list': { const result = await client.listTags(limit, page); const tags = result.data.map(normalizeTag); return { content: [ { type: 'text' as const, text: `Found ${result.meta.total} tags:\n${tags.map((tag) => `• ${tag.name} (ID: ${tag.id})`).join('\n')}` } ] }; } case 'get': { if (!tagId) { throw new Error('tagId is required for get action'); } const result = await client.getTag(tagId); const tag = normalizeTag(result.data); return { content: [ { type: 'text' as const, text: `Tag Details:\n• Name: ${tag.name}\n• Slug: ${tag.nameSlug}\n• Created: ${tag.createdAt}\n• Updated: ${tag.updatedAt}` } ] }; } case 'create': { if (!payload) { throw new Error('payload is required for create action'); } const input = toTagPayloadInput(payload); const result = await client.createTag(input); const tag = normalizeTag(result.data); return { content: [ { type: 'text' as const, text: `Created tag "${tag.name}" (ID: ${tag.id})` } ] }; } case 'update': { if (!tagId) { throw new Error('tagId is required for update action'); } if (!payload) { throw new Error('payload is required for update action'); } const input = toTagPayloadInput(payload); const result = await client.updateTag(tagId, input); const tag = normalizeTag(result.data); return { content: [ { type: 'text' as const, text: `Updated tag "${tag.name}" (ID: ${tag.id})` } ] }; } case 'delete': { if (!tagId) { throw new Error('tagId is required for delete action'); } await client.deleteTag(tagId); return { content: [ { type: 'text' as const, text: `Deleted tag with ID ${tagId}` } ] }; } default: throw new Error(`Unknown action: ${action}`); } }
  • Registration of the 'monica_manage_tag' tool, including title, description, input schema, and reference to the handler function.
    server.registerTool( 'monica_manage_tag', { title: 'Manage Monica tags', description: 'List, inspect, create, update, or delete tags. Tags allow you to group and categorize contacts.', inputSchema: { action: z.enum(['list', 'get', 'create', 'update', 'delete']), tagId: z.number().int().positive().optional(), limit: z.number().int().min(1).max(100).optional(), page: z.number().int().min(1).optional(), payload: tagPayloadSchema.optional() } }, async ({ action, tagId, payload, limit, page }) => { switch (action) { case 'list': { const result = await client.listTags(limit, page); const tags = result.data.map(normalizeTag); return { content: [ { type: 'text' as const, text: `Found ${result.meta.total} tags:\n${tags.map((tag) => `• ${tag.name} (ID: ${tag.id})`).join('\n')}` } ] }; } case 'get': { if (!tagId) { throw new Error('tagId is required for get action'); } const result = await client.getTag(tagId); const tag = normalizeTag(result.data); return { content: [ { type: 'text' as const, text: `Tag Details:\n• Name: ${tag.name}\n• Slug: ${tag.nameSlug}\n• Created: ${tag.createdAt}\n• Updated: ${tag.updatedAt}` } ] }; } case 'create': { if (!payload) { throw new Error('payload is required for create action'); } const input = toTagPayloadInput(payload); const result = await client.createTag(input); const tag = normalizeTag(result.data); return { content: [ { type: 'text' as const, text: `Created tag "${tag.name}" (ID: ${tag.id})` } ] }; } case 'update': { if (!tagId) { throw new Error('tagId is required for update action'); } if (!payload) { throw new Error('payload is required for update action'); } const input = toTagPayloadInput(payload); const result = await client.updateTag(tagId, input); const tag = normalizeTag(result.data); return { content: [ { type: 'text' as const, text: `Updated tag "${tag.name}" (ID: ${tag.id})` } ] }; } case 'delete': { if (!tagId) { throw new Error('tagId is required for delete action'); } await client.deleteTag(tagId); return { content: [ { type: 'text' as const, text: `Deleted tag with ID ${tagId}` } ] }; } default: throw new Error(`Unknown action: ${action}`); } } );
  • Zod input schema defining parameters for the tool: action, optional tagId, limit, page, and payload.
    inputSchema: { action: z.enum(['list', 'get', 'create', 'update', 'delete']), tagId: z.number().int().positive().optional(), limit: z.number().int().min(1).max(100).optional(), page: z.number().int().min(1).optional(), payload: tagPayloadSchema.optional()
  • Zod schema for tag payload, requiring a name string between 1 and 255 characters.
    const tagPayloadSchema = z.object({ name: z.string().min(1).max(255) });
  • Helper function to convert TagPayloadForm to the input format expected by createTag and updateTag methods.
    function toTagPayloadInput(payload: TagPayloadForm): CreateTagPayload & UpdateTagPayload { return { name: payload.name }; }

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