You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should see log entries for tool discovery, file access, web fetches, and the final summary tweet. Try editing the instructions or adding new MCP servers to see how the agent evolves.
56
139
57
-
## 4. Paste the example agent
58
-
59
-
`main.py`
60
-
```python
61
-
import asyncio
62
-
import os
63
-
import time
64
-
65
-
from mcp_agent.app import MCPApp
66
-
from mcp_agent.agents.agent import Agent
67
-
from mcp_agent.workflows.llm.augmented_llm_openai import OpenAIAugmentedLLM
68
-
69
-
app = MCPApp(name="mcp_basic_agent")
70
-
71
-
@app.tool()
72
-
async def example_usage() -> str:
73
-
async with app.run() as session:
74
-
logger = session.logger
75
-
context = session.context
76
-
77
-
# Let the filesystem server access the current directory
"Print the contents of README.md verbatim; create it first if missing"
93
-
)
94
-
logger.info("README contents", data=result)
95
-
96
-
result = await llm.generate_str(
97
-
"Fetch the first two paragraphs from https://modelcontextprotocol.io/introduction"
98
-
)
99
-
logger.info("Fetched content", data=result)
100
-
101
-
tweet = await llm.generate_str(
102
-
"Summarize that content in a 140-character tweet"
103
-
)
104
-
logger.info("Tweet", data=tweet)
105
-
return tweet
106
-
107
-
if __name__ == "__main__":
108
-
start = time.time()
109
-
asyncio.run(example_usage())
110
-
end = time.time()
111
-
print(f"Finished in {end - start:.2f}s")
112
-
```
140
+
## Deploy it (optional)
113
141
114
-
## 5. Run it
142
+
You can deploy your agent as an MCP server.
115
143
116
144
```bash
117
-
uv run main.py
145
+
uvx mcp-agent login
146
+
uvx mcp-agent deploy
118
147
```
119
148
120
-
You should see log entries for tool discovery, file access, web fetches, and the final summary tweet. Try editing the instructions or adding new MCP servers to see how the agent evolves.
121
-
122
149
## Next steps
123
150
124
151
- Check out the generated README (if you used the CLI) for tips on extending the agent.
125
152
- Layer in more capabilities using the [Effective Patterns](/mcp-agent-sdk/effective-patterns/overview) guide.
126
-
- Ready to share it? Deploy with `uvx mcp-agent deploy my-agent` by following [Deploy to Cloud](/get-started/deploy-to-cloud).
153
+
- Ready to deploy your agent? Follow[Deploy to Cloud](/get-started/deploy-to-cloud).
0 commit comments