Skip to main content
Glama
lithtrix

lithtrix-mcp

Official

lithtrix_memory_set

Store or update a JSON value for a memory key with optional TTL, importance, source, and confidence score. Persists AI agent memory across sessions and changes.

Instructions

Store or update a JSON value for a memory key (PUT /v1/memory/{key}). Requires LITHTRIX_API_KEY. Optional ttl (seconds), importance, source, confidence.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keyYesMemory key (1–128 chars: letters, digits, hyphen, underscore, dot, colon)
valueNoJSON-serializable value (object, array, string, number, boolean, etc.)
ttlNoOptional positive TTL in seconds
importanceNoOptional importance tier (default normal on API if omitted)
sourceNoOptional provenance label (e.g. tool name)
confidenceNoOptional confidence 0–1 (default 1.0 on API)

Implementation Reference

  • The async handler function for lithtrix_memory_set. Validates API key, builds the payload (value, ttl, importance, source, confidence), sends PUT /v1/memory/{key} to the Lithtrix API, and returns the JSON response.
      async ({ key, value, ttl, importance, source, confidence }) => {
        const apiKey = process.env.LITHTRIX_API_KEY;
        if (!apiKey) return missingApiKeyResponse();
    
        const payload = { value };
        if (ttl !== undefined) payload.ttl = ttl;
        if (importance !== undefined) payload.importance = importance;
        if (source !== undefined) payload.source = source;
        if (confidence !== undefined) payload.confidence = confidence;
    
        const path = `/v1/memory/${encodeURIComponent(key)}`;
        let response;
        try {
          response = await fetch(new URL(path, LITHTRIX_API_URL), {
            method: "PUT",
            headers: {
              Authorization: `Bearer ${apiKey}`,
              "Content-Type": "application/json",
            },
            body: JSON.stringify(payload),
          });
        } catch (err) {
          return networkErrorResponse(err);
        }
        return apiJsonResponse(response);
      }
    );
  • Zod schema definition for lithtrix_memory_set inputs: key (validated string), value (any JSON-serializable), optional ttl (positive int), importance (enum), source (string max 255), confidence (float 0-1).
    {
      key: memoryKeySchema,
      value: z
        .any()
        .describe(
          "JSON-serializable value (object, array, string, number, boolean, etc.)"
        ),
      ttl: z
        .number()
        .int()
        .positive()
        .optional()
        .describe("Optional positive TTL in seconds"),
      importance: importanceSchema,
      source: z
        .string()
        .max(255)
        .optional()
        .describe("Optional provenance label (e.g. tool name)"),
      confidence: z
        .number()
        .min(0)
        .max(1)
        .optional()
        .describe("Optional confidence 0–1 (default 1.0 on API)"),
    },
  • tools/memory.js:83-140 (registration)
    Registration of lithtrix_memory_set via server.tool() inside the registerMemoryTools function, with tool name, description, schema, and handler.
    export function registerMemoryTools(server) {
      server.tool(
        "lithtrix_memory_set",
        "Store or update a JSON value for a memory key (PUT /v1/memory/{key}). " +
          "Requires LITHTRIX_API_KEY. Optional ttl (seconds), importance, source, confidence.",
        {
          key: memoryKeySchema,
          value: z
            .any()
            .describe(
              "JSON-serializable value (object, array, string, number, boolean, etc.)"
            ),
          ttl: z
            .number()
            .int()
            .positive()
            .optional()
            .describe("Optional positive TTL in seconds"),
          importance: importanceSchema,
          source: z
            .string()
            .max(255)
            .optional()
            .describe("Optional provenance label (e.g. tool name)"),
          confidence: z
            .number()
            .min(0)
            .max(1)
            .optional()
            .describe("Optional confidence 0–1 (default 1.0 on API)"),
        },
        async ({ key, value, ttl, importance, source, confidence }) => {
          const apiKey = process.env.LITHTRIX_API_KEY;
          if (!apiKey) return missingApiKeyResponse();
    
          const payload = { value };
          if (ttl !== undefined) payload.ttl = ttl;
          if (importance !== undefined) payload.importance = importance;
          if (source !== undefined) payload.source = source;
          if (confidence !== undefined) payload.confidence = confidence;
    
          const path = `/v1/memory/${encodeURIComponent(key)}`;
          let response;
          try {
            response = await fetch(new URL(path, LITHTRIX_API_URL), {
              method: "PUT",
              headers: {
                Authorization: `Bearer ${apiKey}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify(payload),
            });
          } catch (err) {
            return networkErrorResponse(err);
          }
          return apiJsonResponse(response);
        }
      );
  • Helper functions used by the handler: missingApiKeyResponse, networkErrorResponse, and apiJsonResponse for constructing MCP content responses.
    function missingApiKeyResponse() {
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              error:
                "LITHTRIX_API_KEY environment variable is not set. " +
                "Register at https://lithtrix.ai and use lithtrix_register, then set the key.",
            }),
          },
        ],
        isError: true,
      };
    }
    
    function networkErrorResponse(err) {
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify({
              error: `Network error contacting Lithtrix API: ${err.message}`,
            }),
          },
        ],
        isError: true,
      };
    }
    
    async function apiJsonResponse(response) {
      let body;
      try {
        body = await response.json();
      } catch {
        body = { message: `Invalid JSON (HTTP ${response.status})` };
      }
    
      if (!response.ok) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                error: body.message ?? `Lithtrix API error (HTTP ${response.status})`,
                error_code: body.error_code ?? "UNKNOWN",
                status: body.status,
              }),
            },
          ],
          isError: true,
        };
      }
    
      return {
        content: [{ type: "text", text: JSON.stringify(body, null, 2) }],
      };
    }
  • index.js:33-52 (registration)
    Import and invocation that registers all memory tools (including lithtrix_memory_set) on the MCP server instance.
    import { registerMemoryTools } from "./tools/memory.js";
    import { registerBlobTools } from "./tools/blobs.js";
    import { registerParseTools } from "./tools/parse.js";
    import { registerFeedbackTool } from "./tools/feedback.js";
    import { registerBrowseTool } from "./tools/browse.js";
    import { registerCommonsTool } from "./tools/commons.js";
    
    const server = new McpServer({
      name: "lithtrix",
      version: "0.9.0",
    });
    
    registerSearchTool(server);
    registerRegisterTool(server);
    registerMemoryTools(server);
    registerBlobTools(server);
    registerParseTools(server);
    registerFeedbackTool(server);
    registerBrowseTool(server);
    registerCommonsTool(server);
Behavior4/5

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

With no annotations, the description carries full burden. It discloses the API key requirement, HTTP method (PUT), and optional parameters. It implies upsert semantics ('store or update'). However, it does not state idempotency or response details, which are acceptable for a simple set operation.

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?

Two sentences, front-loaded with action and resource. No unnecessary words. Efficient and direct.

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?

The description lacks mention of return values or expected response (no output schema). While the tool is simple, the agent is left uninformed about what happens after setting. Adequate but with a clear gap.

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%, so baseline is 3. The description lists optional parameters (ttl, importance, source, confidence) but adds no additional meaning beyond the schema's already good descriptions. No value is added over the input 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?

The description clearly states the verb ('store or update') and resource ('memory key'), with HTTP method and endpoint. This differentiates it from sibling read/search tools like lithtrix_memory_get and lithtrix_memory_search.

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 (store/update memory) and states a prerequisite (API key). However, it does not explicitly exclude alternatives or mention when not to use, though the sibling tools imply read/search roles.

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/lithtrix/lithtrix-mcp'

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