Skip to main content
Glama

chat

Engage with Glean Assistant to retrieve enterprise knowledge, including company policies and time-off details, by providing user questions and optional message context for accurate responses.

Instructions

Chat with Glean Assistant using Glean's RAG

Example request: { "message": "What are the company holidays this year?", "context": [ "Hello, I need some information about time off.", "I'm planning my vacation for next year." ] }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNoOptional previous messages for context. Will be included in order before the current message.
messageYesThe user question or message to send to Glean Assistant.

Implementation Reference

  • The core handler function for the 'chat' tool. Converts simplified input parameters to Glean API format using convertToAPIChatRequest, validates, obtains the Glean client, and creates the chat session.
    export async function chat(params: ToolChatRequest) { const mappedParams = convertToAPIChatRequest(params); const parsedParams = ChatRequestSchema.parse(mappedParams) as ChatRequest; const client = await getClient(); return await client.chat.create(parsedParams); }
  • Zod input schema for the 'chat' tool, defining 'message' (required string) and optional 'context' array of previous messages.
    export const ToolChatSchema = z.object({ message: z .string() .describe('The user question or message to send to Glean Assistant.'), context: z .array(z.string()) .describe( 'Optional previous messages for context. Will be included in order before the current message.', ) .optional(), });
  • Registers the 'chat' tool in the MCP listTools handler, providing name, description, and input schema reference.
    { name: TOOL_NAMES.chat, description: `Chat with Glean Assistant using Glean's RAG Example request: { "message": "What are the company holidays this year?", "context": [ "Hello, I need some information about time off.", "I'm planning my vacation for next year." ] } `, inputSchema: z.toJSONSchema(chat.ToolChatSchema), }, {
  • MCP callTool handler dispatch for 'chat': parses arguments with schema, invokes chat handler, formats response, and returns MCP content.
    case TOOL_NAMES.chat: { const args = chat.ToolChatSchema.parse(request.params.arguments); const result = await chat.chat(args); const formattedResults = chat.formatResponse(result); return { content: [{ type: 'text', text: formattedResults }], isError: false, }; }
  • Helper function that maps the simplified ToolChatRequest to the full Glean ChatRequest format expected by the API.
    function convertToAPIChatRequest(input: ToolChatRequest) { const { message, context = [] } = input; const messages = [ ...context.map((text) => ({ author: Author.User, messageType: MessageType.Content, fragments: [{ text }], })), { author: Author.User, messageType: MessageType.Content, fragments: [{ text: message }], }, ]; const chatRequest: ChatRequest = { messages, }; return chatRequest; }

Other Tools

Related 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/gleanwork/mcp-server'

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