Skip to main content
Glama

create_doc

Create new documents by providing a title, markdown text, and optional folder. Supports integration with DartQL for bulk creation.

Instructions

Create a new document with title, text (markdown supported), and optional folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesDocument title
textYesDocument text content (markdown supported)
folderNoFolder dart_id or name (optional)

Implementation Reference

  • Main handler function that validates inputs (title, text, optional folder), resolves folder reference, calls DartClient.createDoc(), and returns the created document with a deep link URL.
    export async function handleCreateDoc(input: CreateDocInput): Promise<CreateDocOutput> {
      const DART_TOKEN = process.env.DART_TOKEN;
    
      if (!DART_TOKEN) {
        throw new DartAPIError(
          'DART_TOKEN environment variable is required. Get your token from: https://app.dartai.com/?settings=account',
          401
        );
      }
    
      // ============================================================================
      // Step 1: Validate required fields
      // ============================================================================
      if (!input.title || typeof input.title !== 'string' || input.title.trim() === '') {
        throw new ValidationError(
          'title is required and must be a non-empty string',
          'title'
        );
      }
    
      if (!input.text || typeof input.text !== 'string') {
        throw new ValidationError(
          'text is required and must be a string (markdown supported)',
          'text'
        );
      }
    
      // ============================================================================
      // Step 2: Validate folder reference (if provided)
      // ============================================================================
      let resolvedFolder: string | undefined;
    
      if (input.folder) {
        // Get config to validate folder reference
        let config: DartConfig;
        try {
          config = await handleGetConfig({ cache_bust: false });
        } catch (error) {
          if (error instanceof DartAPIError) {
            throw new DartAPIError(
              `Failed to retrieve workspace config for folder validation: ${error.message}`,
              error.statusCode,
              error.response
            );
          }
          throw error;
        }
    
        // Check if folder exists
        if (!config.folders || config.folders.length === 0) {
          throw new ValidationError(
            'No folders found in workspace configuration. Create a folder first in Dart AI.',
            'folder'
          );
        }
    
        const folder = findFolder(config.folders, input.folder);
    
        if (!folder) {
          const folderNames = getFolderNames(config.folders);
          const availableFolders = folderNames.join(', ');
          throw new ValidationError(
            `Invalid folder: "${input.folder}" not found in workspace. Available folders: ${availableFolders}`,
            'folder',
            folderNames
          );
        }
    
        resolvedFolder = folder.dart_id;
      }
    
      // ============================================================================
      // Step 3: Call DartClient.createDoc()
      // ============================================================================
      const client = new DartClient({ token: DART_TOKEN });
    
      const docInput: { title: string; text: string; folder?: string } = {
        title: input.title,
        text: input.text,
      };
    
      if (resolvedFolder) {
        docInput.folder = resolvedFolder;
      }
    
      let createdDoc;
      try {
        createdDoc = await client.createDoc(docInput);
      } catch (error) {
        if (error instanceof DartAPIError) {
          throw new DartAPIError(
            `Failed to create document: ${error.message}`,
            error.statusCode,
            error.response
          );
        }
        throw error;
      }
    
      // ============================================================================
      // Step 4: Generate deep link URL and return output
      // ============================================================================
      const deepLinkUrl = `https://app.dartai.com/doc/${createdDoc.doc_id}`;
    
      return {
        doc_id: createdDoc.doc_id,
        title: createdDoc.title,
        url: deepLinkUrl,
        created_at: createdDoc.created_at,
        all_fields: createdDoc,
      };
    }
  • CreateDocInput interface defining the input schema: title (string), text (string), folder (optional string).
    export interface CreateDocInput {
      title: string;
      text: string;
      folder?: string;
    }
  • CreateDocOutput interface defining the return shape: doc_id, title, url, created_at, all_fields (DartDoc).
    export interface CreateDocOutput {
      doc_id: string;
      title: string;
      url: string;
      created_at: string;
      all_fields: DartDoc;
    }
  • src/index.ts:693-714 (registration)
    Tool registration with name 'create_doc', description, inputSchema (title, text required, folder optional).
    {
      name: 'create_doc',
      description: 'Create a new document with title, text (markdown supported), and optional folder',
      inputSchema: {
        type: 'object',
        properties: {
          title: {
            type: 'string',
            description: 'Document title',
          },
          text: {
            type: 'string',
            description: 'Document text content (markdown supported)',
          },
          folder: {
            type: 'string',
            description: 'Folder dart_id or name (optional)',
          },
        },
        required: ['title', 'text'],
      },
    },
  • src/index.ts:1124-1130 (registration)
    Tool dispatch case 'create_doc' that calls handleCreateDoc and returns JSON-stringified result.
    case 'create_doc': {
      const result = await handleCreateDoc((args || {}) as any);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
Behavior2/5

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

With no annotations, the description should disclose more behavioral traits (side effects, permissions, error handling). It only mentions markdown support and optional folder, leaving gaps.

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?

Single sentence, no extraneous words, efficient.

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

Completeness3/5

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

Adequate for a simple creation tool but missing return value information; no output schema so description should hint at what is returned.

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 covers all parameters (100%), so description adds modest value by noting markdown support for text; otherwise redundant.

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 it creates a new document with specific fields (title, text, folder), distinguishing it from siblings like update_doc and delete_doc.

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 on when to use this tool vs alternatives; no prerequisites or exclusions mentioned.

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/standardbeagle/dart-query'

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