Skip to content

Add MCP (Model Context Protocol) support to prompt registry microservice#1855

Merged
chensuyue merged 8 commits intoopea-project:mainfrom
BudEcosystem:feature/3-mcp-support-prompt-registry
Aug 22, 2025
Merged

Add MCP (Model Context Protocol) support to prompt registry microservice#1855
chensuyue merged 8 commits intoopea-project:mainfrom
BudEcosystem:feature/3-mcp-support-prompt-registry

Conversation

@dittops
Copy link
Copy Markdown
Contributor

@dittops dittops commented Jul 20, 2025

Description

This PR adds Model Context Protocol (MCP) support to the prompt registry microservice, enabling AI agents to discover and use prompt management capabilities through the OPEA MCP framework.

Changes Made

  1. MCP Integration
    - Added MCP support to the prompt registry service with three exposed tools:
    • create_prompt: Store prompts with user association
    • get_prompt: Retrieve prompts by user, ID, or keyword search
    • delete_prompt: Delete prompts by ID
      - Enabled via ENABLE_MCP environment variable
  2. Service Architecture Updates
    - Fixed service registration pattern to use unified service name opea_service@prompt_registry for all endpoints
    - Added ServiceType.PROMPT_REGISTRY to the constants enum
    - Updated service startup logic in the main block
  3. Documentation
    - Updated README files to explain MCP functionality and usage
    - Documented important limitation: When MCP is enabled, regular HTTP endpoints are not available (MCP-only mode)
    - Added examples of MCP client usage
  4. Testing
    - Added comprehensive test script (test_prompt_registry_mcp.sh) that tests both MCP-enabled and disabled scenarios
    - Created unit tests for MCP functionality (test_prompt_registry_mcp_unit.py)
    - Tests verify backward compatibility and proper MCP tool registration
  5. Dependencies
    - Added mcp library to requirements

Technical Details

  • When ENABLE_MCP=true, the service operates in MCP-only mode, exposing only the SSE endpoint (/sse) for MCP protocol communication
  • Regular HTTP endpoints (/v1/prompt/create, /v1/prompt/get, /v1/prompt/delete) remain available when MCP is disabled
  • MCP tools are named after the function names, following the framework's convention

Testing

The PR includes comprehensive tests that verify:

  • Backward compatibility with MCP disabled
  • MCP tool discovery and initialization
  • SSE endpoint availability
  • Proper service registration with unified naming

dittops added 2 commits July 20, 2025 03:32
Signed-off-by: dittops <dittops@gmail.com>
Signed-off-by: dittops <dittops@gmail.com>
dittops added 3 commits July 20, 2025 05:13
Signed-off-by: dittops <dittops@gmail.com>
Signed-off-by: dittops <dittops@gmail.com>
Signed-off-by: dittops <dittops@gmail.com>
@chensuyue
Copy link
Copy Markdown
Collaborator

Wait for CI machine back for test.

@joshuayao joshuayao added this to the v1.4 milestone Jul 29, 2025
@joshuayao joshuayao added this to OPEA Aug 14, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
comps/cores/mega/constants.py 97.36% <100.00%> (+0.03%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshuayao
Copy link
Copy Markdown
Collaborator

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

@joshuayao joshuayao moved this to In progress in OPEA Aug 14, 2025
Signed-off-by: dittops <dittops@gmail.com>
Signed-off-by: dittops <dittops@gmail.com>
Copy link
Copy Markdown
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

@chensuyue chensuyue merged commit 0f1ba3b into opea-project:main Aug 22, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in OPEA Aug 22, 2025
chensuyue pushed a commit that referenced this pull request Aug 22, 2025
…ice (#1855)

* MCP support for prompt registry comp

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

* Fix test for the mcp

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

* fix: prompt response format in test

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

* fix: prompt response format in test

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

* fix: mcp test

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

* fix: update test for mcp

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

* fix: mcp test

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

---------

Signed-off-by: dittops <dittops@gmail.com>
(cherry picked from commit 0f1ba3b)
jilongW pushed a commit to jilongW/GenAIComps that referenced this pull request Dec 18, 2025
…ice (opea-project#1855)

* MCP support for prompt registry comp

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

* Fix test for the mcp

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

* fix: prompt response format in test

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

* fix: prompt response format in test

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

* fix: mcp test

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

* fix: update test for mcp

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

* fix: mcp test

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.

5 participants