Coverage for merco/plugins/builtin/mcp/plugin.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-07 14:04 +0800

1"""MCP plugin — creates the MCP server manager.""" 

2from __future__ import annotations 

3 

4import logging 

5from typing import TYPE_CHECKING 

6 

7from merco.plugins.base import Plugin 

8 

9if TYPE_CHECKING: 

10 from merco.plugins.base import PluginContext 

11 

12logger = logging.getLogger("merco.plugins.mcp") 

13 

14 

15class MCPPlugin(Plugin): 

16 """Creates MCPServerManager and attaches it to PluginContext. 

17 

18 This plugin performs NO network or stdio I/O. Loading MCP servers 

19 remains an explicit caller step. 

20 """ 

21 

22 name = "mcp" 

23 version = "1.0.0" 

24 description = "Creates the MCP server manager" 

25 

26 async def activate(self, ctx: "PluginContext") -> None: 

27 from merco.mcp.manager import MCPServerManager 

28 

29 manager = MCPServerManager( 

30 tool_registry=ctx.tool_registry, 

31 hooks=ctx.hooks, 

32 ) 

33 ctx.mcp_manager = manager 

34 if ctx.agent is not None: 

35 ctx.agent.mcp_manager = manager 

36 

37 logger.info("MCP plugin activated")