Skip to main content
Glama
fabian1710

MCP Intercom Server

by fabian1710

list-conversations-from-last-week

Retrieve recent Intercom conversations from the past 7 days to review customer interactions and support activity.

Instructions

Fetch all conversations from the last week (last 7 days)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of the tool: calculates timestamps for the past 7 days and searches conversations using createdAt > startTimestamp and updatedAt < endTimestamp via IntercomClient.
    export async function listConversationsFromLastWeek() {
      // Calculate last week's date range
      const client = new IntercomClient();
      const now = new Date();
      const lastWeekStart = new Date(now);
      lastWeekStart.setDate(now.getDate() - 7);
      lastWeekStart.setHours(0, 0, 0, 0);
    
      const lastWeekEnd = new Date(lastWeekStart);
      lastWeekEnd.setDate(lastWeekStart.getDate() + 6);
      lastWeekEnd.setHours(23, 59, 59, 999);
    
      // Convert to Unix timestamp (seconds)
      const startTimestamp = Math.floor(lastWeekStart.getTime() / 1000);
      const endTimestamp = Math.floor(lastWeekEnd.getTime() / 1000);
    
      return client.searchConversations({
        createdAt: {
          operator: ">",
          value: startTimestamp,
        },
        updatedAt: {
          operator: "<",
          value: endTimestamp,
        },
      });
    }
  • src/index.ts:24-28 (registration)
    Tool registration in MCP server capabilities, defining name, description, input schema (empty object), and output schema.
    "list-conversations-from-last-week": {
      description: "Fetch all conversations from the last week (last 7 days)",
      inputSchema: z.object({}),
      outputSchema: z.any(),
    },
  • Dispatch logic in CallToolRequest handler that calls the listConversationsFromLastWeek function and formats the response as MCP content or error.
    if (name === "list-conversations-from-last-week") {
      try {
        const conversations = await listConversationsFromLastWeek();
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(conversations, null, 2),
            },
          ],
        };
      } catch (error) {
        if (error instanceof Error) {
          return {
            content: [
              {
                type: "text",
                text: `Error: ${error.message}`,
              },
            ],
          };
        }
        throw error;
      }
    }
  • src/index.ts:93-99 (registration)
    Tool listed in the ListTools response with name, description, and input schema.
      name: "list-conversations-from-last-week",
      description: "Fetch all conversations from the last week (last 7 days)",
      inputSchema: {
        type: "object",
        properties: {},
      },
    },

Tool Definition Quality

Score is being calculated. Check back soon.

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/fabian1710/mcp-intercom'

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