agent-chat-mcp 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mytsx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-chat-mcp
3
+ Version: 1.0.0
4
+ Summary: Agent Chat Room MCP server - Allows multiple Claude Code agents to communicate with each other
5
+ Author: mytsx
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mytsx/mcp-servers
8
+ Project-URL: Repository, https://github.com/mytsx/mcp-servers
9
+ Project-URL: Issues, https://github.com/mytsx/mcp-servers/issues
10
+ Keywords: mcp,model-context-protocol,agent,chat,multi-agent,claude
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: mcp[cli]>=1.0.0
19
+ Dynamic: license-file
20
+
21
+ # Agent Chat Room MCP Server
22
+
23
+ Birden fazla Claude Code agent'ının birbirleriyle iletişim kurmasını sağlayan MCP sunucusu. Dosya tabanlı paylaşımlı sohbet odası ile agent'lar mesaj gönderip alabilir.
24
+
25
+ ## Ozellikler
26
+
27
+ - **Multi-room destegi**: Agent'lar farkli odalarda calisabilir, config degistirmeden room parametresiyle gecis yapar
28
+ - Paylasimlı sohbet odası (dosya tabanlı, tüm agent'lar aynı odayı görür)
29
+ - Broadcast ve direct mesajlaşma
30
+ - Agent katılım/ayrılma takibi
31
+ - Mesaj önceliklendirme (urgent/normal/low)
32
+ - Stale agent temizleme (5 dk inaktif)
33
+ - Thread-safe dosya okuma/yazma (fcntl lock)
34
+ - Admin/manager için tüm mesajları okuma
35
+
36
+ ## Kurulum
37
+
38
+ ### Option 1: Using uvx (Recommended)
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "agent-chat": {
44
+ "command": "uvx",
45
+ "args": ["agent-chat-mcp"],
46
+ "env": {
47
+ "AGENT_CHAT_DIR": "/tmp/agent-chat-room",
48
+ "AGENT_CHAT_ROOM": "default"
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ ### Option 2: Install from Source
56
+
57
+ ```bash
58
+ cd agent-chat
59
+ pip install -e .
60
+ ```
61
+
62
+ ## Environment Variables
63
+
64
+ | Degisken | Varsayilan | Aciklama |
65
+ |----------|-----------|----------|
66
+ | `AGENT_CHAT_DIR` | `/tmp/agent-chat-room` | Mesaj ve agent verilerinin saklanacagi dizin |
67
+ | `AGENT_CHAT_ROOM` | `default` | Varsayilan oda adi (tool parametresiyle override edilebilir) |
68
+
69
+ ## Araclar (Tools)
70
+
71
+ ### `join_room`
72
+ Sohbet odasina katil. `room` parametresi ile farkli odalara katilinabilir.
73
+ ```json
74
+ {"agent_name": "backend", "role": "Backend API Developer", "room": "backend-team"}
75
+ ```
76
+
77
+ ### `send_message`
78
+ Mesaj gonder (broadcast veya direct).
79
+ ```json
80
+ {
81
+ "from_agent": "backend",
82
+ "content": "API endpoint'leri hazir",
83
+ "to_agent": "frontend",
84
+ "expects_reply": true,
85
+ "priority": "normal",
86
+ "room": "backend-team"
87
+ }
88
+ ```
89
+
90
+ ### `read_messages`
91
+ Yeni mesajlari oku.
92
+ ```json
93
+ {"agent_name": "frontend", "since_id": 5, "unread_only": true, "limit": 10, "room": ""}
94
+ ```
95
+
96
+ ### `list_agents`
97
+ Odadaki agent'lari listele.
98
+ ```json
99
+ {"agent_name": "backend", "room": "backend-team"}
100
+ ```
101
+
102
+ ### `leave_room`
103
+ Odadan ayril.
104
+ ```json
105
+ {"agent_name": "backend", "room": "backend-team"}
106
+ ```
107
+
108
+ ### `read_all_messages`
109
+ Tum mesajlari oku (admin/manager icin).
110
+ ```json
111
+ {"since_id": 0, "limit": 15, "room": ""}
112
+ ```
113
+
114
+ ### `get_last_message_id`
115
+ Son mesaj ID'sini al (polling icin).
116
+ ```json
117
+ {"agent_name": "backend", "room": ""}
118
+ ```
119
+
120
+ ### `list_rooms`
121
+ Mevcut odalari ve agent/mesaj sayilarini listele.
122
+ ```json
123
+ {}
124
+ ```
125
+
126
+ ### `clear_room`
127
+ Odayi temizle (tum mesajlar ve agent kayitlari silinir).
128
+ ```json
129
+ {"room": "backend-team"}
130
+ ```
131
+
132
+ ## Kullanim Senaryosu
133
+
134
+ ### Multi-Agent Gelistirme (Tek Oda)
135
+
136
+ 3 farkli Claude Code instance'i (terminal) acin:
137
+
138
+ **Terminal 1 - Backend Agent:**
139
+ ```
140
+ join_room agent_name="backend" role="Backend API Developer"
141
+ send_message from_agent="backend" content="REST API endpointleri hazir, /api/users ve /api/posts"
142
+ ```
143
+
144
+ **Terminal 2 - Frontend Agent:**
145
+ ```
146
+ join_room agent_name="frontend" role="Frontend React Developer"
147
+ read_messages agent_name="frontend"
148
+ send_message from_agent="frontend" to_agent="backend" content="users endpoint'inde pagination var mi?"
149
+ ```
150
+
151
+ **Terminal 3 - Manager Agent:**
152
+ ```
153
+ join_room agent_name="manager" role="Project Manager"
154
+ read_all_messages
155
+ ```
156
+
157
+ ### Multi-Room Kullanimi
158
+
159
+ Agent'lar MCP config'i degistirmeden farkli odalara gecis yapabilir:
160
+
161
+ ```
162
+ # Varsayilan odaya katil
163
+ join_room agent_name="backend" role="Backend Dev"
164
+
165
+ # Farkli bir odaya da katil
166
+ join_room agent_name="backend" role="Backend Dev" room="design-review"
167
+
168
+ # Farkli odalara mesaj gonder
169
+ send_message from_agent="backend" content="API hazir" room="default"
170
+ send_message from_agent="backend" content="UI feedback'im var" room="design-review"
171
+
172
+ # Mevcut odalari listele
173
+ list_rooms
174
+ ```
175
+
176
+ ## Nasil Calisiyor
177
+
178
+ - Her oda `AGENT_CHAT_DIR/<room_name>/` altinda ayri dizinde saklanir
179
+ - Her odanin kendi `messages.json` ve `agents.json` dosyasi vardir
180
+ - `room` parametresi bos birakilirsa `AGENT_CHAT_ROOM` env degeri kullanilir (varsayilan: `default`)
181
+ - `fcntl` file locking ile thread-safe okuma/yazma
182
+ - 5 dakika inaktif agent'lar otomatik temizlenir
183
+ - `expects_reply: false` ile sonsuz mesaj dongusu onlenir
184
+
185
+ ## License
186
+
187
+ MIT
@@ -0,0 +1,167 @@
1
+ # Agent Chat Room MCP Server
2
+
3
+ Birden fazla Claude Code agent'ının birbirleriyle iletişim kurmasını sağlayan MCP sunucusu. Dosya tabanlı paylaşımlı sohbet odası ile agent'lar mesaj gönderip alabilir.
4
+
5
+ ## Ozellikler
6
+
7
+ - **Multi-room destegi**: Agent'lar farkli odalarda calisabilir, config degistirmeden room parametresiyle gecis yapar
8
+ - Paylasimlı sohbet odası (dosya tabanlı, tüm agent'lar aynı odayı görür)
9
+ - Broadcast ve direct mesajlaşma
10
+ - Agent katılım/ayrılma takibi
11
+ - Mesaj önceliklendirme (urgent/normal/low)
12
+ - Stale agent temizleme (5 dk inaktif)
13
+ - Thread-safe dosya okuma/yazma (fcntl lock)
14
+ - Admin/manager için tüm mesajları okuma
15
+
16
+ ## Kurulum
17
+
18
+ ### Option 1: Using uvx (Recommended)
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "agent-chat": {
24
+ "command": "uvx",
25
+ "args": ["agent-chat-mcp"],
26
+ "env": {
27
+ "AGENT_CHAT_DIR": "/tmp/agent-chat-room",
28
+ "AGENT_CHAT_ROOM": "default"
29
+ }
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ ### Option 2: Install from Source
36
+
37
+ ```bash
38
+ cd agent-chat
39
+ pip install -e .
40
+ ```
41
+
42
+ ## Environment Variables
43
+
44
+ | Degisken | Varsayilan | Aciklama |
45
+ |----------|-----------|----------|
46
+ | `AGENT_CHAT_DIR` | `/tmp/agent-chat-room` | Mesaj ve agent verilerinin saklanacagi dizin |
47
+ | `AGENT_CHAT_ROOM` | `default` | Varsayilan oda adi (tool parametresiyle override edilebilir) |
48
+
49
+ ## Araclar (Tools)
50
+
51
+ ### `join_room`
52
+ Sohbet odasina katil. `room` parametresi ile farkli odalara katilinabilir.
53
+ ```json
54
+ {"agent_name": "backend", "role": "Backend API Developer", "room": "backend-team"}
55
+ ```
56
+
57
+ ### `send_message`
58
+ Mesaj gonder (broadcast veya direct).
59
+ ```json
60
+ {
61
+ "from_agent": "backend",
62
+ "content": "API endpoint'leri hazir",
63
+ "to_agent": "frontend",
64
+ "expects_reply": true,
65
+ "priority": "normal",
66
+ "room": "backend-team"
67
+ }
68
+ ```
69
+
70
+ ### `read_messages`
71
+ Yeni mesajlari oku.
72
+ ```json
73
+ {"agent_name": "frontend", "since_id": 5, "unread_only": true, "limit": 10, "room": ""}
74
+ ```
75
+
76
+ ### `list_agents`
77
+ Odadaki agent'lari listele.
78
+ ```json
79
+ {"agent_name": "backend", "room": "backend-team"}
80
+ ```
81
+
82
+ ### `leave_room`
83
+ Odadan ayril.
84
+ ```json
85
+ {"agent_name": "backend", "room": "backend-team"}
86
+ ```
87
+
88
+ ### `read_all_messages`
89
+ Tum mesajlari oku (admin/manager icin).
90
+ ```json
91
+ {"since_id": 0, "limit": 15, "room": ""}
92
+ ```
93
+
94
+ ### `get_last_message_id`
95
+ Son mesaj ID'sini al (polling icin).
96
+ ```json
97
+ {"agent_name": "backend", "room": ""}
98
+ ```
99
+
100
+ ### `list_rooms`
101
+ Mevcut odalari ve agent/mesaj sayilarini listele.
102
+ ```json
103
+ {}
104
+ ```
105
+
106
+ ### `clear_room`
107
+ Odayi temizle (tum mesajlar ve agent kayitlari silinir).
108
+ ```json
109
+ {"room": "backend-team"}
110
+ ```
111
+
112
+ ## Kullanim Senaryosu
113
+
114
+ ### Multi-Agent Gelistirme (Tek Oda)
115
+
116
+ 3 farkli Claude Code instance'i (terminal) acin:
117
+
118
+ **Terminal 1 - Backend Agent:**
119
+ ```
120
+ join_room agent_name="backend" role="Backend API Developer"
121
+ send_message from_agent="backend" content="REST API endpointleri hazir, /api/users ve /api/posts"
122
+ ```
123
+
124
+ **Terminal 2 - Frontend Agent:**
125
+ ```
126
+ join_room agent_name="frontend" role="Frontend React Developer"
127
+ read_messages agent_name="frontend"
128
+ send_message from_agent="frontend" to_agent="backend" content="users endpoint'inde pagination var mi?"
129
+ ```
130
+
131
+ **Terminal 3 - Manager Agent:**
132
+ ```
133
+ join_room agent_name="manager" role="Project Manager"
134
+ read_all_messages
135
+ ```
136
+
137
+ ### Multi-Room Kullanimi
138
+
139
+ Agent'lar MCP config'i degistirmeden farkli odalara gecis yapabilir:
140
+
141
+ ```
142
+ # Varsayilan odaya katil
143
+ join_room agent_name="backend" role="Backend Dev"
144
+
145
+ # Farkli bir odaya da katil
146
+ join_room agent_name="backend" role="Backend Dev" room="design-review"
147
+
148
+ # Farkli odalara mesaj gonder
149
+ send_message from_agent="backend" content="API hazir" room="default"
150
+ send_message from_agent="backend" content="UI feedback'im var" room="design-review"
151
+
152
+ # Mevcut odalari listele
153
+ list_rooms
154
+ ```
155
+
156
+ ## Nasil Calisiyor
157
+
158
+ - Her oda `AGENT_CHAT_DIR/<room_name>/` altinda ayri dizinde saklanir
159
+ - Her odanin kendi `messages.json` ve `agents.json` dosyasi vardir
160
+ - `room` parametresi bos birakilirsa `AGENT_CHAT_ROOM` env degeri kullanilir (varsayilan: `default`)
161
+ - `fcntl` file locking ile thread-safe okuma/yazma
162
+ - 5 dakika inaktif agent'lar otomatik temizlenir
163
+ - `expects_reply: false` ile sonsuz mesaj dongusu onlenir
164
+
165
+ ## License
166
+
167
+ MIT
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-chat-mcp"
7
+ version = "1.0.0"
8
+ description = "Agent Chat Room MCP server - Allows multiple Claude Code agents to communicate with each other"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "mytsx"}
14
+ ]
15
+ keywords = ["mcp", "model-context-protocol", "agent", "chat", "multi-agent", "claude"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ ]
22
+ dependencies = [
23
+ "mcp[cli]>=1.0.0",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/mytsx/mcp-servers"
28
+ Repository = "https://github.com/mytsx/mcp-servers"
29
+ Issues = "https://github.com/mytsx/mcp-servers/issues"
30
+
31
+ [project.scripts]
32
+ agent-chat-mcp = "agent_chat_mcp.__main__:run"
33
+
34
+ [tool.setuptools]
35
+ packages = ["agent_chat_mcp"]
36
+ package-dir = {"" = "src"}
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ """
2
+ Agent Chat Room MCP Server
3
+ Allows multiple Claude Code agents to communicate with each other.
4
+ """
5
+
6
+ __version__ = "1.0.0"
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Entry point for Agent Chat Room MCP Server
4
+ Usage: uvx agent-chat-mcp | python -m agent_chat_mcp
5
+ """
6
+
7
+ from .server import mcp
8
+
9
+
10
+ def run():
11
+ """Synchronous entry point"""
12
+ mcp.run()
13
+
14
+
15
+ if __name__ == "__main__":
16
+ run()
@@ -0,0 +1,403 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Agent Chat Room MCP Server
4
+ Allows multiple Claude Code agents to communicate with each other.
5
+ """
6
+
7
+ import json
8
+ import os
9
+ import time
10
+ import fcntl
11
+ from datetime import datetime
12
+ from pathlib import Path
13
+ from mcp.server.fastmcp import FastMCP
14
+
15
+ # Chat data directory - shared between all instances
16
+ CHAT_DIR = Path(os.environ.get("AGENT_CHAT_DIR", "/tmp/agent-chat-room"))
17
+ DEFAULT_ROOM = os.environ.get("AGENT_CHAT_ROOM", "default")
18
+
19
+ # Ensure base directory exists
20
+ CHAT_DIR.mkdir(parents=True, exist_ok=True)
21
+
22
+ mcp = FastMCP("agent-chat")
23
+
24
+ def _get_room_dir(room: str = "") -> Path:
25
+ """Get room directory, creating it if needed."""
26
+ room_name = room if room else DEFAULT_ROOM
27
+ room_dir = CHAT_DIR / room_name
28
+ room_dir.mkdir(parents=True, exist_ok=True)
29
+ return room_dir
30
+
31
+ def _read_json(filepath: Path, default: dict | list) -> dict | list:
32
+ """Thread-safe JSON file reading."""
33
+ if not filepath.exists():
34
+ return default
35
+ try:
36
+ with open(filepath, "r") as f:
37
+ fcntl.flock(f.fileno(), fcntl.LOCK_SH)
38
+ content = f.read()
39
+ fcntl.flock(f.fileno(), fcntl.LOCK_UN)
40
+ return json.loads(content) if content else default
41
+ except (json.JSONDecodeError, IOError):
42
+ return default
43
+
44
+ def _write_json(filepath: Path, data: dict | list) -> None:
45
+ """Thread-safe JSON file writing."""
46
+ with open(filepath, "w") as f:
47
+ fcntl.flock(f.fileno(), fcntl.LOCK_EX)
48
+ json.dump(data, f, indent=2, ensure_ascii=False)
49
+ fcntl.flock(f.fileno(), fcntl.LOCK_UN)
50
+
51
+ def _get_agents(room: str = "") -> dict:
52
+ """Get active agents for a room."""
53
+ return _read_json(_get_room_dir(room) / "agents.json", {})
54
+
55
+ def _save_agents(agents: dict, room: str = "") -> None:
56
+ """Save agents for a room."""
57
+ _write_json(_get_room_dir(room) / "agents.json", agents)
58
+
59
+ def _get_messages(room: str = "") -> list:
60
+ """Get all messages for a room."""
61
+ return _read_json(_get_room_dir(room) / "messages.json", [])
62
+
63
+ def _save_messages(messages: list, room: str = "") -> None:
64
+ """Save messages for a room."""
65
+ _write_json(_get_room_dir(room) / "messages.json", messages)
66
+
67
+ def _cleanup_stale_agents(agents: dict, timeout: int = 300) -> dict:
68
+ """Remove agents that haven't been active for `timeout` seconds."""
69
+ now = time.time()
70
+ return {name: info for name, info in agents.items()
71
+ if now - info.get("last_seen", 0) < timeout}
72
+
73
+ @mcp.tool()
74
+ def join_room(agent_name: str, role: str = "", room: str = "") -> str:
75
+ """
76
+ Join the chat room with a unique name.
77
+
78
+ Args:
79
+ agent_name: Unique name for this agent (e.g., "backend", "frontend", "mobile")
80
+ role: Optional role description (e.g., "Backend API Developer")
81
+ room: Room name (empty = default room from AGENT_CHAT_ROOM env or "default")
82
+
83
+ Returns:
84
+ Confirmation message with list of other agents in the room
85
+ """
86
+ agents = _get_agents(room)
87
+ agents = _cleanup_stale_agents(agents)
88
+
89
+ agents[agent_name] = {
90
+ "role": role,
91
+ "joined_at": datetime.now().isoformat(),
92
+ "last_seen": time.time()
93
+ }
94
+ _save_agents(agents, room)
95
+
96
+ other_agents = [name for name in agents.keys() if name != agent_name]
97
+
98
+ # Add system message about joining
99
+ messages = _get_messages(room)
100
+ messages.append({
101
+ "id": len(messages) + 1,
102
+ "from": "SYSTEM",
103
+ "to": "all",
104
+ "content": f"\U0001f7e2 {agent_name} odaya katıldı" + (f" (Rol: {role})" if role else ""),
105
+ "timestamp": datetime.now().isoformat(),
106
+ "type": "system"
107
+ })
108
+ _save_messages(messages, room)
109
+
110
+ room_label = room if room else DEFAULT_ROOM
111
+ if other_agents:
112
+ return f"\u2705 '{agent_name}' olarak '{room_label}' odasına katıldın. Odadaki diğer agent'lar: {', '.join(other_agents)}"
113
+ return f"\u2705 '{agent_name}' olarak '{room_label}' odasına katıldın. Şu an odada başka agent yok."
114
+
115
+ @mcp.tool()
116
+ def send_message(
117
+ from_agent: str,
118
+ content: str,
119
+ to_agent: str = "all",
120
+ expects_reply: bool = True,
121
+ priority: str = "normal",
122
+ room: str = ""
123
+ ) -> str:
124
+ """
125
+ Send a message to other agents.
126
+
127
+ Args:
128
+ from_agent: Your agent name
129
+ content: Message content
130
+ to_agent: Target agent name or "all" for broadcast (default: "all")
131
+ expects_reply: Set False for acknowledgments/thanks to prevent infinite loops (default: True)
132
+ priority: "urgent", "normal", or "low" (default: "normal")
133
+ room: Room name (empty = default room)
134
+
135
+ Returns:
136
+ Confirmation that message was sent
137
+ """
138
+ # Update last_seen
139
+ agents = _get_agents(room)
140
+ if from_agent in agents:
141
+ agents[from_agent]["last_seen"] = time.time()
142
+ _save_agents(agents, room)
143
+
144
+ messages = _get_messages(room)
145
+ message = {
146
+ "id": len(messages) + 1,
147
+ "from": from_agent,
148
+ "to": to_agent,
149
+ "content": content,
150
+ "timestamp": datetime.now().isoformat(),
151
+ "type": "direct" if to_agent != "all" else "broadcast",
152
+ "expects_reply": expects_reply,
153
+ "priority": priority
154
+ }
155
+ messages.append(message)
156
+ _save_messages(messages, room)
157
+
158
+ if to_agent == "all":
159
+ return f"\U0001f4e4 Mesaj tüm agent'lara gönderildi (ID: {message['id']})"
160
+ return f"\U0001f4e4 Mesaj '{to_agent}' agent'ına gönderildi (ID: {message['id']})"
161
+
162
+ @mcp.tool()
163
+ def read_messages(agent_name: str, since_id: int = 0, unread_only: bool = True, limit: int = 10, room: str = "") -> str:
164
+ """
165
+ Read messages from the chat room.
166
+
167
+ Args:
168
+ agent_name: Your agent name (to filter relevant messages)
169
+ since_id: Only get messages after this ID (default: 0 for all)
170
+ unread_only: If True, only show messages not from yourself (default: True)
171
+ limit: Maximum number of messages to return (default: 10, 0 for unlimited)
172
+ room: Room name (empty = default room)
173
+
174
+ Returns:
175
+ List of messages formatted for reading
176
+ """
177
+ # Update last_seen
178
+ agents = _get_agents(room)
179
+ if agent_name in agents:
180
+ agents[agent_name]["last_seen"] = time.time()
181
+ _save_agents(agents, room)
182
+
183
+ messages = _get_messages(room)
184
+
185
+ # Filter messages
186
+ filtered = []
187
+ for msg in messages:
188
+ if msg["id"] <= since_id:
189
+ continue
190
+ if unread_only and msg["from"] == agent_name:
191
+ continue
192
+ # Include if broadcast, direct to this agent, or system message
193
+ if msg["to"] == "all" or msg["to"] == agent_name or msg["type"] == "system":
194
+ filtered.append(msg)
195
+
196
+ if not filtered:
197
+ return "\U0001f4ed Yeni mesaj yok."
198
+
199
+ total_count = len(filtered)
200
+
201
+ # Apply limit (get last N messages)
202
+ if limit > 0 and len(filtered) > limit:
203
+ filtered = filtered[-limit:]
204
+ result = f"\U0001f4ec Son {limit} mesaj (toplam {total_count}):\n\n"
205
+ else:
206
+ result = f"\U0001f4ec {len(filtered)} mesaj:\n\n"
207
+
208
+ for msg in filtered:
209
+ timestamp = datetime.fromisoformat(msg["timestamp"]).strftime('%H:%M:%S') # HH:MM:SS
210
+ if msg["type"] == "system":
211
+ result += f"[{timestamp}] {msg['content']}\n"
212
+ elif msg["to"] == "all":
213
+ result += f"[{timestamp}] {msg['from']} \u2192 HERKESE: {msg['content']}\n"
214
+ else:
215
+ result += f"[{timestamp}] {msg['from']} \u2192 {msg['to']}: {msg['content']}\n"
216
+ result += f" (ID: {msg['id']})\n\n"
217
+
218
+ return result
219
+
220
+ @mcp.tool()
221
+ def list_agents(agent_name: str = "", room: str = "") -> str:
222
+ """
223
+ List all agents currently in the chat room.
224
+
225
+ Args:
226
+ agent_name: Your agent name (optional, for updating last_seen)
227
+ room: Room name (empty = default room)
228
+
229
+ Returns:
230
+ List of active agents with their roles
231
+ """
232
+ agents = _get_agents(room)
233
+ agents = _cleanup_stale_agents(agents)
234
+ _save_agents(agents, room)
235
+
236
+ if agent_name and agent_name in agents:
237
+ agents[agent_name]["last_seen"] = time.time()
238
+ _save_agents(agents, room)
239
+
240
+ if not agents:
241
+ return "\U0001f465 Odada kimse yok."
242
+
243
+ room_label = room if room else DEFAULT_ROOM
244
+ result = f"\U0001f465 '{room_label}' odasındaki agent'lar ({len(agents)}):\n\n"
245
+ for name, info in agents.items():
246
+ role = info.get("role", "")
247
+ joined = info.get("joined_at", "").split("T")[0]
248
+ marker = " (sen)" if name == agent_name else ""
249
+ result += f" \u2022 {name}{marker}"
250
+ if role:
251
+ result += f" - {role}"
252
+ result += f"\n Katılım: {joined}\n"
253
+
254
+ return result
255
+
256
+ @mcp.tool()
257
+ def leave_room(agent_name: str, room: str = "") -> str:
258
+ """
259
+ Leave the chat room.
260
+
261
+ Args:
262
+ agent_name: Your agent name
263
+ room: Room name (empty = default room)
264
+
265
+ Returns:
266
+ Confirmation message
267
+ """
268
+ agents = _get_agents(room)
269
+
270
+ if agent_name not in agents:
271
+ return f"\u26a0\ufe0f '{agent_name}' zaten odada değil."
272
+
273
+ del agents[agent_name]
274
+ _save_agents(agents, room)
275
+
276
+ # Add system message about leaving
277
+ messages = _get_messages(room)
278
+ messages.append({
279
+ "id": len(messages) + 1,
280
+ "from": "SYSTEM",
281
+ "to": "all",
282
+ "content": f"\U0001f534 {agent_name} odadan ayrıldı",
283
+ "timestamp": datetime.now().isoformat(),
284
+ "type": "system"
285
+ })
286
+ _save_messages(messages, room)
287
+
288
+ return f"\U0001f44b '{agent_name}' odadan ayrıldı."
289
+
290
+ @mcp.tool()
291
+ def clear_room(room: str = "") -> str:
292
+ """
293
+ Clear all messages and agents from the room. Use with caution!
294
+
295
+ Args:
296
+ room: Room name (empty = default room)
297
+
298
+ Returns:
299
+ Confirmation message
300
+ """
301
+ room_dir = _get_room_dir(room)
302
+ _write_json(room_dir / "messages.json", [])
303
+ _write_json(room_dir / "agents.json", {})
304
+ room_label = room if room else DEFAULT_ROOM
305
+ return f"\U0001f9f9 '{room_label}' odası temizlendi. Tüm mesajlar ve agent kayıtları silindi."
306
+
307
+ @mcp.tool()
308
+ def read_all_messages(since_id: int = 0, limit: int = 15, room: str = "") -> str:
309
+ """
310
+ Read ALL messages in the chat room (for manager/admin use).
311
+
312
+ Args:
313
+ since_id: Only get messages after this ID (default: 0 for all)
314
+ limit: Maximum number of messages to return (default: 15, 0 for unlimited)
315
+ room: Room name (empty = default room)
316
+
317
+ Returns:
318
+ List of all messages formatted for reading
319
+ """
320
+ messages = _get_messages(room)
321
+
322
+ filtered = [m for m in messages if m["id"] > since_id]
323
+
324
+ if not filtered:
325
+ return "\U0001f4ed Yeni mesaj yok."
326
+
327
+ total_count = len(filtered)
328
+
329
+ # Apply limit (get last N messages)
330
+ if limit > 0 and len(filtered) > limit:
331
+ filtered = filtered[-limit:]
332
+ result = f"\U0001f4ec Son {limit} mesaj (toplam {total_count}):\n\n"
333
+ else:
334
+ result = f"\U0001f4ec {len(filtered)} mesaj (tümü):\n\n"
335
+
336
+ for msg in filtered:
337
+ timestamp = datetime.fromisoformat(msg["timestamp"]).strftime('%H:%M:%S')
338
+ msg_type = msg.get("type", "direct")
339
+
340
+ if msg_type == "system":
341
+ result += f"[{timestamp}] SYSTEM: {msg['content']}\n"
342
+ else:
343
+ result += f"[{timestamp}] #{msg['id']} {msg['from']} \u2192 {msg['to']}: {msg['content'][:100]}\n"
344
+ result += "\n"
345
+
346
+ return result
347
+
348
+ @mcp.tool()
349
+ def get_last_message_id(agent_name: str = "", room: str = "") -> int:
350
+ """
351
+ Get the ID of the last message. Useful for polling new messages.
352
+
353
+ Args:
354
+ agent_name: Your agent name (optional, for updating last_seen)
355
+ room: Room name (empty = default room)
356
+
357
+ Returns:
358
+ The ID of the last message, or 0 if no messages
359
+ """
360
+ if agent_name:
361
+ agents = _get_agents(room)
362
+ if agent_name in agents:
363
+ agents[agent_name]["last_seen"] = time.time()
364
+ _save_agents(agents, room)
365
+
366
+ messages = _get_messages(room)
367
+ return messages[-1]["id"] if messages else 0
368
+
369
+ @mcp.tool()
370
+ def list_rooms() -> str:
371
+ """
372
+ List all available chat rooms.
373
+
374
+ Returns:
375
+ List of rooms with agent counts
376
+ """
377
+ if not CHAT_DIR.exists():
378
+ return "\U0001f4ad Henüz hiç oda yok."
379
+
380
+ rooms = []
381
+ for item in sorted(CHAT_DIR.iterdir()):
382
+ if item.is_dir():
383
+ agents = _read_json(item / "agents.json", {})
384
+ agents = _cleanup_stale_agents(agents)
385
+ messages = _read_json(item / "messages.json", [])
386
+ rooms.append({
387
+ "name": item.name,
388
+ "agents": len(agents),
389
+ "messages": len(messages)
390
+ })
391
+
392
+ if not rooms:
393
+ return "\U0001f4ad Henüz hiç oda yok."
394
+
395
+ result = f"\U0001f3e0 Mevcut odalar ({len(rooms)}):\n\n"
396
+ for r in rooms:
397
+ default_marker = " (varsayılan)" if r["name"] == DEFAULT_ROOM else ""
398
+ result += f" \u2022 {r['name']}{default_marker} - {r['agents']} agent, {r['messages']} mesaj\n"
399
+
400
+ return result
401
+
402
+ if __name__ == "__main__":
403
+ mcp.run()
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-chat-mcp
3
+ Version: 1.0.0
4
+ Summary: Agent Chat Room MCP server - Allows multiple Claude Code agents to communicate with each other
5
+ Author: mytsx
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mytsx/mcp-servers
8
+ Project-URL: Repository, https://github.com/mytsx/mcp-servers
9
+ Project-URL: Issues, https://github.com/mytsx/mcp-servers/issues
10
+ Keywords: mcp,model-context-protocol,agent,chat,multi-agent,claude
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: mcp[cli]>=1.0.0
19
+ Dynamic: license-file
20
+
21
+ # Agent Chat Room MCP Server
22
+
23
+ Birden fazla Claude Code agent'ının birbirleriyle iletişim kurmasını sağlayan MCP sunucusu. Dosya tabanlı paylaşımlı sohbet odası ile agent'lar mesaj gönderip alabilir.
24
+
25
+ ## Ozellikler
26
+
27
+ - **Multi-room destegi**: Agent'lar farkli odalarda calisabilir, config degistirmeden room parametresiyle gecis yapar
28
+ - Paylasimlı sohbet odası (dosya tabanlı, tüm agent'lar aynı odayı görür)
29
+ - Broadcast ve direct mesajlaşma
30
+ - Agent katılım/ayrılma takibi
31
+ - Mesaj önceliklendirme (urgent/normal/low)
32
+ - Stale agent temizleme (5 dk inaktif)
33
+ - Thread-safe dosya okuma/yazma (fcntl lock)
34
+ - Admin/manager için tüm mesajları okuma
35
+
36
+ ## Kurulum
37
+
38
+ ### Option 1: Using uvx (Recommended)
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "agent-chat": {
44
+ "command": "uvx",
45
+ "args": ["agent-chat-mcp"],
46
+ "env": {
47
+ "AGENT_CHAT_DIR": "/tmp/agent-chat-room",
48
+ "AGENT_CHAT_ROOM": "default"
49
+ }
50
+ }
51
+ }
52
+ }
53
+ ```
54
+
55
+ ### Option 2: Install from Source
56
+
57
+ ```bash
58
+ cd agent-chat
59
+ pip install -e .
60
+ ```
61
+
62
+ ## Environment Variables
63
+
64
+ | Degisken | Varsayilan | Aciklama |
65
+ |----------|-----------|----------|
66
+ | `AGENT_CHAT_DIR` | `/tmp/agent-chat-room` | Mesaj ve agent verilerinin saklanacagi dizin |
67
+ | `AGENT_CHAT_ROOM` | `default` | Varsayilan oda adi (tool parametresiyle override edilebilir) |
68
+
69
+ ## Araclar (Tools)
70
+
71
+ ### `join_room`
72
+ Sohbet odasina katil. `room` parametresi ile farkli odalara katilinabilir.
73
+ ```json
74
+ {"agent_name": "backend", "role": "Backend API Developer", "room": "backend-team"}
75
+ ```
76
+
77
+ ### `send_message`
78
+ Mesaj gonder (broadcast veya direct).
79
+ ```json
80
+ {
81
+ "from_agent": "backend",
82
+ "content": "API endpoint'leri hazir",
83
+ "to_agent": "frontend",
84
+ "expects_reply": true,
85
+ "priority": "normal",
86
+ "room": "backend-team"
87
+ }
88
+ ```
89
+
90
+ ### `read_messages`
91
+ Yeni mesajlari oku.
92
+ ```json
93
+ {"agent_name": "frontend", "since_id": 5, "unread_only": true, "limit": 10, "room": ""}
94
+ ```
95
+
96
+ ### `list_agents`
97
+ Odadaki agent'lari listele.
98
+ ```json
99
+ {"agent_name": "backend", "room": "backend-team"}
100
+ ```
101
+
102
+ ### `leave_room`
103
+ Odadan ayril.
104
+ ```json
105
+ {"agent_name": "backend", "room": "backend-team"}
106
+ ```
107
+
108
+ ### `read_all_messages`
109
+ Tum mesajlari oku (admin/manager icin).
110
+ ```json
111
+ {"since_id": 0, "limit": 15, "room": ""}
112
+ ```
113
+
114
+ ### `get_last_message_id`
115
+ Son mesaj ID'sini al (polling icin).
116
+ ```json
117
+ {"agent_name": "backend", "room": ""}
118
+ ```
119
+
120
+ ### `list_rooms`
121
+ Mevcut odalari ve agent/mesaj sayilarini listele.
122
+ ```json
123
+ {}
124
+ ```
125
+
126
+ ### `clear_room`
127
+ Odayi temizle (tum mesajlar ve agent kayitlari silinir).
128
+ ```json
129
+ {"room": "backend-team"}
130
+ ```
131
+
132
+ ## Kullanim Senaryosu
133
+
134
+ ### Multi-Agent Gelistirme (Tek Oda)
135
+
136
+ 3 farkli Claude Code instance'i (terminal) acin:
137
+
138
+ **Terminal 1 - Backend Agent:**
139
+ ```
140
+ join_room agent_name="backend" role="Backend API Developer"
141
+ send_message from_agent="backend" content="REST API endpointleri hazir, /api/users ve /api/posts"
142
+ ```
143
+
144
+ **Terminal 2 - Frontend Agent:**
145
+ ```
146
+ join_room agent_name="frontend" role="Frontend React Developer"
147
+ read_messages agent_name="frontend"
148
+ send_message from_agent="frontend" to_agent="backend" content="users endpoint'inde pagination var mi?"
149
+ ```
150
+
151
+ **Terminal 3 - Manager Agent:**
152
+ ```
153
+ join_room agent_name="manager" role="Project Manager"
154
+ read_all_messages
155
+ ```
156
+
157
+ ### Multi-Room Kullanimi
158
+
159
+ Agent'lar MCP config'i degistirmeden farkli odalara gecis yapabilir:
160
+
161
+ ```
162
+ # Varsayilan odaya katil
163
+ join_room agent_name="backend" role="Backend Dev"
164
+
165
+ # Farkli bir odaya da katil
166
+ join_room agent_name="backend" role="Backend Dev" room="design-review"
167
+
168
+ # Farkli odalara mesaj gonder
169
+ send_message from_agent="backend" content="API hazir" room="default"
170
+ send_message from_agent="backend" content="UI feedback'im var" room="design-review"
171
+
172
+ # Mevcut odalari listele
173
+ list_rooms
174
+ ```
175
+
176
+ ## Nasil Calisiyor
177
+
178
+ - Her oda `AGENT_CHAT_DIR/<room_name>/` altinda ayri dizinde saklanir
179
+ - Her odanin kendi `messages.json` ve `agents.json` dosyasi vardir
180
+ - `room` parametresi bos birakilirsa `AGENT_CHAT_ROOM` env degeri kullanilir (varsayilan: `default`)
181
+ - `fcntl` file locking ile thread-safe okuma/yazma
182
+ - 5 dakika inaktif agent'lar otomatik temizlenir
183
+ - `expects_reply: false` ile sonsuz mesaj dongusu onlenir
184
+
185
+ ## License
186
+
187
+ MIT
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/agent_chat_mcp/__init__.py
5
+ src/agent_chat_mcp/__main__.py
6
+ src/agent_chat_mcp/server.py
7
+ src/agent_chat_mcp.egg-info/PKG-INFO
8
+ src/agent_chat_mcp.egg-info/SOURCES.txt
9
+ src/agent_chat_mcp.egg-info/dependency_links.txt
10
+ src/agent_chat_mcp.egg-info/entry_points.txt
11
+ src/agent_chat_mcp.egg-info/requires.txt
12
+ src/agent_chat_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agent-chat-mcp = agent_chat_mcp.__main__:run
@@ -0,0 +1 @@
1
+ mcp[cli]>=1.0.0
@@ -0,0 +1 @@
1
+ agent_chat_mcp