Skip to content

[Feature] Add MCP support to text2cypher microservice #4

@dittops

Description

@dittops

Summary

The text2cypher microservice currently lacks MCP (Model Context Protocol) support, preventing AI agents from utilizing its natural language to Cypher query translation capabilities. This feature request proposes adding MCP support to align with other microservices in the GenAIComps framework.

Problem Statement

As a developer building AI agent applications, I need the text2cypher microservice to support MCP so that AI agents can directly interact with Neo4j databases through natural language queries. Currently, AI agents cannot discover or use the text2cypher service through the standard MCP protocol, limiting integration possibilities.

Current State

  • The text2cypher service is registered without MCP parameters in /comps/text2cypher/src/opea_text2cypher_microservice.py
  • Other microservices (feedback_management, prompt_registry, web_retrievers, etc.) already have MCP support
  • No /sse endpoint is exposed for MCP client connections

Proposed Solution

Add MCP support to text2cypher by updating the service registration to include:

  1. enable_mcp parameter (controlled by environment variable)
  2. mcp_func_type set to MCPFuncType.TOOL
  3. Descriptive description for AI agent discovery

Implementation Details

# Add environment variable check
enable_mcp = os.getenv("ENABLE_MCP", "").strip().lower() in {"true", "1", "yes"}

# Update the service registration
@register_microservice(
    name="opea_service@text2cypher",
    service_type=ServiceType.TEXT2CYPHER,
    endpoint="/v1/text2cypher",
    host="0.0.0.0",
    port=9097,
    enable_mcp=enable_mcp,
    mcp_func_type=MCPFuncType.TOOL,
    description="Convert natural language queries to Neo4j Cypher queries for graph database operations"
)

Benefits

  • AI Agent Integration: Enables AI agents to query Neo4j databases using natural language
  • Consistency: Aligns text2cypher with other MCP-enabled microservices
  • Flexibility: Environment variable control allows optional enablement
  • Discoverability: AI agents can discover and understand the service capabilities

Testing Plan

  • Verify MCP SSE endpoint (/sse) is exposed when ENABLE_MCP=true
  • Test discovery through OpeaMCPToolsManager
  • Validate tool execution with sample natural language queries
  • Ensure backward compatibility when MCP is disabled
  • Add integration test similar to test_feedback_management_mcp.sh

Acceptance Criteria

  1. text2cypher service can be enabled with MCP support via ENABLE_MCP environment variable
  2. Service is discoverable through MCP client tools
  3. AI agents can successfully execute natural language to Cypher translations
  4. No breaking changes to existing functionality
  5. Documentation updated to include MCP usage examples

Additional Context

  • MCP implementation pattern is well-established in the codebase
  • The change is minimal and follows existing conventions
  • This enables powerful AI agent workflows for knowledge graph interactions

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions