Navigation
TxtAI Assistant MCP: Semantic Search & Memory Management - MCP Implementation

TxtAI Assistant MCP: Semantic Search & Memory Management

TxtAI Assistant MCP: Boost semantic search & memory management with a robust API, seamlessly integrating Claude & Cline AI for intuitive text-based insights. Elevate your workflows today!

Research And Data
4.4(101 reviews)
151 saves
70 comments

This tool saved users approximately 8717 hours last month!

About TxtAI Assistant MCP

What is TxtAI Assistant MCP: Semantic Search & Memory Management?

TxtAI Assistant MCP is a modular component designed to integrate semantic search and memory management capabilities into AI systems. Built on the MCP (Multi-Component Protocol) framework, it enables applications to store contextual information, retrieve relevant data through natural language queries, and maintain organized tag-based indices. The tool leverages advanced NLP models for semantic analysis and stores structured data in JSON formats, ensuring efficient context retention and retrieval.

How to Use TxtAI Assistant MCP: Semantic Search & Memory Management?

  1. Installation: Deploy via the provided startup script and configure environment variables from the .env.template.
  2. Memory Storage: Use the /store endpoint with JSON payloads containing content, metadata, and tags.
  3. Semantic Search: Query via /search with a natural language prompt and specify result limits.
  4. Integration: Embed into AI workflows using MCP tool syntax, e.g., <use_mcp_tool> blocks for dynamic context handling.

TxtAI Assistant MCP Features

Key Features of TxtAI Assistant MCP

  • Contextual Memory Storage: Stores user interactions and metadata in persistent JSON files with versioned backups.
  • Tag-Driven Indexing: Automatically creates searchable tag hierarchies for rapid data categorization.
  • Health Monitoring: Real-time checks for database integrity and model performance via /health endpoints.
  • Error Resilience: Graceful failure handling with detailed logging and automatic retries for transient issues.
  • Security: Role-based access controls and encrypted data storage options for sensitive information.

Use Cases for TxtAI Assistant MCP

Typical applications include:

  • AI chatbots maintaining user-specific histories across sessions
  • Document management systems with semantic search capabilities
  • Personal knowledge bases for project-specific context tracking
  • Automated support agents resolving issues using past interaction data

TxtAI Assistant MCP FAQ

FAQ

Does it support real-time updates?
Yes, memory storage operations are atomic and thread-safe for concurrent access.
What data formats are supported?
Primarily JSON for structured data, with CSV import/export features available via the admin API.
How is memory retention managed?
Data is stored indefinitely by default, but admins can configure TTL (Time-to-Live) policies per namespace.
Can it integrate with existing systems?
Yes, provides RESTful APIs and WebSockets interfaces for real-time interaction with third-party platforms.
What languages are supported?
Current semantic models support 20+ languages through multilingual embeddings. Custom language packs can be added via the plugin system.

Content

TxtAI Assistant MCP

A Model Context Protocol (MCP) server implementation for semantic search and memory management using txtai. This server provides a robust API for storing, retrieving, and managing text-based memories with semantic search capabilities.

About txtai

This project is built on top of txtai, an excellent open-source AI-powered search engine created by NeuML. txtai provides:

  • 🔍 All-in-one semantic search solution
  • 🧠 Neural search with transformers
  • 💡 Zero-shot text classification
  • 🔄 Text extraction and embeddings
  • 🌐 Multi-language support
  • 🚀 High performance and scalability

We extend txtai's capabilities by integrating it with the Model Context Protocol (MCP), enabling AI assistants like Claude and Cline to leverage its powerful semantic search capabilities. Special thanks to the txtai team for creating such a powerful and flexible tool.

Features

  • 🔍 Semantic search across stored memories
  • 💾 Persistent storage with file-based backend
  • 🏷️ Tag-based memory organization and retrieval
  • 📊 Memory statistics and health monitoring
  • 🔄 Automatic data persistence
  • 📝 Comprehensive logging
  • 🔒 Configurable CORS settings
  • 🤖 Integration with Claude and Cline AI

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)
  • virtualenv (recommended)

Installation

  1. Clone this repository:
git clone https://github.com/yourusername/txtai-assistant-mcp.git
cd txtai-assistant-mcp
  1. Run the start script:
./scripts/start.sh

