Skip to main content
Glama

relentless_insert

Insert validated data into Notion databases to create documentation, blog posts, leads, or structured content with immediate visibility in Notion.

Instructions

Insert a new entry into a Notion database via Relentless API. Data is automatically validated before insertion to catch errors early. Use this to create new documentation, blog posts, leads, or any structured data. The data will be immediately visible in Notion and accessible via the Relentless API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
databaseYesThe database name (e.g., "blog", "docs", "leads"). Use relentless_list_databases to see available databases.
dataYesThe data to insert. Keys should match your Notion database property names exactly (e.g., {"Title": "My Post", "Content": "...", "Published": true}). Property names are case-sensitive. Will be validated before insertion.
skipValidationNoSkip pre-insert validation. Use only if you know the data is correct and want to speed up insertion.

Implementation Reference

  • The handler function for the 'relentless_insert' tool. It validates the input data (optionally skipping validation), performs a POST request to the Relentless API to insert the data into the specified Notion database, handles retries and errors, and returns the API response.
    case 'relentless_insert': {
      const { database, data, skipValidation = false } = args as {
        database: string
        data: Record<string, any>
        skipValidation?: boolean
      }
    
      if (!database || !data) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Missing required parameters: database and data'
        )
      }
    
      console.error(`[${new Date().toISOString()}] Starting insert to ${database}`)
    
      // Basic validation
      if (!data || typeof data !== 'object' || Array.isArray(data)) {
        throw new McpError(ErrorCode.InvalidParams, 'data must be a non-null object')
      }
    
      const dataSize = JSON.stringify(data).length
      if (dataSize > 1_000_000) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Data too large: ${(dataSize / 1_000_000).toFixed(2)}MB (max 1MB)`
        )
      }
    
      // Pre-insertion validation (fetch schema from Relentless API)
      if (!skipValidation) {
        console.error('🔍 Validating data before insertion...')
    
        const schema = await getDatabaseSchema(database)
    
        if (schema) {
          try {
            const validation = validator.validateWithSchema(schema, data)
    
            if (!validation.valid) {
              const errorMessage = validation.errors
                .map(
                  (err: any) =>
                    `  • ${err.field}: ${err.error}${
                      err.expected ? ` (expected: ${err.expected})` : ''
                    }`
                )
                .join('\n')
    
              throw new McpError(
                ErrorCode.InvalidParams,
                `❌ Validation failed:\n${errorMessage}\n\nFix these errors and try again, or use skipValidation: true to bypass.`
              )
            }
    
            // Show warnings if any
            if (validation.warnings.length > 0) {
              console.error('⚠️  Warnings:')
              validation.warnings.forEach((warning: string) => console.error(`  • ${warning}`))
            }
    
            console.error('✅ Validation passed')
          } catch (error) {
            if (error instanceof McpError) {
              throw error
            }
            console.error(`⚠️  Validation error (will proceed anyway): ${error}`)
          }
        } else {
          console.error('⚠️  Could not validate: schema not available')
        }
      }
    
      // Perform insert with retry
      console.error('📤 Inserting data...')
      const endpoint = `${RELENTLESS_API_BASE}/api/v1/public/db/${database}/insert`
      const result = await relentlessRequest(endpoint, {
        method: 'POST',
        body: JSON.stringify(data),
      })
    
      console.error(`[${new Date().toISOString()}] ✅ Insert successful`)
    
      return {
        content: [
          {
            type: 'text',
            text: `✅ Successfully inserted into ${database}!\n\nResponse:\n${JSON.stringify(
              result,
              null,
              2
            )}`,
          },
        ],
      }
    }
  • Input schema definition for the relentless_insert tool, specifying the expected parameters: database (string), data (object), and optional skipValidation (boolean).
    inputSchema: {
      type: 'object',
      properties: {
        database: {
          type: 'string',
          description:
            'The database name (e.g., "blog", "docs", "leads"). Use relentless_list_databases to see available databases.',
        },
        data: {
          type: 'object',
          description:
            'The data to insert. Keys should match your Notion database property names exactly (e.g., {"Title": "My Post", "Content": "...", "Published": true}). Property names are case-sensitive. Will be validated before insertion.',
          additionalProperties: true,
        },
        skipValidation: {
          type: 'boolean',
          description:
            'Skip pre-insert validation. Use only if you know the data is correct and want to speed up insertion.',
          default: false,
        },
      },
      required: ['database', 'data'],
    },
  • src/index.ts:216-243 (registration)
    Registration of the 'relentless_insert' tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: 'relentless_insert',
      description:
        'Insert a new entry into a Notion database via Relentless API. Data is automatically validated before insertion to catch errors early. Use this to create new documentation, blog posts, leads, or any structured data. The data will be immediately visible in Notion and accessible via the Relentless API.',
      inputSchema: {
        type: 'object',
        properties: {
          database: {
            type: 'string',
            description:
              'The database name (e.g., "blog", "docs", "leads"). Use relentless_list_databases to see available databases.',
          },
          data: {
            type: 'object',
            description:
              'The data to insert. Keys should match your Notion database property names exactly (e.g., {"Title": "My Post", "Content": "...", "Published": true}). Property names are case-sensitive. Will be validated before insertion.',
            additionalProperties: true,
          },
          skipValidation: {
            type: 'boolean',
            description:
              'Skip pre-insert validation. Use only if you know the data is correct and want to speed up insertion.',
            default: false,
          },
        },
        required: ['database', 'data'],
      },
    },
  • Helper function to fetch the database schema from Relentless API, used for pre-insert validation in relentless_insert.
    async function getDatabaseSchema(dbName: string): Promise<DatabaseSchema | null> {
      try {
        const endpoint = `${RELENTLESS_API_BASE}/api/v1/public/db/${dbName}/schema`
        const schema = await relentlessRequest(endpoint, undefined, 1) // No retry for schema
        return schema as DatabaseSchema
      } catch (error) {
        console.error(`⚠️  Could not fetch schema for ${dbName}: ${error}`)
        return null
      }
    }
  • validateWithSchema method from DatabaseValidator class, performs detailed validation of insert data against the database schema before insertion.
    validateWithSchema(
      schema: DatabaseSchema,
      rowData: Record<string, any>
    ): ValidationResult {
      const errors: ValidationError[] = []
      const warnings: string[] = []
    
      try {
        const schemaProperties = schema.properties
    
        // 1. Check for missing required fields
        const requiredFields = this.getRequiredFields(schemaProperties)
        for (const field of requiredFields) {
          if (!(field in rowData) || rowData[field] === null || rowData[field] === undefined) {
            errors.push({
              field,
              error: 'Required field is missing',
              expected: 'non-null value',
              received: 'undefined'
            })
          }
        }
    
        // 2. Validate each provided field
        for (const [key, value] of Object.entries(rowData)) {
          const schemaProp = schemaProperties[key]
    
          // Check if field exists in schema
          if (!schemaProp) {
            warnings.push(`Property "${key}" not found in database schema - will be ignored`)
            continue
          }
    
          // Validate based on property type
          const fieldError = this.validateField(key, value, schemaProp)
          if (fieldError) {
            errors.push(fieldError)
          }
        }
    
        // 3. Check data size limits
        const dataSize = JSON.stringify(rowData).length
        if (dataSize > 1_000_000) {
          errors.push({
            field: '_data',
            error: 'Data payload too large',
            expected: '< 1MB',
            received: `${(dataSize / 1_000_000).toFixed(2)}MB`
          })
        }
    
        // 4. Additional validation rules
        this.validateBusinessRules(rowData, schemaProperties, warnings)
    
        return {
          valid: errors.length === 0,
          errors,
          warnings,
          schema: Object.keys(schemaProperties).reduce((acc, key) => {
            acc[key] = {
              type: schemaProperties[key].type,
              required: requiredFields.includes(key)
            }
            return acc
          }, {} as any)
        }
    
      } catch (error) {
        return {
          valid: false,
          errors: [{
            field: '_system',
            error: `Validation failed: ${error instanceof Error ? error.message : 'Unknown error'}`
          }],
          warnings: []
        }
      }
    }
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: automatic validation before insertion, immediate visibility in Notion, and accessibility via the API. It mentions error catching and speed considerations with skipValidation, though it could elaborate more on permissions or rate limits.

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 efficiently structured with three sentences that each add value: stating the core action, explaining validation and use cases, and describing post-insertion behavior. No wasted words, and information is front-loaded with the primary purpose.

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?

For a mutation tool with no annotations and no output schema, the description does well by covering purpose, behavior, and context. It could be more complete by explicitly mentioning error handling or response format, but it provides sufficient guidance for basic usage given the detailed input schema.

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%, providing detailed parameter documentation. The description adds some value by reinforcing validation and giving examples of database names and data structure, but doesn't significantly expand beyond what's already in the schema descriptions. Baseline 3 is appropriate given 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 action ('Insert a new entry'), target resource ('into a Notion database via Relentless API'), and distinguishes from siblings by specifying creation vs. listing/reading operations. It provides concrete examples of use cases (documentation, blog posts, leads) that help differentiate from tools like relentless_list or relentless_read.

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 explicitly states 'Use this to create new documentation, blog posts, leads, or any structured data,' providing clear context for when to use this tool. However, it doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools, though the distinction from read/list operations is implied.

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/PranaytheSingh/relentless-mcp'

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