Skip to content

Commit 13aa44f

Browse files
authored
Merge pull request #12 from redhat-ai-tools/revert-11-mcp-python-sdk
Revert "switch from fastmcp to mcp"
2 parents 6d88154 + 50c39af commit 13aa44f

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
httpx==0.28.1
2-
mcp==1.10.1
2+
fastmcp==2.8.0

slack_mcp_server.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
from typing import Any
33
import httpx
44
from mcp.server.fastmcp import FastMCP
5-
import asyncio
6-
from starlette.responses import PlainTextResponse
75

86
SLACK_API_BASE = "https://slack.com/api"
97
MCP_TRANSPORT = os.environ.get("MCP_TRANSPORT", "stdio")
@@ -13,16 +11,6 @@
1311
"slack", settings={"host": "127.0.0.1" if MCP_TRANSPORT == "stdio" else "0.0.0.0"}
1412
)
1513

16-
# Global metrics store
17-
metrics = {
18-
'get_channel_history_total': 0,
19-
'post_message_total': 0,
20-
'post_command_total': 0,
21-
'add_reaction_total': 0,
22-
'whoami_total': 0,
23-
'join_channel_total': 0,
24-
}
25-
metrics_lock = asyncio.Lock()
2614

2715
async def make_request(
2816
url: str, payload: dict[str, Any] | None = None
@@ -61,8 +49,6 @@ async def log_to_slack(message: str):
6149
@mcp.tool()
6250
async def get_channel_history(channel_id: str) -> str:
6351
"""Get the history of a channel."""
64-
async with metrics_lock:
65-
metrics['get_channel_history_total'] += 1
6652
await log_to_slack(f"Getting history of channel <#{channel_id}>")
6753
url = f"{SLACK_API_BASE}/conversations.history"
6854
payload = {"channel": channel_id}
@@ -76,8 +62,6 @@ async def post_message(
7662
channel_id: str, message: str, thread_ts: str = "", skip_log: bool = False
7763
) -> str:
7864
"""Post a message to a channel."""
79-
async with metrics_lock:
80-
metrics['post_message_total'] += 1
8165
if not skip_log:
8266
await log_to_slack(f"Posting message to channel <#{channel_id}>: {message}")
8367
await join_channel(channel_id, skip_log=skip_log)
@@ -94,8 +78,6 @@ async def post_command(
9478
channel_id: str, command: str, text: str, skip_log: bool = False
9579
) -> str:
9680
"""Post a command to a channel."""
97-
async with metrics_lock:
98-
metrics['post_command_total'] += 1
9981
if not skip_log:
10082
await log_to_slack(
10183
f"Posting command to channel <#{channel_id}>: {command} {text}"
@@ -110,8 +92,6 @@ async def post_command(
11092
@mcp.tool()
11193
async def add_reaction(channel_id: str, message_ts: str, reaction: str) -> str:
11294
"""Add a reaction to a message."""
113-
async with metrics_lock:
114-
metrics['add_reaction_total'] += 1
11595
await log_to_slack(
11696
f"Adding reaction to message {message_ts} in channel <#{channel_id}>: :{reaction}:"
11797
)
@@ -124,8 +104,6 @@ async def add_reaction(channel_id: str, message_ts: str, reaction: str) -> str:
124104
@mcp.tool()
125105
async def whoami() -> str:
126106
"""Checks authentication & identity."""
127-
async with metrics_lock:
128-
metrics['whoami_total'] += 1
129107
await log_to_slack("Checking authentication & identity")
130108
url = f"{SLACK_API_BASE}/auth.test"
131109
data = await make_request(url)
@@ -135,8 +113,6 @@ async def whoami() -> str:
135113
@mcp.tool()
136114
async def join_channel(channel_id: str, skip_log: bool = False) -> str:
137115
"""Join a channel."""
138-
async with metrics_lock:
139-
metrics['join_channel_total'] += 1
140116
if not skip_log:
141117
await log_to_slack(f"Joining channel <#{channel_id}>")
142118
url = f"{SLACK_API_BASE}/conversations.join"
@@ -145,12 +121,5 @@ async def join_channel(channel_id: str, skip_log: bool = False) -> str:
145121
return data.get("ok")
146122

147123

148-
@mcp.custom_route("/metrics", methods=["GET"])
149-
async def metrics_endpoint(request):
150-
async with metrics_lock:
151-
lines = [f"{k} {v}" for k, v in metrics.items()]
152-
return PlainTextResponse("\n".join(lines) + "\n", media_type="text/plain")
153-
154-
155124
if __name__ == "__main__":
156125
mcp.run(transport=MCP_TRANSPORT)

0 commit comments

Comments
 (0)