Skip to content

Conversation

Haniehz1
Copy link
Contributor

@Haniehz1 Haniehz1 commented Sep 16, 2025

  1. Added @app.tool decorator (line 11) - Makes the function available as a cloud tool
  2. Renamed function from example_usage() to fetch_latest_slack_message() (line 12) - More descriptive name
  3. Added return type annotation -> str (line 12) - Required for cloud compatibility
  4. Added docstring (line 13) - Describes what the tool does
  5. Added return statement - Returns formatted result for cloud usage

Summary by CodeRabbit

  • New Features

    • Added a user-accessible tool that fetches the latest message from the bot-commits Slack channel, generates a concise commit summary, and returns a single combined string.
    • Runtime now displays total execution time after completion.
  • Documentation

    • Added a Beta cloud deployment guide with step-by-step deploy/login instructions, secret configuration recommendations, integration examples (desktop and inspector), and usage notes for the new tool.

 1. Added @app.tool decorator (line 11) - Makes the function available as a cloud tool
  2. Renamed function from example_usage() to fetch_latest_slack_message() (line 12) - More descriptive name
  3. Added return type annotation -> str (line 12) - Required for cloud compatibility
  4. Added docstring (line 13) - Describes what the tool does
  6. Added return statement - Returns formatted result for cloud usage
Copy link

coderabbitai bot commented Sep 16, 2025

Walkthrough

Introduces a new public tool fetch_latest_slack_message() that asynchronously fetches the latest message from the bot-commits Slack channel, prompts the LLM for a commit-specific summary, composes and returns a consolidated string (original message + summary), updates the main entry point to call the tool, and adds a cloud deployment section to the README.

Changes

Cohort / File(s) Summary of Changes
Slack agent tool refactor
examples/usecases/mcp_basic_slack_agent/main.py
Replaced internal example_usage() with public @app.tool async def fetch_latest_slack_message() -> str; switched Slack query to bot-commits; adjusted prompts to request a precise commit summary; capture second assistant response as summary; compose and return final_result (original message + summary); update main to call the new tool and print total execution time; add docstring.
README — cloud deploy & integrations
examples/usecases/mcp_basic_slack_agent/README.md
Added a new "4 [Beta] Deploy to MCP Agent Cloud" section with prerequisites, deployment steps (secrets configuration with Deployment/User secret options), Claude Desktop config.json JSON snippet, MCP Inspector SSE setup details (transport, URL, header, token), timeout tip, and documentation for the fetch_latest_slack_message tool (behavior and return).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Runner as Main/Runner
  participant Tool as app.tool fetch_latest_slack_message()
  participant Slack as Slack API
  participant LLM as LLM

  Runner->>Tool: invoke fetch_latest_slack_message()
  rect rgb(240,245,255)
    Tool->>Slack: get latest message from `bot-commits`
    Slack-->>Tool: latest_message
    Tool->>LLM: "Summarize this commit:" + latest_message
    LLM-->>Tool: summary
    Tool-->>Runner: return final_result (latest_message + "\n\n" + summary)
  end
  note right of Runner: Runner prints total execution time
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • saqadri
  • andrew-lastmile

Poem

I twitch my nose at bot-commits’ light,
Hop-hop, I fetch the latest byte.
I nibble words and neatly weave,
A tiny summary I leave.
Thump! Final string, concise and bright. 🥕💬

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Add mcp-agent cloud compatibility to basic slack agent example" is concise, single-sentence, and directly reflects the primary change in the PR—making the basic Slack agent example compatible with the MCP cloud (decorator, renaming, return type and README updates). It clearly communicates the main intention to reviewers and matches the changes described in the summary. The phrasing is specific enough for teammates scanning history to understand the primary purpose of the change.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Haniehz1-patch-11

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (8)
examples/usecases/mcp_basic_slack_agent/main.py (8)

11-13: Fix docstring to match behavior (bot-commits vs general).
Docstring says “general” but the prompt targets “bot-commits.” Align to avoid confusion.

Apply this diff:

-async def fetch_latest_slack_message() -> str:
-    """Get the latest message from general channel and provide a summary."""
+async def fetch_latest_slack_message() -> str:
+    """Get the latest message from the bot-commits channel and provide a summary."""

27-27: Guard against duplicate/inconsistent filesystem args.
Repeated runs can append the same cwd; also handle missing server/args defensively.

Apply this diff:

-context.config.mcp.servers["filesystem"].args.extend([os.getcwd()])
+fs = context.config.mcp.servers.get("filesystem")
+if fs is not None:
+    args = getattr(fs, "args", None)
+    if args is None:
+        fs.args = [os.getcwd()]
+    elif os.getcwd() not in args:
+        fs.args.append(os.getcwd())
+else:
+    logger.info("filesystem server not configured; skipping cwd injection")

31-39: Avoid reusing result for different meanings.
Improves readability and log clarity.

Apply this diff:

-logger.info("slack: Connected to server, calling list_tools...")
-result = await slack_agent.list_tools()
-logger.info("Tools available:", data=result.model_dump())
+logger.info("slack: Connected to server, calling list_tools...")
+tools = await slack_agent.list_tools()
+logger.info("Tools available:", data=tools.model_dump())

 llm = await slack_agent.attach_llm(OpenAIAugmentedLLM)
