style: move httpx import to top-level and fix README example for MCP headers
This commit is contained in:
17
README.md
17
README.md
@@ -753,15 +753,14 @@ Add MCP servers to your `config.json`:
|
|||||||
"filesystem": {
|
"filesystem": {
|
||||||
"command": "npx",
|
"command": "npx",
|
||||||
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
|
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
|
||||||
}
|
|
||||||
},
|
|
||||||
"urlMcpServers": {
|
|
||||||
"url": "https://xx.xx.xx.xx:xxxx/mcp/",
|
|
||||||
"headers": {
|
|
||||||
"Authorization": "Bearer xxxxx",
|
|
||||||
"X-API-Key": "xxxxxxx"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
"my-remote-mcp": {
|
||||||
|
"url": "https://example.com/mcp/",
|
||||||
|
"headers": {
|
||||||
|
"Authorization": "Bearer xxxxx"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -771,7 +770,7 @@ Two transport modes are supported:
|
|||||||
| Mode | Config | Example |
|
| Mode | Config | Example |
|
||||||
|------|--------|---------|
|
|------|--------|---------|
|
||||||
| **Stdio** | `command` + `args` | Local process via `npx` / `uvx` |
|
| **Stdio** | `command` + `args` | Local process via `npx` / `uvx` |
|
||||||
| **HTTP** | `url` + `option(headers)`| Remote endpoint (`https://mcp.example.com/sse`) |
|
| **HTTP** | `url` + `headers` (optional) | Remote endpoint (`https://mcp.example.com/sse`) |
|
||||||
|
|
||||||
MCP tools are automatically discovered and registered on startup. The LLM can use them alongside built-in tools — no extra configuration needed.
|
MCP tools are automatically discovered and registered on startup. The LLM can use them alongside built-in tools — no extra configuration needed.
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
from contextlib import AsyncExitStack
|
from contextlib import AsyncExitStack
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
import httpx
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from nanobot.agent.tools.base import Tool
|
from nanobot.agent.tools.base import Tool
|
||||||
@@ -59,7 +60,6 @@ async def connect_mcp_servers(
|
|||||||
read, write = await stack.enter_async_context(stdio_client(params))
|
read, write = await stack.enter_async_context(stdio_client(params))
|
||||||
elif cfg.url:
|
elif cfg.url:
|
||||||
from mcp.client.streamable_http import streamable_http_client
|
from mcp.client.streamable_http import streamable_http_client
|
||||||
import httpx
|
|
||||||
if cfg.headers:
|
if cfg.headers:
|
||||||
http_client = await stack.enter_async_context(
|
http_client = await stack.enter_async_context(
|
||||||
httpx.AsyncClient(
|
httpx.AsyncClient(
|
||||||
|
|||||||
Reference in New Issue
Block a user