Skip to main content
Glama
index.ts11.3 kB
/** * Records-related tool configurations */ import { AttioRecord } from '../../../types/attio.js'; import { createObjectRecord, getObjectRecord, updateObjectRecord, deleteObjectRecord, listObjectRecords, batchCreateObjectRecords, batchUpdateObjectRecords, } from '../../../objects/records/index.js'; import { BatchConfig, BatchResponse } from '../../../api/operations/index.js'; import { ToolConfig } from '../../tool-types.js'; // Type definitions for record operations interface RecordAttributes { [key: string]: unknown; } interface ListOptions { page?: number; pageSize?: number; query?: string; attributes?: string[]; sort?: string; direction?: 'asc' | 'desc'; } interface BatchUpdateRecord { id: string; attributes: RecordAttributes; } interface BatchOperationResult { summary: { total: number; succeeded: number; failed: number; }; results: BatchResultItem[]; } interface BatchResultItem { success: boolean; id?: string; data?: AttioRecord; error?: { message: string; }; } // Define new tool type interfaces specific to records export interface RecordCreateToolConfig extends ToolConfig { handler: ( objectSlug: string, attributes: RecordAttributes, objectId?: string ) => Promise<AttioRecord>; } export interface RecordGetToolConfig extends ToolConfig { handler: ( objectSlug: string, recordId: string, attributes?: string[], objectId?: string ) => Promise<AttioRecord>; } export interface RecordUpdateToolConfig extends ToolConfig { handler: ( objectSlug: string, recordId: string, attributes: RecordAttributes, objectId?: string ) => Promise<AttioRecord>; } export interface RecordDeleteToolConfig extends ToolConfig { handler: ( objectSlug: string, recordId: string, objectId?: string ) => Promise<boolean>; } export interface RecordListToolConfig extends ToolConfig { handler: ( objectSlug: string, options?: ListOptions, objectId?: string ) => Promise<AttioRecord[]>; } export interface RecordBatchCreateToolConfig extends ToolConfig { handler: <T extends AttioRecord>( objectSlug: string, records: RecordAttributes[], objectId?: string, batchConfig?: Partial<BatchConfig> ) => Promise<BatchResponse<T>>; } export interface RecordBatchUpdateToolConfig extends ToolConfig { handler: ( objectSlug: string, records: BatchUpdateRecord[], objectId?: string ) => Promise<BatchOperationResult>; } // Record tool configurations export const recordToolConfigs = { create: { name: 'create-record', handler: createObjectRecord, formatResult: (result: AttioRecord) => { return `Record created successfully:\n${JSON.stringify(result, null, 2)}`; }, } as RecordCreateToolConfig, get: { name: 'get-record-details', handler: getObjectRecord, formatResult: (result: AttioRecord) => { return `Record details:\n${JSON.stringify(result, null, 2)}`; }, } as RecordGetToolConfig, update: { name: 'update-record', handler: updateObjectRecord, formatResult: (result: AttioRecord) => { return `Record updated successfully:\n${JSON.stringify(result, null, 2)}`; }, } as RecordUpdateToolConfig, delete: { name: 'delete-record', handler: deleteObjectRecord, formatResult: (result: boolean) => { return result ? 'Record deleted successfully' : 'Failed to delete record'; }, } as RecordDeleteToolConfig, list: { name: 'list-records', handler: listObjectRecords, formatResult: (results: AttioRecord[]) => { return `Found ${results.length} records:\n${results .map( (record: AttioRecord) => `- ${record.values?.name || '[Unnamed]'} (ID: ${ record.id?.record_id || 'unknown' })` ) .join('\n')}`; }, } as RecordListToolConfig, batchCreate: { name: 'batch-create-records', handler: batchCreateObjectRecords, formatResult: (result: BatchOperationResult) => { return ( `Batch create operation completed:\n` + `Total: ${result.summary.total}, Succeeded: ${result.summary.succeeded}, Failed: ${result.summary.failed}\n` + `${result.results .map((r: BatchResultItem, i: number) => r.success ? `✅ Record ${i + 1}: Created successfully (ID: ${ r.data?.id?.record_id || 'unknown' })` : `❌ Record ${i + 1}: Failed - ${ r.error?.message || 'Unknown error' }` ) .join('\n')}` ); }, } as RecordBatchCreateToolConfig, batchUpdate: { name: 'batch-update-records', handler: batchUpdateObjectRecords, formatResult: (result: BatchOperationResult) => { return ( `Batch update operation completed:\n` + `Total: ${result.summary.total}, Succeeded: ${result.summary.succeeded}, Failed: ${result.summary.failed}\n` + `${result.results .map((r: BatchResultItem) => r.success ? `✅ Record ${r.id}: Updated successfully` : `❌ Record ${r.id}: Failed - ${ r.error?.message || 'Unknown error' }` ) .join('\n')}` ); }, } as RecordBatchUpdateToolConfig, }; // Record tool definitions export const recordToolDefinitions = [ { name: 'create-record', description: 'Create a new CRM record in Attio (company, person, etc.)', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, attributes: { type: 'object', description: 'Record attributes as key-value pairs', }, }, required: ['objectSlug', 'attributes'], }, }, { name: 'get-record-details', description: 'Get details of a specific CRM record (company, person, etc.)', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, recordId: { type: 'string', description: 'ID of the record to retrieve', }, attributes: { type: 'array', items: { type: 'string', }, description: 'Optional list of attribute slugs to include', }, }, required: ['objectSlug', 'recordId'], }, }, { name: 'update-record', description: 'Update a specific CRM record (company, person, etc.)', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, recordId: { type: 'string', description: 'ID of the record to update', }, attributes: { type: 'object', description: 'Record attributes to update as key-value pairs', }, }, required: ['objectSlug', 'recordId', 'attributes'], }, }, { name: 'delete-record', description: 'Delete a specific record', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, recordId: { type: 'string', description: 'ID of the record to delete', }, }, required: ['objectSlug', 'recordId'], }, }, { name: 'list-records', description: 'List CRM records with filtering options (companies, people, etc.)', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, page: { type: 'number', description: 'Page number to retrieve (starting at 1)', }, pageSize: { type: 'number', description: 'Number of items per page', }, query: { type: 'string', description: 'Search query to filter records', }, attributes: { type: 'array', items: { type: 'string', }, description: 'List of attribute slugs to include', }, sort: { type: 'string', description: 'Attribute slug to sort by', }, direction: { type: 'string', enum: ['asc', 'desc'], description: 'Sort direction (asc or desc)', }, }, required: ['objectSlug'], }, }, { name: 'batch-create-records', description: 'Create multiple CRM records in a single batch operation (bulk import companies, people, etc.)', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, records: { type: 'array', items: { type: 'object', }, description: 'Array of record attributes to create', }, }, required: ['objectSlug', 'records'], }, }, { name: 'batch-update-records', description: 'Update multiple CRM records in a single batch operation (bulk update companies, people, etc.)', inputSchema: { type: 'object', properties: { objectSlug: { type: 'string', description: "The object type slug (e.g., 'companies', 'people')", }, objectId: { type: 'string', description: 'Alternative to objectSlug - direct object ID', }, records: { type: 'array', items: { type: 'object', properties: { id: { type: 'string', description: 'ID of the record to update', }, attributes: { type: 'object', description: 'Record attributes to update', }, }, required: ['id', 'attributes'], }, description: 'Array of records with IDs and attributes to update', }, }, required: ['objectSlug', 'records'], }, }, ];

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/kesslerio/attio-mcp-server'

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