Skip to main content
Glama
anythingllm-rag

anythingllm-rag

by smnspz

rag-workflow

A thin MCP server plus an agent workflow that gives every coding session memory: project context is retrieved from an AnythingLLM RAG at task start and written back, human-approved, when a task establishes durable facts.

The server wraps the AnythingLLM Developer REST API with five workflow-shaped tools instead of a generic chat proxy. The kit (workflow/) is the read/write procedure as two agent skills, plus a session-start trigger.

Requirements

  • Node >= 24 (target the latest locally installed nvm version).

  • A running AnythingLLM instance (self-hosted or desktop) with a Developer API key (Settings -> Developer API).

Related MCP server: shelfmark

Tools

Tool

Endpoint

Purpose

rag_find

GET /v1/workspaces

Match a repo (owner/repo) to its workspace by exact display name

rag_search

POST /v1/workspace/{slug}/vector-search

Scored semantic chunks, no LLM generation

rag_create_workspace

POST /v1/workspace/new

Onboard a repo

rag_write

POST /v1/document/raw-text

Embed a curated markdown doc; upserts by title

rag_forget

POST /v1/workspace/{slug}/update-embeddings

Delete the doc under a title

Identity is the workspace name, never the slug: AnythingLLM strips / and rewrites . to -dot- in slugs, so slugs collide. Doc titles are compared extension-stripped because stored titles lose their extension (.md -> .txt). Both rules are proven in docs/resolver-spec.md and docs/context-schema.md.

Install

pnpm install
pnpm build

Register with any MCP client (example for a global MCP config file):

{
  "mcpServers": {
    "anythingllm-rag": {
      "command": "node",
      "args": ["/absolute/path/to/rag-workflow/dist/index.js"],
      "env": {
        "ANYTHINGLLM_BASE_URL": "http://your-anythingllm-host",
        "ANYTHINGLLM_API_KEY": "your-developer-api-key"
      }
    }
  }
}

Keep the API key out of version control.

Workflow kit

workflow/ holds the procedure that turns the five tools into session memory, written for the pi coding agent but portable to any agent with skills plus a prompt-injection hook:

  • skills/find-context/SKILL.md — read path: identify repo (git origin, cache fallback), find workspace, search per concern, adopt or propose onboarding.

  • skills/write-back/SKILL.md — write path: draft curated docs per docs/context-schema.md, get per-doc human approval, upsert.

  • extensions/rag-trigger.ts — injects the context-check instruction on the first prompt of each session in a git repo.

  • AGENTS.md — standing instructions, fallback when no hook is available.

Install by copying the skills and extension into your agent's discovery paths (pi: ~/.agents/skills/, ~/.pi/agent/extensions/).

Verify

Against a live instance, exercising all five tools and the upsert/no-stale rule:

ANYTHINGLLM_BASE_URL=... ANYTHINGLLM_API_KEY=your-key pnpm smoke

License

MIT

Available Tools

5 tools
rag_create_workspaceCreate RAG workspaceA

Create an AnythingLLM workspace named after the repo (e.g. 'owner/repo'). Returns {name, slug}.

Inputs: name (required).

rag_findFind RAG workspace for a repoA

Check whether an AnythingLLM workspace exists for a repo. Matches on exact display name (e.g. 'owner/repo'). Returns {exists, workspace|null, all}.

Inputs: name (required).

rag_forgetDelete a doc from a workspaceA

Remove the embedded doc whose canonical title matches (extension-insensitive). Used when a doc is split or retired so the stale title leaves no retrievable embedding. Returns {forgotten, title|locations}.

Inputs: slug (required), title (required).

rag_writeWrite curated context to a workspaceA

Embed a curated markdown doc into a workspace (raw-text + auto-embed). If overwrite=true (default), removes any existing embedding with the same title first to avoid stale duplicates.

Inputs: slug (required), title (required), content (required), overwrite.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 5 tools

    Disambiguation4/5

    Each tool targets a distinct operation: lookup, creation, semantic search, document injection, and document removal. The only minor overlap is that rag_write can remove stale embeddings via overwrite, but the intent (write vs. forget) is clearly separated in the descriptions.

    Naming Consistency4/5

    All tools share a consistent rag_ prefix and use lowercase snake_case verbs. However, create_workspace includes an object while find, search, write, and forget are bare verbs, so the pattern is not perfectly uniform.

    Tool Count5/5

    Five tools is a well-scoped set for a focused RAG/workspace utility. Each tool covers a distinct part of the workflow without redundancy or bloat.

    Completeness4/5

    The core RAG lifecycle is covered: find/create workspaces, write docs, semantic search, and forget docs. The main gap is the lack of a workspace deletion tool, which prevents full lifecycle cleanup.

    Maintenance

    ActivityStale
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables per-project, traceable access to a RAG knowledge base, with tools for searching and adding knowledge chunks.
      4
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables coding agents to query local notes, decisions, docs, and code with hybrid retrieval (BM25 + embeddings + reranking) and get path:line citations. It provides tools like rag_query for full-corpus search and search_knowledge for project-scoped knowledge recall.
      2
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to maintain a persistent knowledge graph of a project, providing dependency context, impact analysis, side-effect discovery, and session recording for more informed coding decisions.
      5
      MIT