import argparse
import asyncio
import json
from mcp import ClientSession
from mcp.client.stdio import StdioServerParameters, stdio_client
async def run_tests(test_all: bool, test_github: bool, test_docs: bool) -> None:
server_params = StdioServerParameters(
command="python",
args=["server.py"],
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
if test_all or test_github:
repo = await session.call_tool("get_repository", {})
print("\n=== get_repository ===")
print(json.dumps(repo.content, indent=2))
file_out = await session.call_tool(
"get_file_content",
{"path": "README.md"},
)
print("\n=== get_file_content (README.md) ===")
print(json.dumps(file_out.content, indent=2)[:2000])
if test_all or test_docs:
docs_out = await session.call_tool(
"search_docs",
{"keyword": "Rate Limits", "max_results": 5},
)
print("\n=== search_docs (keyword='Rate Limits') ===")
print(json.dumps(docs_out.content, indent=2))
def main() -> None:
p = argparse.ArgumentParser()
p.add_argument("--test-all", action="store_true")
p.add_argument("--test-github", action="store_true")
p.add_argument("--test-docs", action="store_true")
args = p.parse_args()
# default: run all
if not (args.test_all or args.test_github or args.test_docs):
args.test_all = True
asyncio.run(run_tests(args.test_all, args.test_github, args.test_docs))
if __name__ == "__main__":
main()