-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample_client.py
More file actions
48 lines (40 loc) · 1.37 KB
/
sample_client.py
File metadata and controls
48 lines (40 loc) · 1.37 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
#!/usr/bin/env python3
"""
Sample client for Cisco NSO MCP Server
This script demonstrates how to connect to the MCP server and list available tools.
"""
import asyncio
import os
from fastmcp import Client
from fastmcp.client.transports import PythonStdioTransport
async def main():
print("Connecting to MCP server...")
# create server parameters
server_params = PythonStdioTransport(
python_cmd="python3",
script_path="cisco_nso_mcp_server/server.py",
args=[
"--nso-scheme=https",
"--nso-address=127.0.0.1",
"--nso-port=8888",
"--nso-username=admin",
"--nso-password=admin",
"--no-nso-verify"
],
env={**os.environ}
)
# create and enter the context managers directly in this task
# Use 'Client(server_params)' to use stdio transport
# Use 'Client("http://127.0.0.1:8000/mcp")' to use HTTP transport
async with Client(server_params) as client:
# list available tools
tools = await client.list_tools()
print("\nAvailable tools:")
for tool in tools:
print(f"- {tool.name}: {tool.description}")
# call a tool
ned_response = await client.call_tool("get_device_ned_ids")
print("\nNED IDs:")
print(ned_response.content[0].text)
if __name__ == "__main__":
asyncio.run(main())