Skip to main content
Glama
DriftOS

DriftOS MCP Server

Official
by DriftOS

driftos_extract_facts

Extract structured facts from conversation branches to identify key information and maintain topic context in semantic routing systems.

Instructions

Trigger fact extraction for a branch. Use when you want to explicitly extract facts from the current conversation state.

Args:

  • branch_id (string): The branch ID to extract facts from

Returns: { "facts": [{ "key": string, "value": string }] }

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branch_idYesBranch ID to extract facts from

Implementation Reference

  • Handler function for the 'driftos_extract_facts' tool. It calls driftClient.extractFacts(branch_id), stringifies the result as JSON, and handles errors by returning an error message.
    async (params) => {
      try {
        const result = await driftClient.extractFacts(params.branch_id);
    
        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 extracting facts: ${message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Input schema validation using Zod for the branch_id parameter.
    inputSchema: z.object({
      branch_id: z.string().min(1).describe('Branch ID to extract facts from'),
    }).strict(),
  • Registration of the 'driftos_extract_facts' tool using server.registerTool, including schema, annotations, description, and inline handler.
      server.registerTool(
        'driftos_extract_facts',
        {
          title: 'Extract Facts from Branch',
          description: `Trigger fact extraction for a branch. Use when you want to explicitly extract facts from the current conversation state.
    
    Args:
      - branch_id (string): The branch ID to extract facts from
    
    Returns:
      { "facts": [{ "key": string, "value": string }] }`,
          inputSchema: z.object({
            branch_id: z.string().min(1).describe('Branch ID to extract facts from'),
          }).strict(),
          annotations: {
            readOnlyHint: false,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
        async (params) => {
          try {
            const result = await driftClient.extractFacts(params.branch_id);
    
            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 extracting facts: ${message}`,
                },
              ],
              isError: true,
            };
          }
        }
      );
  • src/index.ts:20-20 (registration)
    Invocation of registerFactsTools(server) which registers the 'driftos_extract_facts' tool among others.
    registerFactsTools(server);

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