Skip to main content
Glama

chat_with_onyx

Interact directly with Onyx AI to retrieve comprehensive answers from knowledge bases, enabling enhanced semantic search and document context retrieval for streamlined knowledge management.

Instructions

Chat with Onyx to get comprehensive answers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
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)
personaIdNoThe ID of the persona to use (default: 15)
queryYesThe question to ask Onyx

Implementation Reference

  • The primary handler function that executes the chat_with_onyx tool logic: validates inputs, manages chat sessions, sends messages to Onyx API, and formats the response with answer, 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 }; } }
  • Input schema and metadata for the chat_with_onyx tool, defining parameters like query (required), 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:62-75 (registration)
    Registers the chat_with_onyx tool handler in the MCP CallToolRequestSchema switch statement, mapping tool name to handleChatWithOnyx execution.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => { switch (request.params.name) { case 'search_onyx': return handleSearchOnyx(request.params.arguments, this.onyxApiService); case 'chat_with_onyx': return handleChatWithOnyx(request.params.arguments, this.onyxApiService); default: throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } }); }
  • src/server.ts:88-92 (registration)
    Registers the chat_with_onyx tool schema in the MCP ListToolsRequestSchema response for tool discovery.
    return { tools: [ toolSchemas.search_onyx, toolSchemas.chat_with_onyx, ],
  • Re-exports the handleChatWithOnyx handler from chatTool.js for use in server.ts.
    export { handleChatWithOnyx } from './chatTool.js';

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/lupuletic/onyx-mcp-server'

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