-result = await llm.generate_str(
+latest_message = await llm.generate_str(
     message="What was the latest message in the bot-commits channel?",
 )
-logger.info(f"Result: {result}")
+logger.info(f"Latest message: {latest_message}")

41-45: Label the second log as Summary.
Minor clarity improvement.

-summary = await llm.generate_str(
+summary = await llm.generate_str(
     message="Can you summarize what that commit was about?",
 )
-logger.info(f"Result: {summary}")
+logger.info(f"Summary: {summary}")

46-47: Return machine-readable output for cloud consumers.
Since the tool must return str, prefer JSON for easier downstream parsing.

Apply this diff and add an import:

+import json
@@
-final_result = f"Latest message: {result}\n\nSummary: {summary}"
-return final_result
+final_result = {"latest_message": latest_message, "summary": summary}
+return json.dumps(final_result)

Add near the top:

-import asyncio
+import asyncio
+import json

35-37: Parameterize the Slack channel.
Avoid hard-coding; allow override via env.

-    message="What was the latest message in the bot-commits channel?",
+    message=f"What was the latest message in the {os.getenv('SLACK_CHANNEL', 'bot-commits')} channel?",

29-47: Add minimal error handling to avoid tool crashes.
Return a friendly string on failures so cloud calls don’t 500.

-async with slack_agent:
+async with slack_agent:
     logger.info("slack: Connected to server, calling list_tools...")
-    tools = await slack_agent.list_tools()
+    try:
+        tools = await slack_agent.list_tools()
         ...
-    final_result = {"latest_message": latest_message, "summary": summary}
-    return json.dumps(final_result)
+        final_result = {"latest_message": latest_message, "summary": summary}
+        return json.dumps(final_result)
+    except Exception as e:
+        logger.info("slack: error during fetch/summarize", error=str(e))
+        return json.dumps({"error": str(e)})

53-58: Print the tool’s output when run as a script.
Helps make the example useful outside cloud.

-start = time.time()
-asyncio.run(fetch_latest_slack_message())
-end = time.time()
+start = time.time()
+result = asyncio.run(fetch_latest_slack_message())
+end = time.time()
 t = end - start
 
+print(result)
 print(f"Total run time: {t:.2f}s")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b2550e and 3203f34.

📒 Files selected for processing (1)
  • examples/usecases/mcp_basic_slack_agent/main.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
examples/usecases/mcp_basic_slack_agent/main.py (2)
src/mcp_agent/app.py (1)
  • logger (193-210)
src/mcp_agent/logging/logger.py (1)
  • info (271-279)

Added cloud details
async def example_usage():
@app.tool
async def fetch_latest_slack_message() -> str:
"""Get the latest message from general channel and provide a summary."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring references the "general" channel, but the implementation on line 36 is fetching from the "bot-commits" channel. For consistency, please update the docstring to match the actual implementation:

"""Get the latest message from bot-commits channel and provide a summary."""

This will ensure the documentation accurately reflects the code's behavior.

Suggested change
"""Get the latest message from general channel and provide a summary."""
"""Get the latest message from bot-commits channel and provide a summary."""

Spotted by Diamond

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
examples/usecases/mcp_basic_slack_agent/README.md (1)

78-90: Fix YAML nesting for Slack env (current example won’t match mcp.servers.slack.env.*).

env must be nested under slack. Otherwise secrets/config resolution will fail at runtime.

Apply:

 mcp:
   servers:
     slack:
-    env:
-      SLACK_BOT_TOKEN: "xoxb-your-bot-token"
-      SLACK_TEAM_ID: "T01234567"
+      env:
+        SLACK_BOT_TOKEN: "xoxb-your-bot-token"
+        SLACK_TEAM_ID: "T01234567"
🧹 Nitpick comments (5)
examples/usecases/mcp_basic_slack_agent/README.md (5)

119-119: Remove trailing punctuation in headings (MD026).

-#### For OpenAI API Key:
+#### For OpenAI API Key
...
-#### For Slack Bot Token:
+#### For Slack Bot Token

Also applies to: 130-130


120-125: Add language to fenced code blocks (MD040).

-```
+```text
 Select secret type for 'openai.api_key'
 
-```
+```

-```
+```text
 Select secret type for 'mcp.servers.slack.env.SLACK_BOT_TOKEN'
 
-```
+```

Also applies to: 132-136


149-166: Avoid embedding bearer tokens in config; source from OS env instead.

Omit the env block to prevent plaintext tokens in dotfiles. Keep ${BEARER_TOKEN} in args and export it at runtime.

   "args": [
     "mcp-remote",
     "https://[your-agent-server-id].deployments.mcp-agent.com/sse",
     "--header",
     "Authorization: Bearer ${BEARER_TOKEN}"
   ],
-  "env": {
-    "BEARER_TOKEN": "your-mcp-agent-cloud-api-token"
-  }

Usage:

  • macOS/Linux: export BEARER_TOKEN=...
  • Windows (PowerShell): $Env:BEARER_TOKEN="..."

69-73: Add a prominent “do not commit secrets” note and ensure .gitignore covers it.

Prevent accidental leakage of mcp_agent.secrets.yaml.

Add after the copy command:

  • “Do not commit mcp_agent.secrets.yaml; ensure it’s in .gitignore.”

107-115: Confirm CLI verbs (login, deploy) for mcp-agent.

If the CLI uses different subcommands/entrypoint, update the README to exact names to prevent setup churn.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3203f34 and 68711ff.

📒 Files selected for processing (1)
  • examples/usecases/mcp_basic_slack_agent/README.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
examples/usecases/mcp_basic_slack_agent/README.md

119-119: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


120-120: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


130-130: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)


131-131: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (1)
examples/usecases/mcp_basic_slack_agent/README.md (1)

189-192: Verify channel name matches code default.

README says "bot-commits" but examples/usecases/mcp_basic_slack_agent/main.py's docstring says "general" while the LLM prompt references "bot-commits" — confirm the intended Slack channel and make README/code consistent.

Locations: examples/usecases/mcp_basic_slack_agent/README.md (lines 189–192); examples/usecases/mcp_basic_slack_agent/main.py (docstring ~line 13; prompt ~line 36).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant