memgrep
memgrep
Семантический поиск по вашим мемам из Telegram. Спрашивайте на русском или английском — и находите мем, который смутно помните.
Конвейер: экспорт из Telegram → описания от vision-модели (двуязычные) + OCR → мультиязычные эмбеддинги (bge-m3, локально) → гибридный поиск PostgreSQL/pgvector (плотный + полнотекстовый, RRF) → переранжирование cross-encoder. Доступен как CLI, веб-интерфейс и MCP-сервер, так что ваш ИИ-ассистент тоже сможет искать мемы.
Полную архитектуру см. в дизайн-спеке.
Быстрый старт
cp .env.example .env # fill in OpenRouter API key
make up # PostgreSQL + pgvector on :5433
make test
uv run memgrep ingest # load data/result.json + photos into the db
uv run memgrep caption --limit 400 # describe images via a vision model (pilot)
uv run memgrep embed # local bge-m3 embeddings
uv run memgrep search "this is fine" # CLI search; --open shows files in Preview
uv run memgrep serve # web UI on localhost:8000
uv run memgrep evals # golden-set metrics for the current config
uv run memgrep sync # ingest + caption + embed for new exports
uv run memgrep watch # follow the channel via Bot APIЭкспорт из Telegram сохраняется в data/ (Telegram Desktop → Экспорт истории чатов → Фотографии, формат JSON). Мемы и экспортированные данные остаются локально — data/ игнорируется git’ом; публикуется только код.
Related MCP server: local-docs-mcp
Качество поиска
Метрики измерены на золотом наборе из 21 запроса, собранном через кнопку обратной связи в интерфейсе ("это он ✓"), и пилотном корпусе из 400 изображений. Каждый слой поиска добавлялся только после того, как доказал свою пользу:
Слой | hit@5 | hit@10 | MRR |
только плотные векторы | 0.857 | 0.905 | 0.768 |
+ полнотекстовый поиск, слияние RRF | 0.905 | 0.952 | 0.815 |
+ реранкер cross-encoder | 0.905 | 1.000 | 0.839 |
Сравнение моделей описаний на том же корпусе и золотом наборе: qwen3-vl-8b сравнялась или превзошла qwen3-vl-235b по метрикам поиска при цене втрое ниже, поэтому весь корпус индексируется моделью 8b (~$3.6 за ~11k изображений). Оговорка задокументирована в истории оценок: золотой набор собирался поверх индекса 8b, что смещает сравнение в её пользу.
Конфигурация поиска задаётся переменными окружения: MEMGREP_SEARCH_MODE=vector|hybrid, MEMGREP_RERANK_ENABLED=true|false. memgrep evals записывает JSON с меткой времени для каждой конфигурации в evals/results/, чтобы запуски оставались сопоставимыми.
MCP-сервер
Позвольте Claude (или любому MCP-клиенту) искать ваши мемы:
claude mcp add memgrep -- uv run --directory /absolute/path/to/memgrep python -m memgrep.mcp_serverИнструменты: search_memes(query, k) возвращает совпадения с путями к файлам и описаниями; get_meme(sha256) возвращает само изображение.
Служба наблюдения
Команда memgrep watch в реальном времени отслеживает Telegram-канал через long polling Bot API. Настройте бота администратором канала, задайте MEMGREP_TG_BOT_TOKEN и MEMGREP_TG_CHANNEL_ID и запустите службу наблюдения. Новые фотографии, опубликованные в канале, автоматически индексируются: в течение нескольких минут они получают описания, эмбеддинги и становятся доступными для поиска. Реакции на недавние записи также синхронизируются обратно в базу данных для отслеживания вовлечённости.
Стек
Python 3.12+, uv, PostgreSQL 17 + pgvector, sentence-transformers (эмбеддинги BAAI/bge-m3, реранкер BAAI/bge-reranker-v2-m3, обе модели локальные), любой OpenAI-совместимый vision-эндпоинт для описаний (по умолчанию: OpenRouter, qwen3-vl), FastAPI, typer, MCP Python SDK. 49 тестов, в тестовом наборе нет сетевых запросов и загрузок моделей.
Available Tools
2 toolsget_memeA
Return the meme image itself by sha256 from a search_memes result.
| Name | Required | Description | Default |
|---|---|---|---|
| sha256 | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description must carry the behavioral disclosure burden. It states the core behavior (returning the image binary for a given hash) and implies a read-only action, but it does not disclose output format (e.g., binary, base64), error conditions, or whether any authentication is required. This is adequate but not rich.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, front-loaded sentence with no filler words. Every phrase contributes meaning: 'meme image itself' clarifies the return value, 'by sha256' identifies the key parameter, and 'from a search_memes result' indicates the source workflow.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool with one parameter and no output schema, the description is largely complete: it identifies the input provenance, the operation, and the result. It does not mention potential errors or the exact binary format, but given the tool's simplicity the missing details are minor and unlikely to cause incorrect invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides only the parameter name and type (string) with 0% description coverage, so the description must add meaning. It does this by explaining that the sha256 parameter comes from a search_memes result, giving the agent crucial context on how to obtain a valid value. It could specify the expected format (e.g., hex-encoded SHA-256), but the guidance is already helpful.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Return') and names a precise resource ('the meme image itself') with a clear retrieval mechanism ('by sha256'). Referencing 'from a search_memes result' distinguishes it from its sibling tool search_memes, which presumably returns metadata or search results rather than the image content.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly implies the intended usage: call this tool with a sha256 obtained from search_memes to fetch the actual image. It doesn't explicitly state exclusions or when to prefer alternatives, but for a simple single-purpose tool the context is clear enough.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_memesA
Semantic search over the meme collection. Query in Russian or English.
| Name | Required | Description | Default |
|---|---|---|---|
| k | No | ||
| query | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the behavioral burden; it does convey that matching is semantic rather than exact and that the query language is flexible. It does not state read-only behavior, result ordering, or limitations, but for a simple search tool the disclosed traits are non-trivial.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two short sentences carry the essential message, with the main action stated first and no filler. Every phrase earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple two-parameter search with an output schema, the description is nearly sufficient, but it leaves two gaps: the meaning/behavior of 'k' and the relationship to the sibling get_meme tool. This is adequate but not complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so the description must compensate. It adds meaning to 'query' by explaining the search is semantic and accepts Russian or English, but it remains silent on the 'k' parameter. The compensation is partial, making this minimum viable.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description gives a specific verb and resource ('Semantic search over the meme collection') and the 'semantic' qualifier distinguishes it from a direct fetch like get_meme. It is clear, but it does not explicitly name or contrast the sibling tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'Semantic search over the meme collection' implies when the tool is relevant, and 'Query in Russian or English' gives practical input guidance. However, it offers no explicit direction on when to choose this over get_meme or what types of queries are not appropriate.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
The two tools have clearly distinct purposes: one performs semantic search over the collection, the other retrieves a specific image by hash. There is no overlap or ambiguity between them.
Both tools follow the same verb_noun pattern in snake_case: search_memes and get_meme. The singular/plural variation is natural for resource action and does not break consistency.
With only two tools, the server feels thin and sits at the low end of the borderline range. However, the narrow purpose of search and retrieval justifies a minimal surface, so it is not unreasonable.
For a read-only meme search and retrieval server, the surface is complete: search returns hashes and get_meme fetches the image. There are no dead ends or missing core operations within this defined scope.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Memory system for AI agents with semantic search. Store and recall memories with ease.
Persistent memory for AI agents. Search, store, and recall across sessions.
Persistent memory for AI agents. Semantic search, memory graph, W3C DID identity.
Persistent AI memory with semantic search, conflict detection, and ticketing.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with persistent memory through local ChromaDB vector storage, featuring automated file ingestion and batch processing for over 70 file types. It enables advanced vector search, EXIF metadata extraction for photos, and duplicate file detection across local directories.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to perform semantic, hybrid, and filtered search on indexed local documentation with RAG capabilities.2MIT
- AlicenseNot gradedqualityCmaintenanceEnables searching local images using natural Japanese queries, leveraging a Japanese-specific CLIP model for similarity search and providing efficient caching and fast retrieval via MCP and HTTP endpoints.MIT
- AlicenseAqualityBmaintenanceEnables natural language search of local photo archives using AI-powered semantic understanding, with integration into Claude Desktop via the Model Context Protocol.42MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Milflopper/memgrep'
If you have feedback or need assistance with the MCP directory API, please join our Discord server