anythingllm-mcp
# anythingllm-mcp
Standalone, MIT-licensed Model Context Protocol (MCP) server that exposes an [AnythingLLM](https://github.com/Mintplex-Labs/anything-llm) instance as an MCP server for coding assistants such as Claude Code, Claude Desktop, and Cursor (`Mintplex-Labs/anything-llm#5048`).
Every tool maps directly to AnythingLLM's verified `/api/v1/` developer endpoints (`Authorization: Bearer <api_key>`) and adds fail-closed workspace ACL scoping (`ANYTHINGLLM_ALLOWED_WORKSPACES`), slug path-traversal guards, and strict Bearer token redaction.
## Tools
| Tool | AnythingLLM Endpoint | Annotations | Purpose |
| --- | --- | --- | --- |
| `list_workspaces` | `GET /api/v1/workspaces` | `readOnly`, `idempotent` | List workspaces (filtered to `ANYTHINGLLM_ALLOWED_WORKSPACES` when configured) |
| `get_workspace` | `GET /api/v1/workspace/:slug` | `readOnly`, `idempotent` | Inspect workspace configuration, embedded documents, and threads |
| `chat_workspace` | `POST /api/v1/workspace/:slug/chat` | `non-readOnly`, `non-idempotent` | Query or chat with a workspace (`mode`: `query`, `chat`, or `automatic`, optional `sessionId` and `reset`) |
| `vector_search_workspace` | `POST /api/v1/workspace/:slug/vector-search` | `readOnly`, `idempotent` | Raw vector similarity search returning chunks, metadata, distance, and score without LLM generation |
| `list_documents` | `GET /api/v1/documents` | `readOnly`, `idempotent` | List locally stored documents (supports optional `?folder=`, `offset`, and `limit`) |
## Quickstart
### 1. Create an AnythingLLM Developer API Key
In your AnythingLLM instance, go to **Settings -> Tools -> Developer API** and generate an API key.
### 2. Build locally
```bash
git clone https://github.com/khoap1220-hue/anythingllm-mcp.git
cd anythingllm-mcp
npm ci
npm run build
```
### 3. Configure Claude Desktop / Cursor / Claude Code
```json
{
"mcpServers": {
"anythingllm": {
"command": "node",
"args": ["/absolute/path/to/anythingllm-mcp/dist/cli.js"],
"env": {
"ANYTHINGLLM_BASE_URL": "http://localhost:3001",
"ANYTHINGLLM_API_KEY": "your-developer-api-key",
"ANYTHINGLLM_ALLOWED_WORKSPACES": "architecture,runbooks"
}
}
}
}
```
Or run with Docker (non-root `node` user):
```bash
docker build -t anythingllm-mcp .
docker run --rm -i \
-e ANYTHINGLLM_BASE_URL="http://host.docker.internal:3001" \
-e ANYTHINGLLM_API_KEY="your-developer-api-key" \
-e ANYTHINGLLM_ALLOWED_WORKSPACES="architecture,runbooks" \
anythingllm-mcp
```
## Configuration
| Environment Variable | Required | Default | Description |
| --- | --- | --- | --- |
| `ANYTHINGLLM_API_KEY` | Yes | — | Developer API key sent via `Authorization: Bearer <key>` |
| `ANYTHINGLLM_BASE_URL` | No | `http://localhost:3001` | Base URL of AnythingLLM (`http://` or `https://`, credentials in URL rejected) |
| `ANYTHINGLLM_ALLOWED_WORKSPACES` | No | *(unrestricted)* | Comma-separated allowlist of workspace slugs. Enforced **before** any outbound HTTP call and filters `list_workspaces`. Setting it to `""` fails closed (blocks all workspaces). |
| `ANYTHINGLLM_TIMEOUT_MS` | No | `30000` | Outbound HTTP request timeout in ms (`1000`–`300000`) |
## Security Hardening
- **Fail-Closed Workspace ACL (`ANYTHINGLLM_ALLOWED_WORKSPACES`)**: Inspired by multi-tenant workspace scoping (`#7164`), unauthorized workspace slugs are rejected locally before any network request is made and omitted from `list_workspaces` output.
- **SSRF & Path-Traversal Guards**: `ANYTHINGLLM_BASE_URL` only permits `http:` / `https:` with no embedded credentials, query strings, or `..` segments. Workspace slugs and document folder names are validated against strict character sets before `encodeURIComponent`.
- **Bearer Token Redaction**: Raw API keys, URL-encoded keys, `Bearer ...` strings, and `Authorization:` headers are stripped from all tool errors and stderr diagnostics.
## Development
```bash
npm ci
npm run lint
npm run typecheck
npm run build
npm test
```
## License
MIT © 2026 Khoa Phan
---
## Enterprise Support & Custom MCP Integrations
Need a native Streamable HTTP `/mcp` endpoint, OAuth 2.1 authorization (`#6396`), or multi-tenant workspace RBAC embedded directly in your AnythingLLM deployment?
- **Async Engineering & MCP Integration Services:** [khoaphan.dev/services](https://khoaphan.dev/services/?ref=anythingllm-mcp)
- **Deliverables:** Written technical spec, deterministic test suite, clean GitHub PR, and CI verification.
- **Engagement Style:** 100% async written handoff with transparent fixed-scope milestones.
- **Registry Ready:** Includes `server.json` (`2025-12-11` schema) and non-root container build.
TDQS
Scored across 5 tools
list_workspaces/get_workspace/list_documents are clearly distinct by resource and verb. chat_workspace and vector_search_workspace both target workspace content and could be momentarily confused, but the descriptions explicitly separate LLM-generated RAG chat from raw vector retrieval without generation.
All names are snake_case with a verb-first pattern (list_workspaces, get_workspace, chat_workspace, list_documents). vector_search_workspace deviates slightly by embedding a noun phrase (vector_search) rather than a single verb, but it remains readable and predictable.
Five tools is a tight, focused set covering the core workspace/chat/document interactions without redundancy. It sits at the thin end of the range but each tool earns its place for a RAG querying server.
The surface is read/query-heavy: agents can list, inspect, chat, and vector-search, but there is no way to create/update/delete workspaces, upload or remove documents, or manage threads despite get_workspace exposing thread data. These are notable gaps for a full lifecycle, though the core querying workflow is covered.