Skip to main content
Glama
DriftOS

DriftOS MCP Server

Official
by DriftOS

Build LLM Prompt

driftos_build_prompt
Read-onlyIdempotent

Build ready-to-use LLM prompts with context and facts for API calls, enabling intelligent conversation routing without full history dependencies.

Instructions

Build a ready-to-use prompt for LLM calls with context and facts.

Args:

  • branch_id (string): The branch ID to build prompt for

  • system_prompt (string, optional): Custom system prompt prefix

Returns: { "system": string, // Full system prompt with topic and facts "messages": [{ "role": string, "content": string }] // Conversation messages }

Use this to get a complete prompt ready for OpenAI/Anthropic/etc API calls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branch_idYesBranch ID to build prompt for
system_promptNoCustom system prompt prefix

Implementation Reference

  • Complete registration of the 'driftos_build_prompt' MCP tool, including schema, description, and inline handler function that delegates to driftClient.buildPrompt.
      server.registerTool(
        'driftos_build_prompt',
        {
          title: 'Build LLM Prompt',
          description: `Build a ready-to-use prompt for LLM calls with context and facts.
    
    Args:
      - branch_id (string): The branch ID to build prompt for
      - system_prompt (string, optional): Custom system prompt prefix
    
    Returns:
      {
        "system": string,  // Full system prompt with topic and facts
        "messages": [{ "role": string, "content": string }]  // Conversation messages
      }
    
    Use this to get a complete prompt ready for OpenAI/Anthropic/etc API calls.`,
          inputSchema: z.object({
            branch_id: z.string().min(1).describe('Branch ID to build prompt for'),
            system_prompt: z.string().optional().describe('Custom system prompt prefix'),
          }).strict(),
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
        async (params) => {
          try {
            const result = await driftClient.buildPrompt(
              params.branch_id,
              params.system_prompt
            );
    
            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 building prompt: ${message}`,
                },
              ],
              isError: true,
            };
          }
        }
      );
  • Inline handler function for executing the 'driftos_build_prompt' tool. It invokes driftClient.buildPrompt and returns the JSON-formatted result as MCP content, with error handling.
    async (params) => {
      try {
        const result = await driftClient.buildPrompt(
          params.branch_id,
          params.system_prompt
        );
    
        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 building prompt: ${message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Tool metadata and input schema using Zod: requires branch_id (string), optional system_prompt (string). Includes title, description, and annotations indicating read-only, idempotent behavior.
        {
          title: 'Build LLM Prompt',
          description: `Build a ready-to-use prompt for LLM calls with context and facts.
    
    Args:
      - branch_id (string): The branch ID to build prompt for
      - system_prompt (string, optional): Custom system prompt prefix
    
    Returns:
      {
        "system": string,  // Full system prompt with topic and facts
        "messages": [{ "role": string, "content": string }]  // Conversation messages
      }
    
    Use this to get a complete prompt ready for OpenAI/Anthropic/etc API calls.`,
          inputSchema: z.object({
            branch_id: z.string().min(1).describe('Branch ID to build prompt for'),
            system_prompt: z.string().optional().describe('Custom system prompt prefix'),
          }).strict(),
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
  • Exports the driftClient instance, created from @driftos/client, which provides the buildPrompt method called by the tool handler.
    export const driftClient = createDriftClient(DRIFTOS_API_URL);
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the agent knows this is a safe, non-mutating operation. The description adds useful context about what the tool builds (prompts with context and facts) and the intended use (for LLM API calls), but doesn't provide additional behavioral details like rate limits, authentication needs, or performance characteristics beyond what annotations cover.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, args, returns, usage) and appropriately sized. Every sentence adds value, though the Args section could be more concise since it largely repeats schema information. The front-loaded purpose statement is effective.

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

Completeness4/5

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

Given the tool's moderate complexity, rich annotations, and 100% schema coverage, the description provides adequate context. It explains what the tool does, shows the return structure (though no formal output schema exists), and indicates usage context. However, it doesn't fully explain how the prompt is constructed from 'context and facts' or clarify the relationship with sibling tools that might provide those inputs.

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?

With 100% schema description coverage, the input schema already fully documents both parameters. The description's Args section repeats the parameter names but doesn't add meaningful semantic context beyond what's in the schema. The baseline score of 3 is appropriate when the schema carries the full parameter documentation burden.

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 tool's purpose with specific verbs ('build a ready-to-use prompt for LLM calls') and resources ('with context and facts'). It distinguishes from siblings like driftos_get_context or driftos_get_facts by focusing on prompt construction rather than raw data retrieval.

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 ('to get a complete prompt ready for OpenAI/Anthropic/etc API calls'), but doesn't explicitly state when not to use it or name specific alternatives among the sibling tools. The context is helpful but lacks explicit exclusion guidance.

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