Skip to main content
Glama

chat_with_onyx

Get comprehensive answers by chatting with Onyx AI, which searches your document knowledge bases to provide relevant information for your queries.

Instructions

Chat with Onyx to get comprehensive answers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe question to ask Onyx
personaIdNoThe ID of the persona to use (default: 15)
chatSessionIdNoExisting chat session ID to continue a conversation (optional)
documentSetsNoList of document set names to search within (empty for all)
enableAutoDetectFiltersNoWhether to enable auto-detection of filters (default: true)

Implementation Reference

  • The core handler function for the 'chat_with_onyx' tool. It validates arguments, manages chat sessions, interacts with the Onyx API service to send messages and retrieve responses, and formats the output including sources and session ID.
    export async function handleChatWithOnyx(args: unknown, onyxApiService: OnyxApiService) { try { if (typeof args !== 'object' || args === null) { throw new McpError(ErrorCode.InvalidParams, 'Invalid arguments'); } const { query, personaId = DEFAULT_PERSONA_ID, documentSets = [], // Unused parameter removed: enableAutoDetectFilters chatSessionId = null } = args as ChatParams; if (!query || typeof query !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Query is required'); } // Variable to store the chat session ID (either existing or new) let sessionId = chatSessionId; // Step 1: Create a chat session if one doesn't exist if (!sessionId) { sessionId = await onyxApiService.createChatSession(personaId); } else { console.error(`Using existing chat session with ID: ${sessionId}`); } // Step 2: Send a message to the chat session const { answer, documents } = await onyxApiService.sendChatMessage(sessionId, query, documentSets); return { content: [ { type: 'text', text: `${answer}\n\nSources:\n${documents.map(doc => `- ${doc.semantic_identifier || 'Unknown'} (${doc.document_id || 'Unknown ID'})`).join('\n')}\n\n---\nChat Session ID: ${sessionId}`, metadata: { chat_session_id: sessionId } } ] }; } catch (error) { console.error('Error in handleChatWithOnyx:', error); return { content: [ { type: 'text', text: `Error chatting with Onyx: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • The JSON schema definition for the 'chat_with_onyx' tool, specifying input parameters such as query, personaId, chatSessionId, documentSets, and enableAutoDetectFilters.
    chat_with_onyx: { name: 'chat_with_onyx', description: 'Chat with Onyx to get comprehensive answers', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The question to ask Onyx' }, personaId: { type: 'integer', description: 'The ID of the persona to use (default: 15)', default: 15 }, chatSessionId: { type: 'string', description: 'Existing chat session ID to continue a conversation (optional)' }, documentSets: { type: 'array', items: { type: 'string', }, description: 'List of document set names to search within (empty for all)' }, enableAutoDetectFilters: { type: 'boolean', description: 'Whether to enable auto-detection of filters (default: true)', default: true } }, required: ['query'] } }
  • src/server.ts:66-67 (registration)
    Registers the handler dispatch for 'chat_with_onyx' tool calls within the MCP CallToolRequestSchema handler switch statement.
    case 'chat_with_onyx': return handleChatWithOnyx(request.params.arguments, this.onyxApiService);
  • src/server.ts:89-92 (registration)
    Registers the 'chat_with_onyx' tool schema in the response to ListToolsRequestSchema, making it discoverable by MCP clients.
    tools: [ toolSchemas.search_onyx, toolSchemas.chat_with_onyx, ],
  • Re-exports the handleChatWithOnyx function from chatTool.js for convenient import in server.ts.
    export { handleChatWithOnyx } from './chatTool.js';
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/lupuletic/onyx-mcp-server'

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