Metadata-Version: 2.4
Name: da2-xiaozhi-tunnel
Version: 0.1.0
Summary: MCP (Model Context Protocol) 橋接模組，支援 WebSocket 與 HTTP/SSE 傳輸
Author-email: Danny <danny@da2.35g.tw>
Maintainer: DA2 Studio
License: MIT
Project-URL: Homepage, https://da2.35g.tw
Project-URL: Repository, https://github.com/da2studio/da2-xiaozhi-tunnel
Keywords: mcp,websocket,sse,xiaozhi,ai,bridge
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: websockets>=10.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: httpx-sse>=0.3.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.20; extra == "dev"
Dynamic: license-file

# da2-xiaozhi-tunnel

MCP (Model Context Protocol) 橋接模組，用於連接小智雲端與其他 MCP 伺服器。

## 功能特色

- **WebSocketTunnelMCP**: WebSocket 隧道伺服器，對接小智雲端
- **MCPHttpClient**: HTTP/SSE 客戶端，連接遠端 MCP 伺服器
- 支援多伺服器工具聚合與智慧路由
- 自動重連機制

## 安裝

```bash
pip install da2-xiaozhi-tunnel
```

## 快速開始

```python
from da2_xiaozhi_tunnel import WebSocketTunnelMCP, MCPHttpClient

# 建立主伺服器
mcp = WebSocketTunnelMCP(server_name="MyServer")

# 註冊本地工具
@mcp.tool("hello", "打招呼", {"type": "object", "properties": {}})
async def hello():
    return "Hello, World!"

# 掛載遠端 MCP Server
hub = MCPHttpClient("http://remote-mcp/mcp", "hub", use_sse=False)
mcp.mount_client(hub)

# 連線
await mcp.connect("wss://api.xiaozhi.me/mcp/?token=YOUR_TOKEN")
await mcp.listen_loop()
```

## 文件

- [MCPHttpClient 說明](MCPHttpClient.md)
- [WebSocketTunnelMCP 說明](WebSocketTunnelMCP.md)

## License

MIT