The script will:

  • Create a virtual environment
  • Install required dependencies
  • Set up necessary directories
  • Create a configuration file from template
  • Start the server

Configuration

The server can be configured using environment variables in the .env file. A template is provided at .env.template:

# Server Configuration
HOST=0.0.0.0
PORT=8000

# CORS Configuration
CORS_ORIGINS=*

# Logging Configuration
LOG_LEVEL=DEBUG

# Memory Configuration
MAX_MEMORIES=0

Integration with Claude and Cline AI

This TxtAI Assistant can be used as an MCP server with Claude and Cline AI to enhance their capabilities with semantic memory and search functionality.

Configuration for Claude

To use this server with Claude, add it to Claude's MCP configuration file (typically located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "txtai-assistant": {
      "command": "path/to/txtai-assistant-mcp/scripts/start.sh",
      "env": {}
    }
  }
}

Configuration for Cline

To use with Cline, add the server configuration to Cline's MCP settings file (typically located at ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json):

{
  "mcpServers": {
    "txtai-assistant": {
      "command": "path/to/txtai-assistant-mcp/scripts/start.sh",
      "env": {}
    }
  }
}

Available MCP Tools

Once configured, the following tools become available to Claude and Cline:

  1. store_memory: Store new memory content with metadata and tags
{
  "content": "Memory content to store",
  "metadata": {
    "source": "conversation",
    "timestamp": "2023-01-01T00:00:00Z"
  },
  "tags": ["important", "context"],
  "type": "conversation"
}
  1. retrieve_memory: Retrieve memories based on semantic search
{
  "query": "search query",
  "n_results": 5
}
  1. search_by_tag: Search memories by tags
{
  "tags": ["important", "context"]
}
  1. delete_memory: Delete a specific memory by content hash
{
  "content_hash": "hash_value"
}
  1. get_stats: Get database statistics
{}
  1. check_health: Check database and embedding model health
{}

Usage Examples

In Claude or Cline, you can use these tools through the MCP protocol:

# Store a memory
<use_mcp_tool>
<server_name>txtai-assistant</server_name>
<tool_name>store_memory</tool_name>
<arguments>
{
  "content": "Important information to remember",
  "tags": ["important"]
}
</arguments>
</use_mcp_tool>

# Retrieve memories
<use_mcp_tool>
<server_name>txtai-assistant</server_name>
<tool_name>retrieve_memory</tool_name>
<arguments>
{
  "query": "what was the important information?",
  "n_results": 5
}
</arguments>
</use_mcp_tool>

The AI will automatically use these tools to maintain context and retrieve relevant information during conversations.

API Endpoints

Store Memory

POST /store

Store a new memory with optional metadata and tags.

Request Body:

{
    "content": "Memory content to store",
    "metadata": {
        "source": "example",
        "timestamp": "2023-01-01T00:00:00Z"
    },
    "tags": ["example", "memory"],
    "type": "general"
}

Search Memories

POST /search

Search memories using semantic search.

Request Body:

{
    "query": "search query",
    "n_results": 5,
    "similarity_threshold": 0.7
}

Search by Tags

POST /search_tags

Search memories by tags.

Request Body:

{
    "tags": ["example", "memory"]
}

Delete Memory

DELETE /memory/{content_hash}

Delete a specific memory by its content hash.

Get Statistics

GET /stats

Get system statistics including memory counts and tag distribution.

Health Check

GET /health

Check the health status of the server.

Directory Structure

txtai-assistant-mcp/
├── server/
│   ├── main.py           # Main server implementation
│   └── requirements.txt  # Python dependencies
├── scripts/
│   └── start.sh         # Server startup script
├── data/                # Data storage directory
├── logs/                # Log files directory
├── .env.template        # Environment configuration template
└── README.md           # This file

Data Storage

Memories and tags are stored in JSON files in the data directory:

  • memories.json: Contains all stored memories
  • tags.json: Contains the tag index

Logging

Logs are stored in the logs directory. The default log file is server.log.

Development

To contribute to this project:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Error Handling

The server implements comprehensive error handling:

  • Invalid requests return appropriate HTTP status codes
  • Errors are logged with stack traces
  • User-friendly error messages are returned in responses

Security Considerations

  • CORS settings are configurable via environment variables
  • File paths are sanitized to prevent directory traversal
  • Input validation is performed on all endpoints

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Related MCP Servers & Clients