Skip to main content
Glama

ad4m_delete_memory

Remove links from a Perspective by filtering source, predicate, or target URIs. Returns matched, removed, and failed counts.

Instructions

Remove links from a Perspective by source, predicate, and/or target filter. Returns matched/removed/failed counts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
perspective_uuidYesPerspective UUID to delete from
sourceNoFilter by source URI
predicateNoFilter by predicate URI
targetNoFilter by target URI

Implementation Reference

  • The deleteMemory handler function: queries links matching the filter, then removes each via removeLink(), returning matched/removed/failed counts.
      async ({ perspective_uuid, source, predicate, target }) => {
        const query: Record<string, string> = {};
        if (source)    query.source    = source;
        if (predicate) query.predicate = predicate;
        if (target)    query.target    = target;
        const data = await gql(
          `query Q($uuid: String!, $q: LinkQuery!) {
             perspectiveQueryLinks(uuid: $uuid, query: $q) { ${LINKS_WITH_PROOF} }
           }`,
          { uuid: perspective_uuid, q: query }
        );
        const links = data.perspectiveQueryLinks as LinkExpr[];
        let removed = 0, failed = 0;
        for (const link of links) {
          try { if (await removeLink(perspective_uuid, link)) removed++; else failed++; }
          catch { failed++; }
        }
        return ok({ matched: links.length, removed, failed });
      }
    );
  • src/index.ts:429-457 (registration)
    Tool registration via server.tool('ad4m_delete_memory', ...) with Zod schema for perspective_uuid (required), source/predicate/target (optional).
    // 11. ad4m_delete_memory
    server.tool("ad4m_delete_memory",
      "Remove links from a Perspective by source, predicate, and/or target filter. Returns matched/removed/failed counts.",
      {
        perspective_uuid: z.string().describe("Perspective UUID to delete from"),
        source:           z.string().optional().describe("Filter by source URI"),
        predicate:        z.string().optional().describe("Filter by predicate URI"),
        target:           z.string().optional().describe("Filter by target URI"),
      },
      async ({ perspective_uuid, source, predicate, target }) => {
        const query: Record<string, string> = {};
        if (source)    query.source    = source;
        if (predicate) query.predicate = predicate;
        if (target)    query.target    = target;
        const data = await gql(
          `query Q($uuid: String!, $q: LinkQuery!) {
             perspectiveQueryLinks(uuid: $uuid, query: $q) { ${LINKS_WITH_PROOF} }
           }`,
          { uuid: perspective_uuid, q: query }
        );
        const links = data.perspectiveQueryLinks as LinkExpr[];
        let removed = 0, failed = 0;
        for (const link of links) {
          try { if (await removeLink(perspective_uuid, link)) removed++; else failed++; }
          catch { failed++; }
        }
        return ok({ matched: links.length, removed, failed });
      }
    );
  • Input schema using Zod: perspective_uuid (string, required), source, predicate, target (all optional strings).
    {
      perspective_uuid: z.string().describe("Perspective UUID to delete from"),
      source:           z.string().optional().describe("Filter by source URI"),
      predicate:        z.string().optional().describe("Filter by predicate URI"),
      target:           z.string().optional().describe("Filter by target URI"),
    },
  • removeLink helper: sends a GraphQL perspectiveRemoveLink mutation to delete a specific link by author/timestamp/proof/data.
    async function removeLink(uuid: string, link: LinkExpr): Promise<boolean> {
      const result = await gql(
        `mutation R($uuid: String!, $link: LinkExpressionInput!) {
           perspectiveRemoveLink(uuid: $uuid, link: $link)
         }`,
        { uuid, link: { author: link.author, timestamp: link.timestamp, proof: link.proof, data: link.data } }
      );
      return !!(result.perspectiveRemoveLink);
    }
  • LINKS_WITH_PROOF GraphQL fragment used to retrieve link expressions with proof fields.
    const LINKS_WITH_PROOF = `
      author timestamp
      proof { key signature valid invalid }
      data { source predicate target }
    `;
Behavior3/5

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

No annotations provided. Description mentions destructive nature ('remove') and return of counts, but lacks details on irreversibility, required permissions, or side effects.

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?

Single sentence conveys purpose, filtering capability, and output. No unnecessary words.

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?

No output schema, so description should clarify return format. It mentions counts but not structure or error handling. Adequate but could be more complete.

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 coverage is 100% with each parameter described. The description adds filter semantics but does not provide new meaning beyond schema.

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?

Clearly states it removes links from a Perspective using filters (source, predicate, target). This distinguishes it from siblings like ad4m_write_memory (adds) and ad4m_recall (retrieves).

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?

Implies use when needing to delete specific links by filter. No explicit when-not or alternatives, but context of sibling tools makes it clear this is the delete operation.

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/thefranceway/mcp-ad4m'

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