Catalog npm
Back to packageRELEASE DETAILS

2026.1.35

npm

2ndbrain

Always-on Node.js service bridging Telegram messaging to Claude AI with knowledge graph, journal, project management, and semantic search.

aiassistantclaudeknowledge-graphtelegram
Published1 Feb 2026
Direct dependencies5
Transitive dependenciesNot calculated

README

Current package documentation

2ndbrain

A personal, always-on AI assistant that lives on your local network. 2ndbrain bridges Telegram to Claude via a Node.js service, giving you a private conversational AI with persistent memory, a knowledge platform, and full access to local tools — all from your phone.

You set it up on a device on your LAN (e.g. a Raspberry Pi 5), and you — and only you — interact with it by chatting over Telegram.

How It Works

Telegram  ──long-polling──▸  2ndbrain  ──subprocess──▸  Claude CLI
                                │                          │
                                │                     MCP tools
                                │                     (postgres, embeddings,
                                │                      shell commands)
                                │
                           PostgreSQL
                         (history, knowledge,
                          projects, journal,
                          embeddings)
  1. Messages arrive from Telegram via long-polling (no public URL required)
  2. Slash commands are routed to built-in handlers; everything else goes to Claude
  3. Claude is spawned as a subprocess with access to MCP tools (database, semantic search, whitelisted shell commands)
  4. Responses stream back through Telegram with a typing indicator
  5. All conversations are persisted in PostgreSQL for recall and search

Integrations

IntegrationRole
Telegram Bot APIMessaging interface — long-polling, attachments (photos, docs, audio, video, voice), typing indicators
Claude CLIConversational AI — spawned as subprocess with streaming JSON, thinking mode, session continuity
PostgreSQL + pgvectorPersistent storage — conversation history, knowledge graph, projects, journal, vector embeddings with HNSW indexing
Model Context Protocol (MCP)Tool framework — gives Claude direct access to the database (pg server) and a custom embed_query tool for semantic search
OpenAI Embeddings APIVector embeddings — optional provider for semantic search (configurable model and dimensions)
ExpressWeb admin dashboard — settings, environment config, activity logs (LAN-only)

Features

Conversation

  • Persistent conversation history with session tracking
  • Auto-compaction when history exceeds a configurable threshold
  • Rate limiting for both Claude calls and Telegram sends
  • Attachment storage (photos, documents, audio, video, voice) in ~/data

Skills (Claude-managed via MCP)

SkillDescription
Knowledge GraphEntities and relationships with full-text search and embedding queue
JournalTimestamped personal notes with semantic search
Project ManagementProjects with specifications and issues, completion tracking
SchedulerRecurring tasks via cron expressions with timezone support
RecallUnified semantic search across journal, knowledge, projects, and history
System OpsRead-only diagnostics — memory, disk, uptime, database status, logs

Slash Commands

CommandAction
/statusCurrent system status
/healthHealth check across all subsystems
/restartRestart the service
/rebootReboot the host
/stopGraceful shutdown
/newStart a new conversation session
/helpList available commands

Security

  • Whitelisted Telegram users (multi-layered)
  • Whitelisted MCP tools and shell commands
  • Configurable file-edit path restrictions
  • LAN-only web admin interface

Lifecycle Hooks

Custom scripts that run at startup, shutdown, pre/post Claude invocation, and on errors.

Setup

  1. Ensure PostgreSQL is running with the pgvector extension
  2. Ensure claude-cli is installed and configured
  3. Create a .env file at ~/.2ndbrain/.env (see Configuration below)
  4. Start the service: npx 2ndbrain
  5. (Optional) Configure to start on boot via systemd or similar

Configuration

All configuration lives in ~/.2ndbrain/.env:

CategoryKey Variables
RequiredTELEGRAM_BOT_TOKEN, TELEGRAM_ALLOWED_USERS, DATABASE_URL
ClaudeCLAUDE_MODEL, CLAUDE_THINKING, CLAUDE_TIMEOUT, CLAUDE_MAX_BUDGET
MCPMCP_CONFIG_PATH, MCP_TOOLS_WHITELIST, COMMANDS_WHITELIST
EmbeddingsEMBEDDING_PROVIDER, EMBEDDING_API_KEY, EMBEDDING_MODEL, EMBEDDING_DIMENSIONS
Rate LimitsRATE_LIMIT_CLAUDE (default 10/min), RATE_LIMIT_TELEGRAM (default 30/min)
Web AdminWEB_PORT, WEB_BIND, AUTO_OPEN_BROWSER
StorageDATA_DIR (default ~/data)
ConversationHISTORY_COMPACT_THRESHOLD (default 100)
SecurityFILE_EDIT_PATHS
LoggingLOG_LEVEL

Data Schema

  • Projects (id, created, updated, name)
    • Specifications (id, created, updated, project_id, note)
    • Issues (id, created, updated, note, completed)
  • Knowledge Graph
    • Nodes (id, created, updated, name, note)
    • Edges (id, created, updated, node1_id, node2_id, name)
  • Journal (id, created, updated, note)
  • Conversation Messages (id, created, updated, user_id, message_id, content, session_id)
  • System Logs (id, timestamp, content, level)
  • Attachments (id, created, updated, file_path, metadata)
  • Scheduled Tasks (id, cron_expression, timezone, next_run, error tracking)
  • Embeddings (id, created, updated, entity_type, vector)

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 5

Native requirements
5 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
pg
Environment
{
  "local_name": "pg",
  "alias": false,
  "peer_metadata": null
}
^8.13.1runtime
open
Environment
{
  "local_name": "open",
  "alias": false,
  "peer_metadata": null
}
^10.1.0runtime
dotenv
Environment
{
  "local_name": "dotenv",
  "alias": false,
  "peer_metadata": null
}
^16.4.7runtime
express
Environment
{
  "local_name": "express",
  "alias": false,
  "peer_metadata": null
}
^4.21.2runtime
node-cron
Environment
{
  "local_name": "node-cron",
  "alias": false,
  "peer_metadata": null
}
^4.2.1runtime

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "56ee13e1df6a4febafa117b0170e03a28a119ff0",
  "tarball": "https://registry.npmjs.org/2ndbrain/-/2ndbrain-2026.1.35.tgz",
  "fileCount": 33,
  "integrity": "sha512-IQNPinuReOAJvM9RtVOyinEXrSaTmK4eOHgRwSL7StDOvqHUpTY5batzv5xWSYHMSS5M5FLCSdp0QJIGdT4t0w==",
  "signatures": [
    {
      "sig": "MEQCIGDm5qpFmLOtWJZKpSaHd1RH9XiKelwQqr4EtzgsmI/CAiBO5jwV6mWUPS19muPPvdivUROzhenZIc5L3UTjYbwafg==",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 291697
}

Repository

PENDING
fingerskier/2ndbrain

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:15 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:76deb6f83bc9687556faced7ba1b127e6c0bc528ebfc897a88a5f036b2fe3984

Other collected versions

2026.2.41 Feb2026.2.31 Feb2026.2.21 Feb2026.2.11 Feb2026.1.371 Feb2026.1.361 FebView all collected versions →