Skip to content

Commit a985648

Browse files
committed
update README.md
1 parent daf78ec commit a985648

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

README.md

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -212,33 +212,52 @@ I provide `McpAgent` to support tool calls based on the MCP protocol. Below is a
212212

213213
2. create an MCP session
214214

215-
You can create a connection configuration for your MCP server with `StdioMcpConfig`.
215+
- To connect with a stdio based MCP server, use `StdioMcpConfig`.
216216

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+
```
225225

226-
A function decorated with `@mcp_session` will receive an MCP session instance as its first parameter. A function can be decorated with multiple `@mcp_session` decorators to access sessions for different MCP servers.
226+
> A function decorated with `@mcp_session` will receive an MCP session instance as its first parameter. A function can 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+
```
227252

228-
```python
229-
@sync_call
230-
@mcp_session(stdio_mcp_config)
231-
async def run(session, request: str) -> str:
232-
...
233-
```
234253

235254
3. create an `McpAgent` instance within the MCP session
236255

237256
After creating `McpAgent`, you need to call the `fetch_abilities()` method to retrieve tool configurations from the MCP server.
238257
239258
```python
240259
@sync_call
241-
@mcp_session(stdio_mcp_config)
260+
@mcp_session(mcp_config)
242261
async def run(session, request: str) -> str:
243262
mcp_agent = await McpAgent(session=session, brain=model).fetch_abilities()
244263
...
@@ -248,7 +267,7 @@ I provide `McpAgent` to support tool calls based on the MCP protocol. Below is a
248267
249268
```python
250269
@sync_call
251-
@mcp_session(stdio_mcp_config)
270+
@mcp_session(mcp_config)
252271
async def run(session, request: str) -> str:
253272
mcp_agent = await McpAgent(session=session, brain=model).fetch_abilities()
254273
result = await mcp_agent.assign(request).just_do_it()

0 commit comments

Comments
 (0)