Skip to content

Notes & Docs MCP Server

Overview

MCP server (buddai-notes-and-docs) that stores free-form notes in MongoDB and enables semantic lookup using local embeddings. The container is launched via notes-and-docs.mcp.yml over STDIO.

Components

  • index.js – registers two tools (addNoteToDB, searchNotesByPrompt).
  • mongo.js – handles Mongo access, persists notes, builds vector indexes, and runs semantic queries.
  • embeddings.js / models/ – loads nomic-embed-text-v1.5 (ONNX) via @xenova/transformers, normalises embeddings, and caches the extractor.
  • Dockerfile – Node 22 image bundling production dependencies and local model artefacts.

Exposed MCP tools

ToolPurposeInput
addNoteToDBStores a note with a generated embedding.title, content.
searchNotesByPromptSemantic search over saved notes, returning the top five matches.prompt.

All responses are JSON-encoded in the MCP tool output (type: "text"). Notes live in the notes collection with fields { title, content, embedding: float[768], timestamp }.

Configuration

notes-and-docs.mcp.yml launches the container:

yaml
notes-and-docs:
  transport: stdio
  command: docker
  args:
    - run
    - --init
    - -i
    - --rm
    - --network
    - buddai_net
    - -e
    - MONGO_URI
    - buddai/mcp-notes-and-docs
  env:
    MONGO_URI: "${MONGO_URI}"

Environment variables consumed:

  • MONGO_URI – MongoDB connection string (must support Atlas Search / $vectorSearch).
  • DEBUG – optional (mcp_notes-and-docs:*).

Ensure the models/ directory contains the ONNX model and ORT runtime referenced by embeddings.js. Run the associated download script if needed.

Running locally

  1. Install Node.js ≥ 20 and run npm install.
  2. Export MONGO_URI and optional DEBUG.
  3. Verify models/ contains nomic-embed-text-v1.5 files (download_model.sh if missing).
  4. Launch the server with node index.js to expose the STDIO MCP interface.

Docker usage

bash
docker build -t buddai/mcp-notes-and-docs mcp_servers/notes

Run as the host expects:

bash
docker network create buddai_net                  # once
MONGO_URI=mongodb://mongo:27017/buddai \
docker run --rm --init -i \
  --network buddai_net \
  -e MONGO_URI \
  -e DEBUG=mcp_notes-and-docs:* \
  buddai/mcp-notes-and-docs

Development notes

  • saveNote closes the Mongo connection after every write/read to avoid long-lived connections; batching may require refactoring.
  • Vector search uses the vectorSearchOnEmbedding Atlas Search index; the code auto-creates it if absent, but this requires Atlas Search permissions.
  • Tests (test.js) refer to outdated tool names/functions and should be rewritten before relying on them.

Troubleshooting

  • Embedding errors: ensure the ONNX runtime assets exist in models/ort-wasm/ and the container has CPU instruction support (WASM fallback is used when needed).
  • Search index not found: allow Atlas Search creation or create the vectorSearchOnEmbedding index manually.
  • Performance issues: consider keeping the Mongo connection open (close() currently runs after each query) if latency becomes noticeable.