Skip to main content
Glama

add_observations

Add text observations to existing entities and index them for full-text and semantic search within the Memento memory server.

Instructions

Add text observations to existing entities and index them for full-text and semantic search.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
observationsYesList of {entityName, contents} pairs.

Implementation Reference

  • Core handler function that adds observations to entities: resolves entity IDs, inserts new observations, generates embeddings using embedTexts, and stores observation vectors in the repository.
    async addObservations(list) {
        const results = [];
        for (const { entityName, contents } of list) {
            const entityId = await this.#repository.getOrCreateEntityId(entityName, 'Unknown');
            const inserted = [];
            for (const content of contents) {
                const { inserted: wasInserted, observationId } = await this.#repository.insertObservation(entityId, content);
                if (wasInserted && observationId !== null && observationId !== undefined) {
                    inserted.push({ observationId, content });
                }
            }
            if (inserted.length) {
                const embeddings = await this.embedTexts(inserted.map(row => row.content));
                const vectorRows = inserted.map((row, index) => ({
                    observationId: row.observationId,
                    entityId,
                    embedding: embeddings[index]
                }));
                await this.#repository.insertObservationVectors(vectorRows);
            }
            results.push({ entityName, addedObservations: inserted.map(item => item.content) });
        }
        return results;
    }
  • src/server.js:91-110 (registration)
    Registers the 'add_observations' MCP tool, defines input schema using Zod, and provides a thin handler that delegates to KnowledgeGraphManager.addObservations and returns JSON-formatted results.
    this.tool(
        'add_observations',
        'Add text observations to existing entities and index them for full-text and semantic search.',
        {
            observations: z.array(z.object({
                entityName: z.string().describe('Name of the entity to annotate.'),
                contents:   z.array(z.string()).describe('List of text observations to add.')
            })).describe('List of {entityName, contents} pairs.')
        },
        async ({ observations }) => ({
            content: [{
                type: 'text',
                text: JSON.stringify(
                    await this.#knowledgeGraphManager.addObservations(observations),
                    null,
                    2
                )
            }]
        })
    );
  • Zod schema defining the input parameters for the add_observations tool: an array of objects with entityName (string) and contents (array of strings).
        observations: z.array(z.object({
            entityName: z.string().describe('Name of the entity to annotate.'),
            contents:   z.array(z.string()).describe('List of text observations to add.')
        })).describe('List of {entityName, contents} pairs.')
    },

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/iAchilles/memento'

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