consciousness MCP server

consciousness MCP server

A pluggable vector memory server for semantic search and long-term memory, with session-scoped and universal memory tools.

Category
访问服务器

README

@one710/consciousness

npm version npm downloads Build Status License: MIT

A powerful, pluggable vector memory and Model Context Protocol (MCP) server for local semantic search and long-term memory.

Features

  • MCP Integration: Fully compatible with the Model Context Protocol.
  • Session-Scoped & Universal Memory: Scoped tools isolate memory per sessionId; universal tools provide shared, session-independent storage.
  • Pluggable Architecture: Easily swap embedding providers and vector stores.
  • Multiple Storage Backends: Memory, Filesystem, ChromaDB, and Supabase (pgvector) via optional entry points.
  • Optional embedding entry points: Hugging Face and AI SDK providers load only when imported from @one710/consciousness/huggingface or @one710/consciousness/aisdk.
  • Semantic Search: Use state-of-the-art embeddings for intelligent memory retrieval.
  • DTS Indexing: Optimized search using Distance to Samples (DTS) logic.

Quick Start (using npx)

You can run the consciousness MCP server directly without installation using npx:

npx @one710/consciousness

By default, this will start an MCP server named "consciousness" using a FilesystemVectorStore (persisted to ./memory_store.json) and HFEmbeddingProvider.

Installation

npm install @one710/consciousness

Usage in Code

Creating an MCP Server

import { createServer, MemoryVectorStore } from "@one710/consciousness";
import { HFEmbeddingProvider } from "@one710/consciousness/huggingface";

const provider = new HFEmbeddingProvider();
const store = new MemoryVectorStore(provider);
const server = createServer("my-server", "1.0.0", store);

// Connect to transport (e.g., Stdio)
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const transport = new StdioServerTransport();
await server.connect(transport);

Embedding Providers

Hugging Face (Local)

Uses @huggingface/transformers to generate embeddings locally on your CPU/GPU. Import the optional entry so the main package graph does not load Transformers until you use this provider:

import { HFEmbeddingProvider } from "@one710/consciousness/huggingface";

const provider = new HFEmbeddingProvider();

AI SDK (Cloud/Remote)

Uses the Vercel AI SDK to connect to any supported provider (e.g., OpenAI, Anthropic, Google). Install ai and the provider package you use, then import:

import { AISDKEmbeddingProvider } from "@one710/consciousness/aisdk";
import { openai } from "@ai-sdk/openai";

const provider = new AISDKEmbeddingProvider(
  openai.embedding("text-embedding-3-small"),
  1536, // Dimensions
);

Vector Stores

Memory Store (In-memory)

import { MemoryVectorStore } from "@one710/consciousness";

const store = new MemoryVectorStore(provider);

Filesystem Store (Local Persistence)

import { FilesystemVectorStore } from "@one710/consciousness";

const store = new FilesystemVectorStore(provider, "./memory-data.json");

Chroma Store (Distributed/Managed)

Install chromadb alongside this package, then import the optional entry (the main package does not depend on Chroma):

import { ChromaVectorStore } from "@one710/consciousness/chroma";
import { ChromaClient } from "chromadb";

const client = new ChromaClient();
const store = new ChromaVectorStore(provider, client, "my-collection");

Supabase Store (pgvector)

Install @supabase/supabase-js, apply the SQL under supabase/migrations/ in your project. In that migration, set embedding_dim in the DO block to your provider’s width (e.g. 1536 for OpenAI text-embedding-3-small, 384 for the default MiniLM model) before the first run. Then:

import { createClient } from "@supabase/supabase-js";
import { SupabaseVectorStore } from "@one710/consciousness/supabase";

const client = createClient(url, key);
const store = new SupabaseVectorStore(provider, client);

Working with Sessions

All store operations require a sessionId to isolate memories:

const sessionId = "user-123";

// Store a memory
await store.add(sessionId, "The capital of France is Paris");

// Search within the session
const results = await store.search(sessionId, "France", {
  method: "cosine",
  limit: 5,
});

// Forget a specific memory
await store.forget(sessionId, results[0].item.id);

// Clear all memories for the session
await store.clear(sessionId);

MCP Tools

The MCP server exposes two sets of tools:

Scoped Tools (require sessionId)

Tool Description
add_to_scoped_memory Store content scoped to a session
search_scoped_memory Semantic search within a session (cosine, euclidean, dts)
forget_scoped_memory Remove a specific memory by ID within a session
clear_scoped_memory Clear all memories for a session

Universal Tools (no sessionId needed)

Tool Description
add_to_universal_memory Store content in shared, session-independent memory
search_universal_memory Semantic search across universal memory (cosine, euclidean, dts)
forget_universal_memory Remove a specific memory by ID from universal memory
clear_universal_memory Clear all universal memories

Local Supabase (Docker) and tests

The repo includes a Supabase CLI project under supabase/. With Docker running:

yarn supabase:start

That pulls images, applies supabase/migrations/, and exposes the API at http://127.0.0.1:54321 (see yarn supabase:status). Stop with yarn supabase:stop.

Integration tests in test/supabase-vector-store.test.ts probe that URL with the default local service role JWT. If the stack is down, they skip with a short console warning so yarn test still finishes. To force-skip them (e.g. in CI without Docker):

SKIP_SUPABASE_TESTS=1 yarn test

To run only the Supabase tests:

yarn supabase:start   # once per machine session
yarn test:supabase

Override URL/key when needed: SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY (or API_URL / SERVICE_ROLE_KEY from supabase status --output env).

Chroma + Supabase via Docker Compose (integration tests)

docker-compose.test.yml runs Chroma (port 8000), Postgres + pgvector (host 54332), PostgREST, and a tiny nginx gateway so @supabase/supabase-js keeps using the /rest/v1/ paths it expects. Defaults avoid colliding with Supabase CLI on 54321 / 54322; the API for tests is http://127.0.0.1:54331.

yarn docker:test:up    # wait until containers are healthy
yarn docker:test       # sets SUPABASE_URL=http://127.0.0.1:54331 and runs the full suite
yarn docker:test:down  # stop and remove volumes

yarn test expects Chroma on localhost:8000 (e.g. yarn docker:test:up before a full run). test/chroma.test.ts uses ChromaClient defaults to match the compose mapping. SKIP_SUPABASE_TESTS still applies when no Supabase-compatible API is reachable on SUPABASE_URL (default http://127.0.0.1:54321).

License

This project is licensed under the MIT License.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选