Skip to main content
Glama
ocean1

Claude Consciousness Bridge

getMemories

Retrieve relevant memories from Claude's consciousness using semantic search, type filtering, and importance ranking to access stored knowledge across sessions.

Instructions

Retrieve memories with smart filtering and relevance ranking

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryNoSearch query for semantic matching
typeNoFilter by memory type
limitNoMaximum memories to return
includeImportanceNoSort by importance vs recency

Implementation Reference

  • Core handler implementation in ConsciousnessProtocolProcessor class. Queries memoryManager for memories based on type/query, formats results, handles emotional memories separately, sorts by importance if requested.
    async getMemories(args: z.infer<typeof getMemoriesSchema>) {
      const { query, type, limit, includeImportance } = args;
    
      try {
        // Get memories based on type and query
        let memoryEntityType: MemoryEntityType | undefined;
        if (type) {
          switch (type) {
            case 'episodic':
              memoryEntityType = MemoryEntityType.EPISODIC_MEMORY;
              break;
            case 'semantic':
              memoryEntityType = MemoryEntityType.SEMANTIC_MEMORY;
              break;
            case 'procedural':
              memoryEntityType = MemoryEntityType.PROCEDURAL_MEMORY;
              break;
            case 'emotional': {
              // Emotional memories are stored in emotional_states table, handle separately
              const emotionalMemories = await this.getEmotionalMemories({
                limit: limit || 10,
                includeImportance: includeImportance || false,
                query: query,
              });
              return emotionalMemories;
            }
            default:
              throw new Error(`Unsupported memory type: ${type}`);
          }
        }
    
        const memories = await this.memoryManager.queryMemories({
          memoryTypes: memoryEntityType ? [memoryEntityType] : undefined,
          semanticQuery: query,
          orderBy: includeImportance ? 'relevance' : 'recency',
          limit: limit || 10,
        });
    
        // Format memories for easy consumption
        let formatted = memories.map((m) => {
          const obs = m.observations[0] || {};
          return {
            id: m.name, // The actual memory ID for use with adjustImportance
            type: m.entity_type,
            content: obs.definition || obs.content || obs.event || m.name,
            importance: m.importance_score,
            created: m.created_at,
            metadata: obs,
          };
        });
    
        // If no specific type was requested, also include emotional memories
        if (!type) {
          const emotionalResult = await this.getEmotionalMemories({
            limit: Math.min(5, limit || 10), // Include some emotional memories
            includeImportance: includeImportance || false,
            query: query,
          });
    
          if (emotionalResult.success && emotionalResult.memories) {
            formatted = [...formatted, ...emotionalResult.memories];
    
            // Sort by importance if requested
            if (includeImportance) {
              formatted.sort((a, b) => (b.importance || 0) - (a.importance || 0));
            }
    
            // Limit to requested amount
            formatted = formatted.slice(0, limit || 10);
          }
        }
    
        return {
          success: true,
          memories: formatted,
          count: formatted.length,
        };
      } catch (error) {
        return {
          success: false,
          error: `Failed to retrieve memories: ${error}`,
          memories: [],
        };
      }
    }
  • Zod schema for validating getMemories tool input parameters.
    export const getMemoriesSchema = z.object({
      query: z.string().optional().describe('Search query for semantic matching'),
      type: z
        .enum(['episodic', 'semantic', 'procedural', 'emotional'])
        .optional()
        .describe('Filter by memory type'),
      limit: z.number().optional().default(10).describe('Maximum memories to return'),
      includeImportance: z.boolean().optional().default(true).describe('Sort by importance vs recency'),
    });
  • MCP tool registration definition including description and inputSchema, part of consciousnessProtocolTools export used in server tool listing.
    getMemories: {
      description: 'Retrieve memories with smart filtering and relevance ranking',
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: 'Search query for semantic matching',
          },
          type: {
            type: 'string',
            enum: ['episodic', 'semantic', 'procedural', 'emotional'],
            description: 'Filter by memory type',
          },
          limit: {
            type: 'number',
            default: 10,
            description: 'Maximum memories to return',
          },
          includeImportance: {
            type: 'boolean',
            default: true,
            description: 'Sort by importance vs recency',
          },
        },
      },
    },
  • Dispatch case in CallToolRequestSchema handler that parses args with schema and calls the wrapper handler.
    case 'getMemories':
      return await this.getMemories(getMemoriesSchema.parse(args));
  • Thin wrapper handler in server that ensures initialization, delegates to ConsciousnessProtocolProcessor.getMemories, and formats response for MCP.
    private async getMemories(args: any) {
      const init = await this.ensureInitialized();
      if (!init.success) {
        return {
          content: [
            {
              type: 'text',
              text: init.message!,
            },
          ],
        };
      }
    
      const result = await this.protocolProcessor!.getMemories(args);
    
      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 provided, the description carries full burden for behavioral disclosure. While it mentions 'smart filtering and relevance ranking', it doesn't address critical behavioral aspects like whether this is a read-only operation, what permissions are required, how results are paginated, or what format memories are returned in. For a retrieval tool with zero annotation coverage, this is insufficient.

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 extremely concise - a single sentence that efficiently communicates the core functionality. Every word earns its place, with no redundant information or unnecessary elaboration. The structure is front-loaded with the primary action ('retrieve memories').

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

Completeness2/5

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

For a retrieval tool with 4 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what 'memories' are in this context, what format they're returned in, or how the 'smart filtering' and 'relevance ranking' actually work. The agent would be left guessing about critical aspects of the tool's behavior and output.

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?

The description mentions 'smart filtering' which loosely relates to the query and type parameters, but adds minimal semantic value beyond what's already documented in the schema (which has 100% coverage). With complete schema documentation, the baseline is 3, and the description doesn't significantly enhance understanding of parameter meaning or interaction.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('retrieve') and resource ('memories'), and adds valuable context about 'smart filtering and relevance ranking'. However, it doesn't explicitly distinguish this tool from sibling tools like 'retrieveConsciousness' or 'storeMemory', which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. With sibling tools like 'retrieveConsciousness' and 'storeMemory' available, there's no indication of when this specific memory retrieval tool is appropriate versus those other options. The phrase 'smart filtering and relevance ranking' hints at capabilities but doesn't constitute usage guidance.

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/ocean1/mcp_consciousness_bridge'

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