Skip to main content
Glama
lithtrix

lithtrix-mcp

Official

lithtrix_memory_search

Search memories by natural-language query with optional importance and similarity filters. Returns ranked results with similarity scores.

Instructions

Semantic search over your memories (GET /v1/memory/search). Requires LITHTRIX_API_KEY and server-side vector + embedding configuration. Returns ranked results with similarity scores.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qYesNatural-language search query
limitNoMax results (1–20, default 5)
importanceNoOptional importance tier (default normal on API if omitted)
thresholdNoMinimum similarity 0–1 (default 0.7 on API)

Implementation Reference

  • Registration of the lithtrix_memory_search tool via server.tool() in the registerMemoryTools function.
    server.tool(
      "lithtrix_memory_search",
      "Semantic search over your memories (GET /v1/memory/search). " +
        "Requires LITHTRIX_API_KEY and server-side vector + embedding configuration. " +
        "Returns ranked results with similarity scores.",
      {
        q: z
          .string()
          .min(1)
          .max(500)
          .describe("Natural-language search query"),
        limit: z
          .number()
          .int()
          .min(1)
          .max(20)
          .optional()
          .describe("Max results (1–20, default 5)"),
        importance: importanceSchema,
        threshold: z
          .number()
          .min(0)
          .max(1)
          .optional()
          .describe("Minimum similarity 0–1 (default 0.7 on API)"),
      },
      async ({ q, limit, importance, threshold }) => {
        const apiKey = process.env.LITHTRIX_API_KEY;
        if (!apiKey) return missingApiKeyResponse();
    
        const url = new URL("/v1/memory/search", LITHTRIX_API_URL);
        url.searchParams.set("q", q);
        if (limit !== undefined) url.searchParams.set("limit", String(limit));
        if (importance !== undefined) url.searchParams.set("importance", importance);
        if (threshold !== undefined)
          url.searchParams.set("threshold", String(threshold));
    
        let response;
        try {
          response = await fetch(url.toString(), {
            headers: {
              Authorization: `Bearer ${apiKey}`,
              "Content-Type": "application/json",
            },
          });
        } catch (err) {
          return networkErrorResponse(err);
        }
        return apiJsonResponse(response);
      }
    );
  • Handler function that executes the semantic memory search: builds a GET /v1/memory/search URL with query params (q, limit, importance, threshold), calls the Lithtrix API, and returns the response.
    async ({ q, limit, importance, threshold }) => {
      const apiKey = process.env.LITHTRIX_API_KEY;
      if (!apiKey) return missingApiKeyResponse();
    
      const url = new URL("/v1/memory/search", LITHTRIX_API_URL);
      url.searchParams.set("q", q);
      if (limit !== undefined) url.searchParams.set("limit", String(limit));
      if (importance !== undefined) url.searchParams.set("importance", importance);
      if (threshold !== undefined)
        url.searchParams.set("threshold", String(threshold));
    
      let response;
      try {
        response = await fetch(url.toString(), {
          headers: {
            Authorization: `Bearer ${apiKey}`,
            "Content-Type": "application/json",
          },
        });
      } catch (err) {
        return networkErrorResponse(err);
      }
      return apiJsonResponse(response);
    }
  • Input schema for the tool using Zod: 'q' (required string 1-500 chars), 'limit' (optional int 1-20), 'importance' (optional enum from importanceSchema), and 'threshold' (optional number 0-1).
    {
      q: z
        .string()
        .min(1)
        .max(500)
        .describe("Natural-language search query"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(20)
        .optional()
        .describe("Max results (1–20, default 5)"),
      importance: importanceSchema,
      threshold: z
        .number()
        .min(0)
        .max(1)
        .optional()
        .describe("Minimum similarity 0–1 (default 0.7 on API)"),
    },
  • Shared Zod schema for the 'importance' parameter, reused by lithtrix_memory_search and other memory tools.
      .describe(
        "Memory key (1–128 chars: letters, digits, hyphen, underscore, dot, colon)"
      );
    
    const importanceSchema = z
  • Helper function that returns an error response when the API key is missing, used by the handler.
    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) }],
      };
    }
Behavior3/5

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

With no annotations, the description mentions it returns ranked results with similarity scores and requires configuration, but lacks details on read-only nature, rate limits, or error cases.

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 efficiently convey purpose, HTTP method, prerequisites, and return type, with no unnecessary words.

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

Completeness4/5

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

Given the absence of output schema and annotations, the description covers the core function and prerequisites, though it could detail the return structure more.

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 the schema already explains each parameter. The description adds no new parameter-specific information beyond the 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 'Semantic search over your memories' with the HTTP method, distinguishing it from other memory tools like lithtrix_memory_get and lithtrix_memory_set.

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?

It specifies prerequisites (API key and server-side configuration) but does not explicitly mention when to use this tool versus alternatives like lithtrix_search for broader search or lithtrix_memory_get for exact retrieval.

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