Skip to main content
Glama

get_conversation_context

Retrieve conversation summaries and recent message history for hospitality workflows, enabling agents to quickly understand guest interactions and context.

Instructions

Return an agent-friendly conversation summary plus recent message history.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversationIdYes
detailLevelNo
messageLimitNo

Implementation Reference

  • The tool handler for 'get_conversation_context' fetches conversation, message, reservation, and listing data from the client and processes it using 'buildConversationContext'.
    async ({ conversationId, detailLevel, messageLimit }) => {
      const conversation = await client.getConversation(conversationId, {
        includeResources: 1
      });
      const messages = await client.getConversationMessages(conversationId, {
        limit: messageLimit ?? 10
      });
      const reservation =
        conversation.Reservation ??
        (conversation.reservationId != null ? await client.getReservation(conversation.reservationId).catch(() => null) : null);
      const listingId = conversation.listingMapId ?? conversation.listingId ?? reservation?.listingMapId ?? reservation?.listingId ?? null;
      const listing = listingId != null ? await client.getListing(listingId).catch(() => null) : null;
    
      return toolResult(
        buildConversationContext({
          conversation,
          messages,
          reservation,
          listing,
          detailLevel: detailLevel ?? "compact"
        })
      );
    }
  • Registration function for 'get_conversation_context' tool.
    export function registerGetConversationContextTool(server: McpServer, client: HostawayDataClient) {
      server.registerTool(
        "get_conversation_context",
        {
          description: "Return an agent-friendly conversation summary plus recent message history.",
          inputSchema: {
            conversationId: z.union([z.string(), z.number()]),
            detailLevel: z.enum(["compact", "full"]).optional(),
            messageLimit: z.number().int().min(1).max(100).optional()
          },
          outputSchema: {
            conversationId: z.string(),
            reservationId: z.string().nullable(),
            listingId: z.string().nullable(),
            guest: z.object({
              name: z.string(),
              email: z.string().nullable()
            }),
            listing: z.object({
              id: z.string().nullable(),
              name: z.string().nullable()
            }),
            reservation: z.object({
              id: z.string().nullable(),
              status: z.string().nullable(),
              arrivalDate: z.string().nullable(),
              departureDate: z.string().nullable()
            }),
            channel: z.enum(["Airbnb", "Booking.com", "VRBO", "Direct"]),
            attention: z.object({
              rawHasUnreadMessages: z.boolean().nullable(),
              latestGuestMessageTimestamp: z.string().nullable(),
              hostRepliedAfterLatestGuestMessage: z.boolean(),
              needsAttention: z.boolean()
            }),
            latestSpeaker: z.enum(["guest", "host", "unknown"]).nullable(),
            hasAttachments: z.boolean(),
            preview: z.string(),
            recentMessages: z.array(
              z.object({
                id: z.string(),
                speaker: z.enum(["guest", "host", "unknown"]),
                text: z.string(),
                timestamp: z.string().nullable(),
                hasAttachments: z.boolean()
              })
            ),
            missing: z.array(z.string()),
            notes: z.array(z.string()),
            raw: z
              .object({
                conversation: z.record(z.string(), z.unknown()),
                reservation: z.record(z.string(), z.unknown()).nullable(),
                listing: z.record(z.string(), z.unknown()).nullable()
              })
              .optional()
          }
        },
        async ({ conversationId, detailLevel, messageLimit }) => {
          const conversation = await client.getConversation(conversationId, {
            includeResources: 1
          });
          const messages = await client.getConversationMessages(conversationId, {
            limit: messageLimit ?? 10
          });
          const reservation =
            conversation.Reservation ??
            (conversation.reservationId != null ? await client.getReservation(conversation.reservationId).catch(() => null) : null);
          const listingId = conversation.listingMapId ?? conversation.listingId ?? reservation?.listingMapId ?? reservation?.listingId ?? null;
          const listing = listingId != null ? await client.getListing(listingId).catch(() => null) : null;
    
          return toolResult(
            buildConversationContext({
              conversation,
              messages,
              reservation,
              listing,
              detailLevel: detailLevel ?? "compact"
            })
          );
        }
      );
    }
  • Zod schema definitions for input and output of 'get_conversation_context'.
    inputSchema: {
      conversationId: z.union([z.string(), z.number()]),
      detailLevel: z.enum(["compact", "full"]).optional(),
      messageLimit: z.number().int().min(1).max(100).optional()
    },
    outputSchema: {
      conversationId: z.string(),
      reservationId: z.string().nullable(),
      listingId: z.string().nullable(),
      guest: z.object({
        name: z.string(),
        email: z.string().nullable()
      }),
      listing: z.object({
        id: z.string().nullable(),
        name: z.string().nullable()
      }),
      reservation: z.object({
        id: z.string().nullable(),
        status: z.string().nullable(),
        arrivalDate: z.string().nullable(),
        departureDate: z.string().nullable()
      }),
      channel: z.enum(["Airbnb", "Booking.com", "VRBO", "Direct"]),
      attention: z.object({
        rawHasUnreadMessages: z.boolean().nullable(),
        latestGuestMessageTimestamp: z.string().nullable(),
        hostRepliedAfterLatestGuestMessage: z.boolean(),
        needsAttention: z.boolean()
      }),
      latestSpeaker: z.enum(["guest", "host", "unknown"]).nullable(),
      hasAttachments: z.boolean(),
      preview: z.string(),
      recentMessages: z.array(
        z.object({
          id: z.string(),
          speaker: z.enum(["guest", "host", "unknown"]),
          text: z.string(),
          timestamp: z.string().nullable(),
          hasAttachments: z.boolean()
        })
      ),
      missing: z.array(z.string()),
      notes: z.array(z.string()),
      raw: z
        .object({
          conversation: z.record(z.string(), z.unknown()),
          reservation: z.record(z.string(), z.unknown()).nullable(),
          listing: z.record(z.string(), z.unknown()).nullable()
        })
        .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/uncfreak1255-code/hostaway-mcp'

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