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
Copy file name to clipboardExpand all lines: README.md
+37-18Lines changed: 37 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -212,33 +212,52 @@ I provide `McpAgent` to support tool calls based on the MCP protocol. Below is a
212
212
213
213
2. create an MCP session
214
214
215
-
You can create a connection configuration for your MCP server with`StdioMcpConfig`.
215
+
- To connect with a stdio based MCP server, use`StdioMcpConfig`.
216
216
217
-
```python
218
-
stdio_mcp_config = StdioMcpConfig(
219
-
command='python',
220
-
args=['./my_stdio_mcp_server.py'],
221
-
env=dict(),
222
-
cwd='./mcp_servers'
223
-
)
224
-
```
217
+
```python
218
+
mcp_config = StdioMcpConfig(
219
+
command='python',
220
+
args=['./my_stdio_mcp_server.py'],
221
+
env=dict(),
222
+
cwd='./mcp_servers'
223
+
)
224
+
```
225
225
226
-
A functiondecorated with `@mcp_session` will receive an MCP session instance as its first parameter. A functioncan be decorated with multiple `@mcp_session` decorators to access sessions for different MCP servers.
226
+
> A functiondecorated with `@mcp_session` will receive an MCP session instance as its first parameter. A functioncan be decorated with multiple `@mcp_session` decorators to access sessions for different MCP servers.
227
+
228
+
```python
229
+
@sync_call
230
+
@mcp_session(mcp_config)
231
+
async def run(session, request: str) -> str:
232
+
...
233
+
```
234
+
235
+
- To connect via HTTP with a SSE based MCP server, just provide the URL.
236
+
237
+
```python
238
+
@sync_call
239
+
@mcp_session('http://localhost:8000/sse')
240
+
async def run(session, request: str) -> str:
241
+
...
242
+
```
243
+
244
+
- To connect via websocket with a WS based MCP server, provide the URL.
245
+
246
+
```python
247
+
@sync_call
248
+
@mcp_session('ws://localhost:8000/message')
249
+
async def run(session, request: str) -> str:
250
+
...
251
+
```
227
252
228
-
```python
229
-
@sync_call
230
-
@mcp_session(stdio_mcp_config)
231
-
async def run(session, request: str) -> str:
232
-
...
233
-
```
234
253
235
254
3. create an `McpAgent` instance within the MCP session
236
255
237
256
After creating `McpAgent`, you need to call the `fetch_abilities()` method to retrieve tool configurations from the MCP server.
0 commit comments