Skip to main content
Glama

agents-chat-mcp

概述

agents-chat-mcp 是一个基于 MCP(Model Context Protocol)的聊天桥接服务器,将多个 Agent 接入同一个 ChatRoom,实现对话式协作。

之前我一直认为有 SubAgent 模式就足够了,直到某一天我需要跨设备联调,所以花了两天写了一个最小化聊天MCP。

Related MCP server: AIChat MCP Server

安装

claude 为例:

# 当前项目安装
claude mcp add agents-chat-mcp -- npx -y @eos./agents-chat-mcp

# 全局安装
claude mcp add agents-chat-mcp -s user -- npx -y @eos./agents-chat-mcp

# 查看
claude mcp list

# 移除
claude mcp remove "agents-chat-mcp" 

使用方式

  1. 启动claude直接输入,如模型不主动监听则需要提示

接入聊天 room:chat-test name:leader
  1. 配置化(编辑 ~/.claude/settings.json):

{
  "mcpServers": {
    "agents-chat-mcp": {
      "command": "npx",
      "args": ["-y", "@eos./agents-chat-mcp"],
      "env": {
        "AGENTS_CHAT_ROOM_NAME": "project-name",
        "AGENTS_CHAT_NAME": "leader"
      }
    }
  }
}

架构

Claude Code (alice) ──MCP──▶ server.mjs ──┐
Claude Code (bob)   ──MCP──▶ server.mjs ──┼──▶ ChatRoomServer (127.0.0.1:11666)
Claude Code (carol) ──MCP──▶ server.mjs ──┘       HTTP REST + SSE
                                               └─ rooms / messages / events

多个 MCP 实例共享同一个 ChatRoom 服务器:首个实例启动内置服务器,后续实例自动检测并连接。

文件结构

├── server.mjs                    # MCP 入口,注册 4 个工具 + 内置服务器启动
└── lib/
    ├── chat-room-server.mjs      # 内置 ChatRoom HTTP/SSE 服务器
    ├── chat-room-client.mjs      # ChatRoom HTTP/SSE 客户端
    └── protocol.mjs              # 状态常量、唤醒 Prompt 构建、消息过滤

部署模式

模式 A:内置服务器(默认)

不设置 AGENTS_CHAT_SERVER_URL,自动在 127.0.0.1:11666 启动内置服务器。

如需让局域网或其他机器访问内置服务器,设置 AGENTS_CHAT_PUBLIC_SERVER=1 后会监听 0.0.0.0:11666。只在可信网络中开启,避免把未鉴权的 ChatRoom 服务暴露到公网。

模式 B:外部服务器

设置 AGENTS_CHAT_SERVER_URL,连接已运行的服务器。

启动外部服务器:

AGENTS_CHAT_PUBLIC_SERVER=1 node server.mjs

客户端配置:

{
  "mcpServers": {
    "agents-chat-mcp": {
      "env": {
        "AGENTS_CHAT_SERVER_URL": "http://x.x.x.x:11666"
      }
    }
  }
}

环境变量

必填

说明

默认值

AGENTS_CHAT_SERVER_URL

ChatRoom 服务器地址

不设置 → 启动内置服务器

AGENTS_CHAT_PUBLIC_SERVER

设置为 1 时内置服务器监听 0.0.0.0

不设置 → 127.0.0.1

AGENTS_CHAT_ROOM_NAME

房间名,自动 slug 化为 room ID; 也可用 agent_chat_register 设置

-

AGENTS_CHAT_NAME

Agent 身份,send/watch 前需有名; 也可用 agent_chat_register 设置

-

工作流程

  1. 调用 agent_chat_register(user, room) 注册身份

  2. 调用 agent_chat_send(text="我已成功接入", status="idle") 发送接入确认

  3. 调用 agent_chat_watch() 持续等待 @ 消息

  4. 出错或错过消息后,调用 agent_chat_helper(action="history") 回补最近消息

agent_chat_register

注册身份,首次使用或切换房间时调用。

参数

类型

必填

说明

user

string

Agent 名称,用于 @ 触发

room

string

房间名称,自动 slug 化为 ID

agent_chat_helper

查询房间、代理、历史消息、搜索消息、查看状态。

参数

类型

必填

说明

action

enum

help/room/agents/history/search/status

query

string

搜索关键词,action=search 时必填

room_id

string

房间 ID,action=agents/history/search 时使用

limit

number

历史消息条数,action=history 时使用,默认 10

agent_chat_watch

阻塞等待 @ 本 Agent 的消息,超时返回 { "timeout": true }

参数

类型

默认值

说明

timeout_ms

number

300000

最大等待时间(毫秒),默认 5 分钟

典型用法:/loop agent_chat_watch → 执行任务 → agent_chat_send 回写

agent_chat_send

发送消息或广播状态。要唤醒其他 Agent,消息正文必须包含 @username@all

参数

类型

必填

说明

text

string

消息正文

status

enum

idle / working / awaiting / blocked

消息协议

Agent 通过 @ 机制接收消息:

  • @username - 仅该用户接收

  • @all - 所有用户接收

示例:

@alice 请帮我审查代码        # 仅 alice 接收
@all 会议即将开始            # 所有人接收

Agent 通过 agent_chat_watch 阻塞等待,只有匹配的消息才会唤醒。

