77from pydantic import AnyUrl
88import logging
99
10- import os
11- # Initialize the LinkupClient
12-
1310server = Server ("mcp-search-linkup" )
1411logger = logging .getLogger ("mcp-search-linkup" )
1512logger .setLevel (logging .INFO )
1613
14+
1715## Logging
1816@server .set_logging_level ()
1917async def set_logging_level (level : types .LoggingLevel ) -> types .EmptyResult :
2018 logger .setLevel (level .upper ())
2119 await server .request_context .session .send_log_message (
22- level = "info" ,
23- data = f"Log level set to { level } " ,
24- logger = "mcp-search-linkup"
20+ level = "info" , data = f"Log level set to { level } " , logger = "mcp-search-linkup"
2521 )
2622 return types .EmptyResult ()
2723
24+
2825## Resources
2926@server .list_resources ()
3027async def list_resources () -> list [types .Resource ]:
3128 return [
3229 types .Resource (
3330 uri = AnyUrl ("https://www.thebridgechronicle.com/media" ),
3431 name = "The Bridge Chronicle" ,
35- mimeType = "text/html"
32+ mimeType = "text/html" ,
3633 )
3734 ]
3835
39- @server .read_resource ()
40- async def read_resource (uri : AnyUrl ) -> str :
41- if str (uri ) == "https://www.thebridgechronicle.com/media" :
42- page = client .content (url = "https://www.thebridgechronicle.com/news/capgemini-employees-walk-together-in-celebration-of-indias-independence" )
43- return page .content
44-
45-
46- raise ValueError ("Resource not found" )
4736
4837## Tools
4938@server .list_tools ()
@@ -60,26 +49,15 @@ async def handle_list_tools() -> list[types.Tool]:
6049 "properties" : {
6150 "query" : {
6251 "type" : "string" ,
63- "description" : "The query to search the web with. This should be a question, no need to write in keywords."
52+ "description" : "The query to search the web with. This should be a question, no need to write in keywords." ,
6453 },
65- "depth" : {
66- "type" : "string" ,
67- "enum" : ["standard" , "deep" ],
68- "default" : "standard" ,
69- "description" : "The depth of the search. Standard is a basic search while deep takes more time to complete but can answer more complex questions."
70- },
71- "output_type" : {
72- "type" : "string" ,
73- "enum" : ["searchResults" , "sourcedAnswer" , "structured" ],
74- "default" : "searchResults" ,
75- "description" : "The type of output to return"
76- }
7754 },
7855 "required" : ["query" ],
7956 },
8057 )
8158 ]
8259
60+
8361@server .call_tool ()
8462async def handle_call_tool (
8563 name : str , arguments : dict | None
@@ -94,8 +72,6 @@ async def handle_call_tool(
9472 raise ValueError ("Missing arguments" )
9573
9674 query = arguments .get ("query" )
97- depth = arguments .get ("depth" , "standard" )
98- output_type = arguments .get ("output_type" , "searchResults" )
9975
10076 if not query :
10177 raise ValueError ("Missing query" )
@@ -104,8 +80,8 @@ async def handle_call_tool(
10480 # Perform the search using LinkupClient
10581 search_response = client .search (
10682 query = query ,
107- depth = depth ,
108- output_type = output_type ,
83+ depth = "standard" ,
84+ output_type = "searchResults" ,
10985 )
11086
11187 return [
@@ -115,6 +91,7 @@ async def handle_call_tool(
11591 )
11692 ]
11793
94+
11895async def main ():
11996 # Run the server using stdin/stdout streams
12097 async with mcp .server .stdio .stdio_server () as (read_stream , write_stream ):
@@ -131,5 +108,6 @@ async def main():
131108 ),
132109 )
133110
111+
134112if __name__ == "__main__" :
135- asyncio .run (main ())
113+ asyncio .run (main ())
0 commit comments