Skip to content

Conversation

tpayet
Copy link
Member

@tpayet tpayet commented Aug 6, 2025

Summary

  • Implement comprehensive chat completion support for Meilisearch v1.6.0+
  • Add 6 new MCP tools for chat functionality with streaming support
  • Enable RAG-powered chat responses using indexed documents as context

Changes

New Features

  • ChatManager Class: New manager module to handle all chat-related operations
    • Streaming and non-streaming chat completions
    • Chat workspace CRUD operations
    • Proper error handling and HTTP client management

MCP Tools Added

  1. chat-completion: Generate AI responses with RAG using indexed documents
    • Supports streaming for real-time responses
    • Configurable model, temperature, and token limits
    • Can target specific indices or workspaces
  2. create-chat-workspace: Create workspaces with default chat settings
  3. update-chat-workspace: Modify existing workspace configurations
  4. list-chat-workspaces: List all available chat workspaces
  5. get-chat-workspace: Get details of a specific workspace
  6. delete-chat-workspace: Remove chat workspaces

Implementation Details

  • Streaming responses properly handle Server-Sent Events (SSE) format
  • All chat endpoints follow Meilisearch's API conventions
  • Proper integration with existing MCP server architecture
  • Comprehensive test coverage with mocked HTTP responses

Documentation

  • Updated README with chat feature examples
  • Added tool descriptions in the full documentation section
  • Included practical usage examples for AI assistants

Testing

  • Added comprehensive test suite in test_chat_features.py
  • Tests cover all chat operations including error handling
  • Mocked HTTP clients to avoid external dependencies
  • Updated existing tests to include new tools in discovery

Context

This PR implements support for the new chat completions feature introduced in Meilisearch v1.6.0, as described in the official documentation.

The implementation allows MCP clients (like Claude Desktop) to leverage Meilisearch's RAG capabilities for generating contextual responses based on indexed documents.

Example Usage

# Create a chat workspace
create-chat-workspace(
    uid="support-chat",
    name="Customer Support",
    indexUids=["products", "faqs"],
    model="gpt-4"
)

# Generate a streaming response
chat-completion(
    query="How do I return a defective product?",
    workspaceUid="support-chat",
    stream=True
)

🤖 Generated with Claude Code

- Implement ChatManager class with chat workspace and completion methods
- Add 6 new MCP tools for chat functionality:
  - chat-completion: Generate responses with RAG using indexed documents
  - create-chat-workspace: Create workspaces with default settings
  - update-chat-workspace: Modify existing workspace configurations
  - list-chat-workspaces: List all available workspaces
  - get-chat-workspace: Get specific workspace details
  - delete-chat-workspace: Remove workspaces
- Add streaming support for chat completions
- Include comprehensive tests for all chat features
- Update README with chat feature documentation and examples

This enables Meilisearch MCP users to leverage the new chat completions
feature introduced in Meilisearch v1.6.0, allowing LLMs to generate
contextual responses using indexed documents as knowledge base.
@tpayet tpayet force-pushed the feature/chat-completion-support branch from c4a5575 to 6e0b79e Compare August 6, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant