- Explore MCP Servers
- mcp-chat
Mcp Chat
What is Mcp Chat
MCP-Chat is a lightweight SDK that implements chat functionality on top of the Model Context Protocol (MCP). It enables bidirectional chat communication between MCP server and client applications with minimal configuration.
Use cases
Use cases for MCP-Chat include creating chat applications for communities, integrating chat features into existing applications, and enabling real-time communication in collaborative tools.
How to use
To use MCP-Chat, install it via npm with ‘npm install mcp-chat’. Then, create an MCP Server instance and a message bus instance, providing the necessary accessors for chat resources and messages.
Key features
Key features of MCP-Chat include a standardized interface for chat message exchange, resource-based chat thread management, real-time notifications for new messages, and cross-protocol chat functionality using a specific URI pattern.
Where to use
MCP-Chat can be used in various fields such as social networking applications, customer support systems, and any platform requiring real-time chat functionalities.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Chat
MCP-Chat is a lightweight SDK that implements chat functionality on top of the Model Context Protocol (MCP). It enables bidirectional chat communication between MCP server and client applications with minimal configuration.
Use cases
Use cases for MCP-Chat include creating chat applications for communities, integrating chat features into existing applications, and enabling real-time communication in collaborative tools.
How to use
To use MCP-Chat, install it via npm with ‘npm install mcp-chat’. Then, create an MCP Server instance and a message bus instance, providing the necessary accessors for chat resources and messages.
Key features
Key features of MCP-Chat include a standardized interface for chat message exchange, resource-based chat thread management, real-time notifications for new messages, and cross-protocol chat functionality using a specific URI pattern.
Where to use
MCP-Chat can be used in various fields such as social networking applications, customer support systems, and any platform requiring real-time chat functionalities.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MCP-Chat SDK
MCP-Chat is a lightweight SDK that implements chat functionality on top of the Model Context Protocol (MCP). It allows you to create bidirectional chat communication between MCP server and client applications with minimal configuration.
Overview
MCP-Chat extends the Model Context Protocol by:
- Providing a standardized interface for chat message exchange
- Implementing resource-based chat thread management
- Supporting real-time notifications for new messages
- Enabling cross-protocol chat functionality with URI pattern
chat+protocol:///path/to/thread
Getting Started
npm install mcp-chat
Usage
MCP-Chat is designed to be simple to implement. You only need to provide a few accessors and attach it to your MCP Server instance:
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { MCPMessageBus, ChatNotificationMessage } from "mcp-chat";
// Create your MCP Server
const server = new Server(
{
name: "my-chat-server",
version: "1.0.0",
},
{
capabilities: {
tools: {},
resources: {},
},
instructions: "This is a chat server that supports MCP-Chat protocol",
}
);
// Create your message bus instance
const messageBus = new MCPMessageBus({
// Define your resource template for chat threads
resourceTemplate: {
uriTemplate: `chat+mycustom:///([^\\/]+)/([^\\/]+)`,
name: "My Custom Chat",
description: "Chat resources for my custom protocol",
},
// Provide an accessor to get all chat resources
getResources: async () => {
// Return an array of Resources matching the chat+mycustom:/// pattern
return [
{
uri: "chat+mycustom:///thread1/general",
name: "General Chat",
description: "General chat thread",
},
// Add more resources as needed
];
},
// Provide an accessor to read messages from a given URI
readMessages: async (uri: string) => {
// Parse the URI and return messages for that thread
// Return array of ChatNotificationMessage objects
return [
{
id: "msg1",
uri: uri,
author: {
name: "User1",
id: "user1",
},
content: "Hello world!",
timestamp: new Date().toISOString(),
},
// Add more messages as needed
];
},
// Provide an accessor to write messages to a given URI
writeMessage: async (uri: string, message: string) => {
// Implement your message writing logic
// Return a confirmation string or undefined
return "Message sent successfully";
},
});
// Attach the message bus to your MCP server
messageBus.attach(server);
// When a new message arrives, notify subscribed clients
async function onNewMessage(uri: string) {
await messageBus.updateResource(uri);
}
Message Format
MCP-Chat uses a standardized message format:
export type ChatNotificationMessage = {
id: string; // Unique message ID
uri: string; // Resource URI where the message belongs
author: {
name: string; // Display name of the author
id: string; // Unique ID of the author
};
content: string; // Message content
timestamp: string; // ISO timestamp of when the message was sent
};
Resource URIs
Chat resources use a specialized URI format:
chat+protocol:///thread/path/goes/here
Where:
chat+protocolidentifies the chat protocol (e.g.,chat+discord,chat+slack, etc.)- IMPORTANT: All MCP-Chat URIs MUST begin with the
chat+prefix to be recognized by the SDK - The path component after
///identifies the thread or channel
MCP Client Interactions
Any MCP client that supports the MCP-Chat protocol can:
- Discover chat resources via the standard MCP resources mechanism
- Read chat messages by accessing the resource URI
- Send messages using the protocol-specific tool exposed automatically
- Subscribe to real-time updates for chat resources
Subscription and Notifications
To receive real-time updates, clients can:
- Subscribe to a resource URI using the standard MCP
subscriberequest:
{
"method": "subscribe",
"params": {
"uri": "chat+protocol:///thread/path"
}
}
- When new messages arrive, call the
updateResourcemethod:
// Notify clients when a new message is received
await messageBus.updateResource("chat+protocol:///thread/path");
This will send a resource update notification to all subscribed clients, so they can fetch the updated messages.
Real-world Example
The discord-mcp-server package is an example of MCP-Chat in action. It:
- Creates a Discord bot that listens for messages
- Exposes Discord channels as chat resources with URIs like
chat+discord:///serverId/channelId - Allows reading message history from these resources
- Provides a
chat+discordtool to send messages back to the channel - Notifies clients when new messages arrive on subscribed channels
License
ISC
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










