Learn-AI / mcp_demo.py
fffffwl's picture
init
d8229c6
raw
history blame contribute delete
827 Bytes
import asyncio
import os
from typing import Any
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
MCP_BASE = os.getenv("TOPCODER_MCP_BASE", "https://api.topcoder-dev.com/v6/mcp/mcp")
async def main() -> None:
async with streamablehttp_client(MCP_BASE) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
names = [t.name for t in tools.tools]
print("Tools:", names)
# If a challenges tool exists, try a harmless list/describe call signature
# We just print availability here; you can extend to actual tool calls once schema is known
def run() -> None:
asyncio.run(main())
if __name__ == "__main__":
run()