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';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'comprehensive answers' but fails to describe key traits such as whether this is a read-only operation, if it requires authentication, rate limits, or how chat sessions are managed. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It is appropriately sized and front-loaded, clearly stating the tool's core function without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a chat tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It does not explain return values, error handling, or how the tool integrates with the sibling 'search_onyx', leaving the agent with insufficient context for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema fully documents all 5 parameters. The description adds no additional meaning beyond what the schema provides, such as explaining how parameters interact or their practical use. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool's purpose as 'Chat with Onyx to get comprehensive answers', which identifies the action (chat) and resource (Onyx) but is vague about what distinguishes it from the sibling tool 'search_onyx'. It lacks specificity on how chatting differs from searching, leaving the purpose unclear in context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus the sibling 'search_onyx'. The description does not mention alternatives, exclusions, or contextual usage, leaving the agent without direction on tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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