文本MCP服务器
FastMCP服务器为文本应用程序提供实时调试工具。
特性
- 用于连接文本应用程序的实时WebSocket服务器
- 实时日志收集和过滤
- 性能监控
- 连接跟踪
- 未来功能的可扩展架构
安装
pip install .用法
- 启动MCP服务器:
textual-mcp- 在Textual应用程序中,连接到调试服务器:
from textual.app import App
import websockets
import json
import asyncio
from datetime import datetime
class MyApp(App):
async def on_mount(self) -> None:
# Connect to debug server
self.ws = await websockets.connect("ws://localhost:7654")
# Send initial connection info
await self.ws.send(json.dumps({
"app_id": "my-app-1",
"app_name": "My Textual App",
"metadata": {
"version": "1.0.0"
}
}))
async def on_logging(self, event: events.Logging) -> None:
# Send log to debug server
if self.ws:
await self.ws.send(json.dumps({
"type": "log",
"timestamp": datetime.now().isoformat(),
"level": event.level,
"message": event.message,
"log_group": event.group
}))发展
- 创建虚拟环境:
python -m venv .venv
source .venv/bin/activate # Linux/Mac
.venv\Scripts\activate # Windows- 安装依赖项:
pip install -e ".[dev]"- 运行测试:
pytest许可证
麻省理工学院
