Skip to main content
Glama
test_transports.py3.84 kB
""" 传输模式集成测试 """ import json import os import sys import pytest # 添加src目录到路径 sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "src")) class TestTransports: """传输模式测试""" def test_stdio_transport(self): """测试STDIO传输模式""" # 这个测试在CI环境中可能比较复杂,我们测试服务器能否正常启动 try: from genome_mcp.__main__ import main assert callable(main) except Exception as e: pytest.fail(f"STDIO传输模式导入失败: {e}") def test_http_transport_import(self): """测试HTTP传输模式导入""" try: from genome_mcp.__main__ import main # 检查是否支持HTTP参数 assert callable(main) except Exception as e: pytest.fail(f"HTTP传输模式导入失败: {e}") def test_sse_transport_import(self): """测试SSE传输模式导入""" try: from genome_mcp.__main__ import main # 检查是否支持SSE参数 assert callable(main) except Exception as e: pytest.fail(f"SSE传输模式导入失败: {e}") @pytest.mark.asyncio async def test_mcp_tools_availability(self): """测试MCP工具在不同传输模式下的可用性""" # 测试MCP服务器是否可以被正确导入 try: from genome_mcp.main import mcp # 检查MCP实例可用性 assert mcp is not None, "MCP instance should be available" assert hasattr(mcp, "name"), "MCP should have name attribute" assert mcp.name == "Genome MCP", "MCP name should be correct" except Exception as e: pytest.fail(f"MCP工具导入失败: {e}") def test_command_line_interface(self): """测试命令行接口""" try: # 测试主模块能否被正确导入 import genome_mcp.__main__ assert hasattr(genome_mcp.__main__, "main") except Exception as e: pytest.fail(f"命令行接口测试失败: {e}") class TestMCPConfiguration: """MCP配置测试""" def test_mcp_config_exists(self): """测试MCP配置文件存在""" config_path = os.path.join( os.path.dirname(__file__), "..", "..", "mcp-config.json" ) assert os.path.exists(config_path), "MCP配置文件不存在" def test_mcp_config_validity(self): """测试MCP配置文件有效性""" config_path = os.path.join( os.path.dirname(__file__), "..", "..", "mcp-config.json" ) with open(config_path) as f: try: config = json.load(f) assert isinstance(config, dict) # 检查必要的配置项 assert "mcpServers" in config except json.JSONDecodeError as e: pytest.fail(f"MCP配置文件JSON格式错误: {e}") def test_claude_desktop_config_example(self): """测试Claude Desktop配置示例""" config_path = os.path.join( os.path.dirname(__file__), "..", "..", "mcp-config.json", ) assert os.path.exists(config_path), "MCP配置示例不存在" with open(config_path) as f: try: config = json.load(f) assert isinstance(config, dict) assert "mcpServers" in config except json.JSONDecodeError as e: pytest.fail(f"MCP配置示例JSON格式错误: {e}") # 示例文件测试已移除,因为examples目录已被删除 # 相关示例已整合到README.md文档中 if __name__ == "__main__": pytest.main([__file__, "-v"])

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gqy20/genome-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server