Class ChatMcpTool

java.lang.Object
io.meeds.chat.mcp.ChatMcpTool
All Implemented Interfaces:
io.meeds.mcp.server.plugin.McpToolPlugin

@Service public class ChatMcpTool extends Object implements io.meeds.mcp.server.plugin.McpToolPlugin
MCP tools exposing the Matrix chat to AI agents. Discovered by the platform mcp-server: a plain @Service implementing McpToolPlugin (no @McpTool annotation, no custom constructor) whose public methods become tools. Each method must have a matching entry, by snake_case name, in ai-tool-definitions.json or it is silently ignored by the mcp-server.
  • Field Details

    • matrixService

      @Autowired protected MatrixService matrixService
  • Constructor Details

    • ChatMcpTool

      public ChatMcpTool()
  • Method Details

    • listChatConversations

      public List<ChatConversation> listChatConversations()
      Lists the chat conversations (direct messages and space rooms) the current user participates in. Tool name: list_chat_conversations.
      Returns:
      the current user's conversations
    • getChatMessages

      public List<ChatMessage> getChatMessages(String conversationId, Integer limit)
      Returns the most recent messages of one of the current user's conversations, in chronological order. Tool name: get_chat_messages.
      Parameters:
      conversationId - the Matrix room id, as returned by list_chat_conversations
      limit - the maximum number of messages to return; defaults to 50 when omitted by the agent
      Returns:
      the conversation messages, oldest first
    • getUnreadChatMessages

      public List<ChatUnread> getUnreadChatMessages()
      Returns the current user's unread conversations together with their recent messages, to help build a "catch me up" digest of what the user missed. Tool name: get_unread_chat_messages.
      Returns:
      the current user's unread conversations
    • sendChatMessage

      public String sendChatMessage(String conversationId, String text)
      Sends a text message to one of the current user's conversations, on the user's behalf. Tool name: send_chat_message.
      Parameters:
      conversationId - the Matrix room id, as returned by list_chat_conversations
      text - the plain text message to send
      Returns:
      the created event id, or null when the message could not be sent
    • searchChatMessages

      public List<ChatSearchResult> searchChatMessages(String query, String conversationId)
      Full-text searches the current user's chat messages, either across all their conversations or scoped to a single one. Tool name: search_chat_messages.
      Parameters:
      query - the free-text search term
      conversationId - an optional Matrix room id (as returned by list_chat_conversations) to restrict the search to a single conversation; when omitted, all the user's conversations are searched
      Returns:
      the matching messages, most recent first, each with its conversation