Skip to content

Commit c78edcd

Browse files
committed
Update test_mcp_plugin.py
1 parent 6674052 commit c78edcd

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

tests/test_mcp_plugin.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,29 @@ def test_get_capabilities_description_no_servers(self):
344344
@pytest.mark.asyncio
345345
@pytest.mark.skipif(not os.getenv("GITHUB_TOKEN"), reason="GITHUB_TOKEN not set")
346346
class TestGitHubMCPServer:
347-
"""Integration tests with GitHub MCP server (requires GITHUB_TOKEN)"""
347+
"""Integration tests with GitHub MCP server (requires GITHUB_TOKEN)
348+
349+
Uses the local GitHub MCP server via stdio transport (npx).
350+
The remote hosted endpoint at api.githubcopilot.com requires OAuth,
351+
but the local server works with a regular GitHub Personal Access Token.
352+
"""
348353

349354
async def test_github_mcp_server_connection(self):
350-
"""Test real connection to GitHub MCP server"""
355+
"""Test real connection to GitHub MCP server via local stdio transport"""
356+
import shutil
357+
358+
# Check if npx is available
359+
if not shutil.which("npx"):
360+
pytest.skip("npx not available - required for local GitHub MCP server")
361+
362+
# Use stdio transport with local GitHub MCP server
363+
# This uses the official @modelcontextprotocol/server-github package
351364
config = ServerConfig(
352-
transport="sse",
353-
url="https://api.githubcopilot.com/mcp",
354-
headers={
355-
"Authorization": f"Bearer {os.getenv('GITHUB_TOKEN')}",
356-
"Accept": "text/event-stream"
357-
},
358-
description="GitHub MCP Server"
365+
transport="stdio",
366+
command="npx",
367+
args=["-y", "@modelcontextprotocol/server-github"],
368+
env={"GITHUB_PERSONAL_ACCESS_TOKEN": os.getenv("GITHUB_TOKEN")},
369+
description="GitHub MCP Server (local)"
359370
)
360371

361372
server = MCPServer("github", config)
@@ -369,14 +380,11 @@ async def test_github_mcp_server_connection(self):
369380
print(f"GitHub MCP server connected successfully!")
370381
print(f"Found: {len(server.tools)} tools, {len(server.resources)} resources, {len(server.prompts)} prompts")
371382

372-
# Test a simple tool if available
383+
# List some tools
373384
if server.tools:
374-
tool_name = server.tools[0].name
375-
print(f"Testing tool: {tool_name}")
376-
377-
# Create minimal arguments - this might fail but tests the connection
378-
result = await execute_tool_sse(config, tool_name, {})
379-
print(f"Tool execution result: {result}")
385+
print("Available tools:")
386+
for tool in server.tools[:5]:
387+
print(f" - {tool.name}")
380388
else:
381389
pytest.skip("Could not connect to GitHub MCP server")
382390

0 commit comments

Comments
 (0)