Repository navigation
Expand file tree
/
Copy path__init__.py
More file actions
56 lines (46 loc) · 1.58 KB
/
Copy path__init__.py
File metadata and controls
56 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
HTTP client package for MCP interactive clients by acai10.
Exports:
- MCPInteractiveHTTPClient: interactive client using
- streamable-http transport (mcp.run(transport="streamable-http"))
- or SSE transport (mcp.run(transport="sse")), depending on the `transport` argument.
Defines:
- MCPInteractiveHTTPClient:
Wrapper around mcp.client.session.ClientSession with an interactive CLI:
- initialize MCP session
- list tools and let the user choose one
- show tool argument schema and prompt for values
- call the tool and pretty-print the result
- optional logging setup via `activate_logger` argument
Constructor:
MCPInteractiveHTTPClient(
url: str,
transport: str = "http", # "http" (streamable-http) or "sse"
activate_logger: bool = True, # configure logging on first use if True
)
Example usage:
from http_client import MCPInteractiveHTTPClient
import asyncio
HTTP_URL = "http://localhost:8000/mcp"
SSE_URL = "http://localhost:8000/sse"
async def main_http():
async with MCPInteractiveHTTPClient(
HTTP_URL,
transport="http",
activate_logger=True,
) as client:
await client.run()
async def main_sse():
async with MCPInteractiveHTTPClient(
SSE_URL,
transport="sse",
activate_logger=True,
) as client:
await client.run()
if __name__ == "__main__":
asyncio.run(main_http())
"""
from .http_client import MCPInteractiveHTTPClient
__all__ = [
"MCPInteractiveHTTPClient",
]