Skip to content

Commit 6de7862

Browse files
Merge branch 'docs/mcp-agent-cloud-examples' into main
2 parents 4bfac0e + 00f2970 commit 6de7862

File tree

2 files changed

+76
-6
lines changed

2 files changed

+76
-6
lines changed

examples/mcp_agent_server/asyncio/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,81 @@ uv run client.py
152152
uv run client.py --custom-fastmcp-settings
153153
```
154154

155+
### [Beta] Deploying to mcp-agent cloud
156+
157+
You can deploy your MCP-Agent app as a hosted mcp-agent app in the Cloud.
158+
159+
1. Update the *mcp_agent.secrets.yaml* file specifying deployed secrets:
160+
161+
```
162+
openai:
163+
api_key: !developer_secret
164+
165+
anthropic:
166+
api_key: !developer_secret
167+
```
168+
169+
2. In your terminal, authenticate into mcp-agent cloud by running:
170+
```
171+
uv run mcp-agent login
172+
```
173+
174+
3. You will be redirected to the login page, create an mcp-agent cloud account through Google or Github
175+
176+
4. Set up your mcp-agent cloud API Key and copy & paste it into your terminal
177+
178+
```
179+
andrew_lm@Mac sdk-cloud % uv run mcp-agent login
180+
INFO: Directing to MCP Agent Cloud API login...
181+
Please enter your API key 🔑:
182+
```
183+
184+
5. In your terminal, deploy the MCP app:
185+
```
186+
uv run mcp-agent deploy mcp_agent_server -c /absolute/path/to/your/project
187+
```
188+
189+
6. In the terminal, ou will then be prompted to specify your OpenAI and/or Anthropic keys:
190+
191+
Once the deployment is successful, you should see the following:
192+
```
193+
andrew_lm@Mac sdk-cloud % uv run mcp-agent deploy basic_agent_server -c /Users/andrew_lm/Documents/GitHub/mcp-agent/examples/mcp_agent_server/asyncio/
194+
╭─────────────────────────────────────────────────── MCP Agent Deployment ────────────────────────────────────────────────────╮
195+
│ Configuration: /Users/andrew_lm/Documents/GitHub/mcp-agent/examples/mcp_agent_server/asyncio/mcp_agent.config.yaml │
196+
│ Secrets file: /Users/andrew_lm/Documents/GitHub/mcp-agent/examples/mcp_agent_server/asyncio/mcp_agent.secrets.yaml │
197+
│ Mode: DEPLOY │
198+
╰──────────────────────────────────────────────────────── LastMile AI ────────────────────────────────────────────────────────╯
199+
INFO: Using API at https://mcp-agent.com/api
200+
INFO: Checking for existing app ID for 'basic_agent_server'...
201+
SUCCESS: Found existing app with ID: app_dd3a033d-4f4b-4e33-b82c-aad9ec43c52f for name 'basic_agent_server'
202+
INFO: Processing secrets file...
203+
INFO: Found existing transformed secrets to use where applicable:
204+
/Users/andrew_lm/Documents/GitHub/mcp-agent/examples/mcp_agent_server/asyncio/mcp_agent.deployed.secrets.yaml
205+
INFO: Loaded existing secrets configuration for reuse
206+
INFO: Reusing existing developer secret handle at 'openai.api_key': mcpac_sc_83d412fd-083e-4174-89b4-ecebb1e4cae9
207+
INFO: Transformed config written to /Users/andrew_lm/Documents/GitHub/mcp-agent/examples/mcp_agent_server/asyncio/mcp_agent.deployed.secrets.yaml
208+
209+
Secrets Processing Summary
210+
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
211+
┃ Type ┃ Path ┃ Handle/Status ┃ Source ┃
212+
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
213+
│ Developer │ openai.api_key │ mcpac_sc...b1e4qwe9 │ ♻️ Reused │
214+
└───────────┴────────────────┴─────────────────────┴──────────┘
215+
216+
Summary: 0 new secrets created, 1 existing secrets reused
217+
SUCCESS: Secrets file processed successfully
218+
INFO: Transformed secrets file written to /Users/andrew_lm/Documents/GitHub/mcp-agent/examples/mcp_agent_server/asyncio/mcp_agent.deployed.secrets.yaml
219+
╭───────────────────────────────────────── Deployment Ready ───────────────────────────────────────────────╮
220+
│ Ready to deploy MCP Agent with processed configuration │
221+
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯
222+
WARNING: Found a __main__ entrypoint in main.py. This will be ignored in the deployment.
223+
▰▰▰▰▰▰▱ ✅ Bundled successfully
224+
▹▹▹▹▹ Deploying MCP App bundle...INFO: App ID: app_ddde033d-21as-fe3s-b82c-aaae4243c52f
225+
INFO: App URL: https://770xdsp22y321prwv9rasdfasd9l5zj5.deployments.mcp-agent-cloud.lastmileai.dev
226+
INFO: App Status: OFFLINE
227+
▹▹▹▹▹ ✅ MCP App deployed successfully!
228+
```
229+
155230
## Receiving Server Logs in the Client
156231

157232
The server advertises the `logging` capability (via `logging/setLevel`) and forwards its structured logs upstream using `notifications/message`. To receive these logs in a client session, pass a `logging_callback` when constructing the client session and set the desired level:

examples/mcp_agent_server/asyncio/basic_agent_server.py renamed to examples/mcp_agent_server/asyncio/main.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
# Note: This is purely optional:
3030
# if not provided, a default FastMCP server will be created by MCPApp using create_mcp_server_for_app()
31-
mcp = FastMCP(name="basic_agent_server", description="My basic agent server example.")
31+
mcp = FastMCP(name="basic_agent_server")
3232

3333
# Define the MCPApp instance. The server created for this app will advertise the
3434
# MCP logging capability and forward structured logs upstream to connected clients.
@@ -249,25 +249,21 @@ async def grade_story_async(story: str, app_ctx: Optional[AppContext] = None) ->
249249

250250
return result
251251

252-
253252
# Add custom tool to get token usage for a workflow
254253
@mcp.tool(
255254
name="get_token_usage",
256255
structured_output=True,
257256
description="""
258257
Get detailed token usage information for a specific workflow run.
259-
260258
This provides a comprehensive breakdown of token usage including:
261259
- Total tokens used across all LLM calls within the workflow
262260
- Breakdown by model provider and specific models
263261
- Hierarchical usage tree showing usage at each level (workflow -> agent -> llm)
264262
- Total cost estimate based on model pricing
265-
266263
Args:
267264
workflow_id: Optional workflow ID (if multiple workflows have the same name)
268265
run_id: Optional ID of the workflow run to get token usage for
269266
workflow_name: Optional name of the workflow (used as fallback)
270-
271267
Returns:
272268
Detailed token usage information for the specific workflow run
273269
""",
@@ -366,7 +362,6 @@ def collect_model_usage(node: TokenNode):
366362

367363
return result
368364

369-
370365
async def main():
371366
parser = argparse.ArgumentParser()
372367
parser.add_argument(

0 commit comments

Comments
 (0)