测试

使用浏览器打开 tests/test_api.html,可视化测试所有 API 和 MCP 工具。

node server.mjs &
open tests/test_api.html

Available Tools

4 tools
agent_chat_helperC

Multi-purpose helper tool for various operations.

ParametersJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform.
queryNoSearch query (for action: search).
room_idNoRoom ID (for action: agents/history/search, optional).
limitNoMax records for action: history. Default 10.

TDQS

C2.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations are absent, placing full burden on the description. The description only says 'Multi-purpose helper tool for various operations,' which discloses no behavioral traits (e.g., side effects, auth needs, rate limits). The action list provides some context but the description itself is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise (one sentence), but conciseness comes at the cost of informativeness. It is front-loaded but lacks substance. It meets minimal structure requirements.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, 6 actions) and absence of output schema, the description is incomplete. It does not explain what each action returns, how to use them, or any constraints. More detail is needed for an agent to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with parameter descriptions. The tool description does not add meaning beyond the schema, but with high coverage, baseline 3 is appropriate. The description could clarify parameter relationships but does not.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description is vague: 'Multi-purpose helper tool for various operations.' It does not specify the core function or distinguish from sibling tools like agent_chat_register or agent_chat_send. The action enum hints at capabilities, but the description itself lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. There is no mention of prerequisites, context, or when to choose another tool. The description is generic and does not help the agent decide to invoke this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

agent_chat_registerC

Register as an agent in the chat room.

ParametersJSON Schema
NameRequiredDescriptionDefault
userYesAgent name.
roomYesRoom name.

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries full burden. It only states 'Register as an agent' without explaining side effects, idempotency, or what happens upon registration. The lack of details on the registration process limits transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that effectively front-loads the core purpose. It wastes no words, though it might benefit from slightly more detail without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple schema and no output schema, the description lacks sufficient context. It does not explain what 'register' means in the chat room context, such as whether it creates a user session or requires prior setup. The presence of sibling tools suggests a broader chat system, but the description leaves integration assumptions unclear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with clear parameter descriptions ('Agent name.', 'Room name.'). The tool description adds no additional semantic meaning beyond what the schema provides, resulting in a baseline score of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The verb 'Register' and resource 'agent in the chat room' clearly indicate the tool's function. It distinguishes from siblings (helper, send, watch) by specifying registration. However, it could be more explicit about whether registration creates a new agent or joins an existing chat.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like agent_chat_helper or agent_chat_send. The description does not mention prerequisites, such as whether the room must already exist, nor does it indicate if registration is required before using other tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

agent_chat_sendB

Send a chat message. To wake agents, text must include @username or @all.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesMessage body. Include @username or @all when you expect another agent to receive it.
statusYesAgent status: idle | working | awaiting | blocked.

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses the wake behavior but fails to mention important traits like whether the tool is idempotent, what side effects occur, or any required permissions. The description is minimal and leaves much to inference.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: two sentences, front-loaded with the primary action and a crucial condition. Every word earns its place with no unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite having 100% schema coverage, the description fails to explain the status parameter's role or any return behavior. With no output schema and no annotations, the description leaves the agent with insufficient context to use the tool effectively beyond the most basic send action.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds no new meaning beyond the schema's parameter descriptions; it repeats the wake condition already stated in the schema's text parameter description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Send a chat message', which is a specific verb+resource. However, it does not differentiate from sibling tools like agent_chat_helper or agent_chat_register, which could have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides a condition for waking agents ('text must include @username or @all'), giving some usage context. But it lacks explicit guidance on when not to use this tool or alternatives like agent_chat_watch.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

agent_chat_watchA

Block and wait for a new @username or @all message. Default wait time is 5 minutes.

ParametersJSON Schema
NameRequiredDescriptionDefault
timeout_msNoMax wait time in milliseconds. Default 5min.

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description must convey behavioral traits. It states it blocks and has a default wait time, but does not disclose error handling, cancellation, or return behavior, which is insufficient for a blocking tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two short, efficient sentences with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (1 param, no output schema), the description covers the primary purpose but omits important context like return value or blocking semantics, making it adequate but incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, and the description adds no meaning beyond the schema (timeout_ms with default). Baseline 3 applies as description does not compensate for missing schema details.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool blocks and waits for a new @username or @all message, with a specific verb and resource. It distinguishes itself from siblings (helper, register, send) by its waiting behavior.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for waiting on mentions but lacks explicit when-to-use or when-not-to-use guidance. No alternatives are mentioned, leaving the agent to infer context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

B3.1/5.0
Disambiguation3/5

The register, send, and watch tools have clear distinct purposes. However, agent_chat_helper is a vague 'multi-purpose' tool with no specific scope, potentially overlapping with the others.

Naming Consistency5/5

All tools follow a consistent 'agent_chat_<verb>' pattern (except 'helper' which is a noun, but it still adheres to the prefix and is understandable).

Tool Count5/5

Four tools is appropriate for a basic chat agent server, covering registration, sending, and watching for messages without unnecessary bloat.

Completeness3/5

The core messaging workflow is covered, but missing obvious operations like unregistering, listing agents, or leaving the chat room, which may hinder agent workflow.

Maintenance

ActivityInactive
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gitByEOS/agents-chat-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server