Skip to main content
Glama
DriftOS

DriftOS MCP Server

Official
by DriftOS

driftos_get_context

Retrieve focused conversation context for LLMs by extracting relevant messages and accumulated facts from specific branches, reducing history overload.

Instructions

Get assembled context for a conversation branch, including messages and facts from related branches.

This is what you pass to an LLM instead of the entire conversation history. Returns only the relevant messages from the current branch plus accumulated facts.

Args:

  • branch_id (string): The branch ID to get context for (returned from route_message)

Returns: { "branchId": string, "branchTopic": string, "messages": [ { "role": "user" | "assistant", "content": string } ], "allFacts": [ { "branchTopic": string, "isCurrent": boolean, "facts": [{ "key": string, "value": string, "confidence": number }] } ] }

Use this to build focused LLM context windows instead of dumping entire conversation history.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branch_idYesBranch ID to get context for

Implementation Reference

  • Executes the tool logic: calls driftClient.getContext(branch_id), stringifies the result as JSON text response, or returns error if failed.
    async (params) => { try { const result = await driftClient.getContext(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 getting context: ${message}`, }, ], isError: true, }; } }
  • Zod input schema validating the branch_id parameter.
    inputSchema: z.object({ branch_id: z.string().min(1).describe('Branch ID to get context for'), }).strict(),
  • Direct registration of the 'driftos_get_context' tool on the MCP server, including title, description, input schema, annotations, and inline handler function.
    server.registerTool( 'driftos_get_context', { title: 'Get Conversation Context', description: `Get assembled context for a conversation branch, including messages and facts from related branches. This is what you pass to an LLM instead of the entire conversation history. Returns only the relevant messages from the current branch plus accumulated facts. Args: - branch_id (string): The branch ID to get context for (returned from route_message) Returns: { "branchId": string, "branchTopic": string, "messages": [ { "role": "user" | "assistant", "content": string } ], "allFacts": [ { "branchTopic": string, "isCurrent": boolean, "facts": [{ "key": string, "value": string, "confidence": number }] } ] } Use this to build focused LLM context windows instead of dumping entire conversation history.`, inputSchema: z.object({ branch_id: z.string().min(1).describe('Branch ID to get context for'), }).strict(), annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, }, async (params) => { try { const result = await driftClient.getContext(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 getting context: ${message}`, }, ], isError: true, }; } } );
  • Creation of the driftClient instance used in the tool handler to perform the getContext call.
    export const driftClient = createDriftClient(DRIFTOS_API_URL);
  • src/index.ts:18-18 (registration)
    Top-level call to registerContextTools during MCP server initialization, which includes registration of driftos_get_context.
    registerContextTools(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