Textual应用调试服务器

一个为Textual应用提供实时调试工具和性能监控的WebSocket服务器。

  • by vvitchkrvft
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 vvitchkrvft/textual_mcp

使用说明

文本MCP服务器

FastMCP服务器为文本应用程序提供实时调试工具。

特性

  • 用于连接文本应用程序的实时WebSocket服务器
  • 实时日志收集和过滤
  • 性能监控
  • 连接跟踪
  • 未来功能的可扩展架构

安装

pip install .

用法

  1. 启动MCP服务器:
textual-mcp
  1. 在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
            }))

发展

  1. 创建虚拟环境:
python -m venv .venv
source .venv/bin/activate  # Linux/Mac
.venv\Scripts\activate     # Windows
  1. 安装依赖项:
pip install -e ".[dev]"
  1. 运行测试:
pytest

许可证

麻省理工学院