Skip to content

Conversation

@dittops
Copy link
Contributor

@dittops dittops commented Jul 16, 2025

Description

This PR implements MCP (Model Context Protocol) support for the comps/chathistory microservice, enabling AI agents to discover and utilize chat history management capabilities as tools.

Problem Statement

The chathistory microservice currently lacks MCP support, preventing AI agents from discovering and utilizing chat history management capabilities as tools. This limits the microservice's integration potential within agent-based workflows where automated chat history operations (create, retrieve, update, delete conversations) would be valuable.

Changes Made

1. Core Microservice Updates

  • Added ENABLE_MCP environment variable to control MCP functionality (default: false)
  • Updated all three @register_microservice decorators with MCP parameters:
    • enable_mcp: Controlled by environment variable
    • mcp_func_type: Set to MCPFuncType.TOOL
    • description: Added descriptive text for AI agent discovery
  • Imported required MCP constants from comps.cores.mega.constants

2. Deployment Configuration

  • Docker Compose: Added ENABLE_MCP environment variable to compose.yaml
  • Kubernetes: Added MCP configuration section to cpu-values.yaml

3. Testing Infrastructure

  • Created test_chathistory_mcp.sh following existing MCP test patterns
  • Extended validate_svc_with_mcp.py to support chathistory service validation
  • Test performs full CRUD cycle: create, retrieve, and delete operations

4. Documentation

  • Added comprehensive MCP section to README including:
    • Configuration instructions for Docker and Kubernetes
    • Available MCP tools description
    • AI agent usage examples
    • SSE endpoint information

MCP Tools Exposed

When ENABLE_MCP=true, the following tools are available for AI agents:

  1. create_documents - Create or update chat conversation history for AI agent workflows
  2. get_documents - Retrieve chat conversation history for AI agent workflows
  3. delete_documents - Delete chat conversation history for AI agent workflows

Testing

  • Backward compatibility verified - existing functionality unchanged when MCP disabled
  • MCP validation test created following established patterns
  • All three operations (create, get, delete) tested via MCP interface
  • Documentation updated with clear examples

Deployment Notes

  • MCP is disabled by default to maintain backward compatibility
  • To enable MCP, set environment variable: ENABLE_MCP=true
  • No additional dependencies or security considerations required

@dittops dittops force-pushed the feature/2-add-mcp-support-to-chathistory branch from 515df3a to 33c84c3 Compare July 17, 2025 06:57
@dittops dittops requested a review from letonghan as a code owner July 20, 2025 06:46
@joshuayao joshuayao added this to the v1.4 milestone Jul 22, 2025
Copy link
Collaborator

@letonghan letonghan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joshuayao joshuayao added this to OPEA Aug 14, 2025
@joshuayao
Copy link
Collaborator

Hi @ZePan110 could you please help check the failure? libgl1-mesa-glx is deprecated.

@ZePan110
Copy link
Collaborator

Hi @ZePan110 could you please help check the failure? libgl1-mesa-glx is deprecated.

The fix for the built fail has been merged.
@dittops Please check for UT test failure.

@joshuayao
Copy link
Collaborator

Hi @dittops could you please check the CI failures? Thanks.

@joshuayao joshuayao moved this to In progress in OPEA Aug 14, 2025
Signed-off-by: dittops <dittops@gmail.com>
@dittops dittops force-pushed the feature/2-add-mcp-support-to-chathistory branch 2 times, most recently from 124e036 to 2cfccbf Compare August 21, 2025 12:35
Signed-off-by: dittops <dittops@gmail.com>
@dittops dittops force-pushed the feature/2-add-mcp-support-to-chathistory branch from 2cfccbf to 8b3f07e Compare August 21, 2025 12:39
@joshuayao joshuayao merged commit eed273e into opea-project:main Aug 27, 2025
18 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in OPEA Aug 27, 2025
jilongW pushed a commit to jilongW/GenAIComps that referenced this pull request Dec 18, 2025
* Feat: add mcp support to chat history comp

Signed-off-by: dittops <dittops@gmail.com>

* fix: update chathisotry MCP test with validate script

Signed-off-by: dittops <dittops@gmail.com>

* fix: pre-commit corrections

Signed-off-by: dittops <dittops@gmail.com>

---------

Signed-off-by: dittops <dittops@gmail.com>
Signed-off-by: sunzhonghua2004 <137033036@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants