Skip to main content
Glama
DriftOS

DriftOS MCP Server

Official
by DriftOS

Route Message

driftos_route_message

Analyzes conversation messages to determine whether they introduce new topics, continue current discussions, or return to previous ones using semantic drift detection.

Instructions

Route a message to the appropriate conversation branch using semantic drift detection.

Returns one of three actions:

  • BRANCH: New topic detected, creates a new branch

  • STAY: Message continues the current topic

  • ROUTE: Returns to a previously discussed topic

Args:

  • conversation_id (string): Unique identifier for the conversation

  • content (string): The message content to route

  • role ('user' | 'assistant'): Who sent the message (default: 'user')

Returns: { "action": "BRANCH" | "STAY" | "ROUTE", "branchId": string, "branchTopic": string, "confidence": number, "isNewBranch": boolean }

Example:

  • "I want to buy a house in London" -> BRANCH (new topic)

  • "What areas have good schools?" -> STAY (same topic)

  • "Back to houses - what about mortgage rates?" -> ROUTE (returns to previous branch)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
conversation_idYesUnique identifier for the conversation
contentYesThe message content to route
roleNoWho sent the messageuser

Implementation Reference

  • The tool handler that routes the message using driftClient and returns a text content response with the result or an error.
    async (params) => {
      try {
        const result = await driftClient.route(
          params.conversation_id,
          params.content,
          params.role
        );
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        const message = error instanceof Error ? error.message : 'Unknown error';
        return {
          content: [
            {
              type: 'text' as const,
              text: `Error routing message: ${message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema using Zod for validating tool parameters: conversation_id (string), content (string), role (enum).
    inputSchema: z.object({
      conversation_id: z.string().min(1).describe('Unique identifier for the conversation'),
      content: z.string().min(1).describe('The message content to route'),
      role: z.enum(['user', 'assistant']).default('user').describe('Who sent the message'),
    }).strict(),
  • Function that registers the 'driftos_route_message' tool with the MCP server, providing title, description, input schema, annotations, and the handler function.
    export function registerRouteTools(server: McpServer): void {
      server.registerTool(
        'driftos_route_message',
        {
          title: 'Route Message',
          description: `Route a message to the appropriate conversation branch using semantic drift detection.
    
    Returns one of three actions:
    - BRANCH: New topic detected, creates a new branch
    - STAY: Message continues the current topic
    - ROUTE: Returns to a previously discussed topic
    
    Args:
      - conversation_id (string): Unique identifier for the conversation
      - content (string): The message content to route
      - role ('user' | 'assistant'): Who sent the message (default: 'user')
    
    Returns:
      {
        "action": "BRANCH" | "STAY" | "ROUTE",
        "branchId": string,
        "branchTopic": string,
        "confidence": number,
        "isNewBranch": boolean
      }
    
    Example:
      - "I want to buy a house in London" -> BRANCH (new topic)
      - "What areas have good schools?" -> STAY (same topic)
      - "Back to houses - what about mortgage rates?" -> ROUTE (returns to previous branch)`,
          inputSchema: z.object({
            conversation_id: z.string().min(1).describe('Unique identifier for the conversation'),
            content: z.string().min(1).describe('The message content to route'),
            role: z.enum(['user', 'assistant']).default('user').describe('Who sent the message'),
          }).strict(),
          annotations: {
            readOnlyHint: false,
            destructiveHint: false,
            idempotentHint: false,
            openWorldHint: false,
          },
        },
        async (params) => {
          try {
            const result = await driftClient.route(
              params.conversation_id,
              params.content,
              params.role
            );
    
            return {
              content: [
                {
                  type: 'text' as const,
                  text: JSON.stringify(result, null, 2),
                },
              ],
            };
          } catch (error) {
            const message = error instanceof Error ? error.message : 'Unknown error';
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Error routing message: ${message}`,
                },
              ],
              isError: true,
            };
          }
        }
      );
    }
  • src/index.ts:17-17 (registration)
    Calls registerRouteTools to register the tool on the main McpServer instance.
    registerRouteTools(server);
  • Exports the driftClient instance created from external library, used in the tool handler for routing messages.
    import { createDriftClient } from '@driftos/client';
    import { DRIFTOS_API_URL } from '../constants.js';
    
    export const driftClient = createDriftClient(DRIFTOS_API_URL);
Behavior4/5

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

Annotations indicate this is a non-read-only, non-destructive, non-idempotent tool, but the description adds valuable behavioral context beyond that. It explains the three possible actions (BRANCH, STAY, ROUTE) and what they mean in practice (e.g., 'creates a new branch', 'continues the current topic'), which is not covered by annotations. However, it does not mention potential side effects like rate limits or authentication needs.

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 well-structured and front-loaded with the core purpose, followed by clear sections for returns, args, and examples. Every sentence adds value—none are redundant or wasteful—making it efficient and easy to parse for an AI agent.

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

Completeness5/5

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

Given the tool's complexity (semantic routing with multiple outcomes) and lack of an output schema, the description provides comprehensive context. It fully explains the return structure, actions, and includes practical examples, compensating for the missing output schema and ensuring the agent understands how to interpret results.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description repeats parameter names and basic meanings in the 'Args' section but does not add significant semantic details beyond what the schema provides, such as explaining how 'role' affects routing decisions. This meets the baseline of 3 for high schema coverage.

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

Purpose5/5

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

The description clearly states the specific action ('Route a message') and mechanism ('using semantic drift detection'), distinguishing it from sibling tools like 'driftos_list_branches' or 'driftos_extract_facts'. It explicitly defines the three possible routing outcomes (BRANCH, STAY, ROUTE), making the purpose highly specific and differentiated.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool ('Route a message to the appropriate conversation branch') and includes examples that illustrate different scenarios (new topic, same topic, return to previous topic). However, it does not explicitly state when NOT to use it or name alternatives among sibling tools, such as when to use 'driftos_get_context' instead.

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/DriftOS/driftos-mcp-server'

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