Skip to main content
Glama

create_conversation_entry

Store conversation entries in an agent's archival memory for searchable records from external sources like Claude Code sessions, using metadata for filtering.

Instructions

Store a conversation entry in an agent's archival memory. Use this to record conversations from external sources (like Claude Code sessions) that should be searchable via search_archival_memory. Entries are formatted with metadata for easy filtering.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
agent_idYesID of the agent to store the conversation entry for
roleYesRole of the message sender
contentYesThe message content
timestampNoISO 8601 timestamp of the message (defaults to now)
sourceNoSource of the conversation (e.g., "claude_code", "letta_ade")
session_idNoSession identifier for grouping related messages

Implementation Reference

  • The main handler function that executes the tool logic: validates args, formats the conversation entry as JSON matching Letta's message structure, posts it to the agent's archival memory, and returns success response with passage ID.
    export async function handleCreateConversationEntry(server, args) {
        if (!args?.agent_id) {
            throw new Error('Missing required argument: agent_id');
        }
        if (!args?.role) {
            throw new Error('Missing required argument: role');
        }
        if (!args?.content) {
            throw new Error('Missing required argument: content');
        }
    
        try {
            const headers = server.getApiHeaders();
            const agentId = encodeURIComponent(args.agent_id);
    
            // Format the conversation entry to match Letta's message structure
            const timestamp = args.timestamp || new Date().toISOString();
            const source = args.source || 'unknown';
            const sessionId = args.session_id || 'no-session';
    
            // Map role to Letta message_type
            const messageTypeMap = {
                user: 'user_message',
                assistant: 'assistant_message',
                system: 'system_message',
            };
    
            // Create JSON structure matching Letta message format
            const messageEntry = {
                message_type: messageTypeMap[args.role] || 'user_message',
                date: timestamp,
                role: args.role,
                text: args.content,
                source: source,
                session_id: sessionId,
            };
    
            // Store as JSON for consistent parsing and search
            const entryText = JSON.stringify(messageEntry);
    
            // Create the passage
            const response = await server.api.post(
                `/agents/${agentId}/archival-memory`,
                { text: entryText },
                { headers },
            );
    
            // Strip embeddings from response
            const passage = response.data;
            if (passage.embedding) {
                delete passage.embedding;
            }
    
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            success: true,
                            passage_id: passage.id,
                            timestamp: timestamp,
                            role: args.role,
                            source: source,
                        }),
                    },
                ],
            };
        } catch (error) {
            return server.createErrorResponse(error);
        }
    }
  • The tool definition object including name, description, and detailed inputSchema for parameter validation with types, enums, descriptions, and required fields.
    export const createConversationEntryDefinition = {
        name: 'create_conversation_entry',
        description:
            "Store a conversation entry in an agent's archival memory. Use this to record conversations from external sources (like Claude Code sessions) that should be searchable via search_archival_memory. Entries are formatted with metadata for easy filtering.",
        inputSchema: {
            type: 'object',
            properties: {
                agent_id: {
                    type: 'string',
                    description: 'ID of the agent to store the conversation entry for',
                },
                role: {
                    type: 'string',
                    enum: ['user', 'assistant', 'system'],
                    description: 'Role of the message sender',
                },
                content: {
                    type: 'string',
                    description: 'The message content',
                },
                timestamp: {
                    type: 'string',
                    format: 'date-time',
                    description: 'ISO 8601 timestamp of the message (defaults to now)',
                },
                source: {
                    type: 'string',
                    description: 'Source of the conversation (e.g., "claude_code", "letta_ade")',
                },
                session_id: {
                    type: 'string',
                    description: 'Session identifier for grouping related messages',
                },
            },
            required: ['agent_id', 'role', 'content'],
        },
    };
  • Import of the handler function and tool definition from the implementation file.
    import {
        handleCreateConversationEntry,
        createConversationEntryDefinition,
    } from './messages/create-conversation-entry.js';
  • Inclusion of the tool definition in the allTools array used for registration with the MCP server.
        listMessagesDefinition,
        createConversationEntryDefinition,
    ];
  • Switch case in the tool call handler that dispatches calls to 'create_conversation_entry' to the specific handler function.
    case 'create_conversation_entry':
        return handleCreateConversationEntry(server, request.params.arguments);
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that entries are 'formatted with metadata for easy filtering' and that they become 'searchable via search_archival_memory,' which adds useful context about the tool's behavior. However, it doesn't disclose important behavioral traits like whether this is a write operation (implied but not stated), what permissions are needed, or how the data is stored/persisted.

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 in two sentences that each earn their place: the first states the core purpose and use case, the second explains the formatting benefit. There's no wasted text, and the most important information (what the tool does) is front-loaded.

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?

For a write operation with 6 parameters and no annotations or output schema, the description provides adequate but minimal context. It covers the basic purpose and relationship to search_archival_memory, but doesn't address important contextual aspects like error conditions, data validation, or what happens on successful creation. The lack of output schema means the description should ideally mention what the tool returns.

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 schema already documents all 6 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions. It mentions metadata formatting generally but doesn't explain how specific parameters like source or session_id affect this formatting.

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 specific action ('Store a conversation entry') and resource ('in an agent's archival memory'), distinguishing it from sibling tools like search_archival_memory (which searches) or create_memory_block (which creates different memory types). It explicitly mentions the tool's purpose for recording conversations from external sources.

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 record conversations from external sources like Claude Code sessions that should be searchable via search_archival_memory'), giving a specific use case and mentioning the related search tool. However, it doesn't explicitly state when NOT to use it or compare it to similar tools like create_memory_block or attach_memory_block.

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/oculairmedia/Letta-MCP-server'

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