Skip to content

Commit d9f0b90

Browse files
authored
Add mcp-agent cloud compatibility to basic slack agent example (#494)
* Add mcp-agent cloud compatibility to basic slack agent example 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 * Update README.md Added cloud details
1 parent 35d97d5 commit d9f0b90

File tree

2 files changed

+105
-6
lines changed

2 files changed

+105
-6
lines changed

examples/usecases/mcp_basic_slack_agent/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,97 @@ Run your MCP Agent app:
9696
```bash
9797
uv run main.py
9898
```
99+
## `4` [Beta] Deploy to MCP Agent Cloud
100+
101+
### Prerequisites
102+
Make sure your agent is cloud-compatible with the `@app.tool` decorator (already included in this example).
103+
104+
### Step 1: Login to MCP Agent Cloud
105+
106+
```bash
107+
uv run mcp-agent login
108+
```
109+
110+
111+
### Step 2: Deploy your agent
112+
113+
```bash
114+
uv run mcp-agent deploy basic-slack-agent
115+
```
116+
117+
During deployment, you'll be prompted to configure secrets. You'll see two options for each secret:
118+
119+
#### For OpenAI API Key:
120+
```
121+
Select secret type for 'openai.api_key'
122+
1: Deployment Secret: The secret value will be stored securely and accessible to the deployed application runtime.
123+
2: User Secret: No secret value will be stored. The 'configure' command must be used to create a configured application with this secret.
124+
125+
```
126+
Recommendation:
127+
- Choose Option 1 if you're deploying for personal use and want immediate functionality
128+
- Choose Option 2 if you're sharing this agent publicly and want users to provide their own OpenAI API keys
129+
130+
#### For Slack Bot Token:
131+
```
132+
Select secret type for 'mcp.servers.slack.env.SLACK_BOT_TOKEN'
133+
1: Deployment Secret: The secret value will be stored securely and accessible to the deployed application runtime.
134+
2: User Secret: No secret value will be stored. The 'configure' command must be used to create a configured application with this secret.
135+
136+
```
137+
Recommendation:
138+
- Choose Option 1 if you're deploying for your own Slack workspace and want the agent to work immediately
139+
- Choose Option 2 if you're sharing this agent publicly and want each user to connect their own Slack workspace
140+
141+
### Step 3: Connect to your deployed agent
142+
143+
Once deployed, you'll receive a deployment URL like: `https://[your-agent-server-id].deployments.mcp-agent.com`
144+
145+
#### Claude Desktop Integration
146+
147+
Configure Claude Desktop to access your agent by updating your `~/.claude-desktop/config.json`:
148+
149+
```json
150+
{
151+
"mcpServers": {
152+
"basic-slack-agent": {
153+
"command": "/path/to/npx",
154+
"args": [
155+
"mcp-remote",
156+
"https://[your-agent-server-id].deployments.mcp-agent.com/sse",
157+
"--header",
158+
"Authorization: Bearer ${BEARER_TOKEN}"
159+
],
160+
"env": {
161+
"BEARER_TOKEN": "your-mcp-agent-cloud-api-token"
162+
}
163+
}
164+
}
165+
}
166+
```
167+
168+
#### MCP Inspector
169+
170+
Test your deployed agent using MCP Inspector:
171+
172+
```bash
173+
npx @modelcontextprotocol/inspector
174+
```
175+
176+
Configure the inspector with these settings:
177+
178+
| Setting | Value |
179+
|---------|-------|
180+
| Transport Type | SSE |
181+
| SSE URL | `https://[your-agent-server-id].deployments.mcp-agent.com/sse` |
182+
| Header Name | Authorization |
183+
| Bearer Token | your-mcp-agent-cloud-api-token |
184+
185+
**Tip:** Increase the request timeout in the Configuration since LLM calls take longer than simple API calls.
186+
187+
### Available Tools
188+
189+
Once deployed, your agent will expose the `fetch_latest_slack_message` tool, which:
190+
- Fetches the latest message from the bot-commits channel
191+
- Provides an AI-generated summary of the message content
192+
- Returns both the original message and summary

examples/usecases/mcp_basic_slack_agent/main.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
app = MCPApp(name="mcp_basic_agent")
99

1010

11-
async def example_usage():
11+
@app.tool
12+
async def fetch_latest_slack_message() -> str:
13+
"""Get the latest message from general channel and provide a summary."""
1214
async with app.run() as agent_app:
1315
logger = agent_app.logger
1416
context = agent_app.context
@@ -31,22 +33,25 @@ async def example_usage():
3133

3234
llm = await slack_agent.attach_llm(OpenAIAugmentedLLM)
3335
result = await llm.generate_str(
34-
message="What was the last message in the general channel?",
36+
message="What was the latest message in the bot-commits channel?",
3537
)
3638
logger.info(f"Result: {result}")
3739

3840
# Multi-turn conversations
39-
result = await llm.generate_str(
40-
message="Summarize it for me so I can understand it better.",
41+
summary = await llm.generate_str(
42+
message="Can you summarize what that commit was about?",
4143
)
42-
logger.info(f"Result: {result}")
44+
logger.info(f"Result: {summary}")
45+
46+
final_result = f"Latest message: {result}\n\nSummary: {summary}"
47+
return final_result
4348

4449

4550
if __name__ == "__main__":
4651
import time
4752

4853
start = time.time()
49-
asyncio.run(example_usage())
54+
asyncio.run(fetch_latest_slack_message())
5055
end = time.time()
5156
t = end - start
5257

0 commit comments

Comments
 (0)