MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / list_tools

Function list_tools

AskAgent/python/chatbot_interface.py:73–122  ·  view source on GitHub ↗

Forward list_tools request to NLWeb

()

Source from the content-addressed store, hash-verified

71
72 @server.list_tools()
73 async def list_tools() -> list[Tool]:
74 """Forward list_tools request to NLWeb"""
75 result = await forward_to_nlweb("list_tools", {}, server_url, endpoint)
76
77 if "error" in result:
78 # Fallback to default if server is unavailable
79 return [
80 Tool(
81 name="ask_nlw",
82 description="Connects with the NLWeb server to answer questions",
83 inputSchema={
84 "type": "object",
85 "properties": {
86 "query": {
87 "type": "string",
88 "description": "The query string to send to the NLWeb server"
89 }
90 },
91 "required": ["query"]
92 }
93 )
94 ]
95
96 # Extract tools from the response
97 try:
98 tools = result.get("response", {}).get("tools", [])
99 return [Tool(
100 name=tool["name"],
101 description=tool["description"],
102 inputSchema=tool["parameters"]
103 ) for tool in tools]
104 except (KeyError, TypeError) as e:
105 print(f"Error processing tools: {e!s}", file=sys.stderr)
106 # Fallback to default
107 return [
108 Tool(
109 name="ask_nlw",
110 description="Connects with the NLWeb server to answer questions",
111 inputSchema={
112 "type": "object",
113 "properties": {
114 "query": {
115 "type": "string",
116 "description": "The query string to send to the NLWeb server"
117 }
118 },
119 "required": ["query"]
120 }
121 )
122 ]
123
124 @server.list_prompts()
125 async def list_prompts() -> list[Prompt]:

Callers

nothing calls this directly

Calls 3

forward_to_nlwebFunction · 0.85
ToolClass · 0.85
getMethod · 0.80

Tested by

no test coverage detected