Spaces:
Sleeping
Sleeping
SURIAPRAKASH1
commited on
Commit
Β·
9231ab5
1
Parent(s):
7f68b3b
arg parser -> imple
Browse files
server.py
CHANGED
@@ -6,9 +6,10 @@ from dotenv import load_dotenv
|
|
6 |
import argparse
|
7 |
load_dotenv()
|
8 |
|
9 |
-
#
|
10 |
-
# Logging
|
11 |
-
#
|
|
|
12 |
logger = logging.getLogger(__name__)
|
13 |
logger.setLevel(logging.DEBUG)
|
14 |
|
@@ -18,7 +19,7 @@ file_handler.setFormatter(logging.Formatter(fmt))
|
|
18 |
|
19 |
logger.addHandler(file_handler)
|
20 |
|
21 |
-
# Now import neccessary Packages
|
22 |
try:
|
23 |
from mcp.server.fastmcp import FastMCP
|
24 |
from bs4 import BeautifulSoup
|
@@ -75,7 +76,7 @@ TYPE_MAPPING = {
|
|
75 |
|
76 |
|
77 |
# ----------------------
|
78 |
-
# Available tools for LLM
|
79 |
# -----------------------
|
80 |
|
81 |
async def cricket_source(mode: str, want: str) -> str:
|
@@ -117,6 +118,7 @@ async def cricket_source(mode: str, want: str) -> str:
|
|
117 |
else:
|
118 |
return json.dumps({"error": "No Available details right now!"})
|
119 |
|
|
|
120 |
@mcp.tool()
|
121 |
async def fetch_cricket_details(mode: Literal["live", "upcomming"])-> str:
|
122 |
""" Get cricket Live or Upcomming match details
|
@@ -284,7 +286,6 @@ async def analyze_file_changes(
|
|
284 |
return json.dumps({"error": str(e)})
|
285 |
|
286 |
|
287 |
-
|
288 |
@mcp.tool()
|
289 |
async def get_pr_templates() -> str:
|
290 |
"""List available PR templates with their content."""
|
@@ -300,7 +301,6 @@ async def get_pr_templates() -> str:
|
|
300 |
return json.dumps(templates, indent=2)
|
301 |
|
302 |
|
303 |
-
|
304 |
@mcp.tool()
|
305 |
async def suggest_template(changes_summary: str, change_type: str) -> str:
|
306 |
"""Let LLM analyze the changes and suggest the most appropriate PR template.
|
@@ -330,14 +330,15 @@ async def suggest_template(changes_summary: str, change_type: str) -> str:
|
|
330 |
|
331 |
return json.dumps(suggestion, indent=2)
|
332 |
|
|
|
333 |
if __name__ == "__main__":
|
334 |
# Argument parser to handle CLI args
|
335 |
parser = argparse.ArgumentParser()
|
336 |
|
337 |
-
parser.add_argument("--transport", type= str, help= "Which transport type do you want to run mcp server?. Controlled by --transport cli arg OR TRANSPORT env. If didn't provide either of those default to stdio.")
|
338 |
args = parser.parse_args()
|
339 |
|
340 |
-
transport =
|
341 |
|
342 |
-
logger.info(f"multitools-server is started
|
343 |
mcp.run(transport = transport)
|
|
|
6 |
import argparse
|
7 |
load_dotenv()
|
8 |
|
9 |
+
# -------------
|
10 |
+
# Logging: logging + stdio = β
, print + stdio = β
|
11 |
+
# -------------
|
12 |
+
|
13 |
logger = logging.getLogger(__name__)
|
14 |
logger.setLevel(logging.DEBUG)
|
15 |
|
|
|
19 |
|
20 |
logger.addHandler(file_handler)
|
21 |
|
22 |
+
# Now import neccessary Packages. Sanity checks for libraries cause connecting mcp-client to mcp-server via stdio, client launches mcp-server as subprocess so client uses it's env libraries. If we use different env like in this case, client will invoke connection closed error and never gives any clue what's went wrong that's frustrating π.
|
23 |
try:
|
24 |
from mcp.server.fastmcp import FastMCP
|
25 |
from bs4 import BeautifulSoup
|
|
|
76 |
|
77 |
|
78 |
# ----------------------
|
79 |
+
# Available tools|resources|prompts|sampling for LLM
|
80 |
# -----------------------
|
81 |
|
82 |
async def cricket_source(mode: str, want: str) -> str:
|
|
|
118 |
else:
|
119 |
return json.dumps({"error": "No Available details right now!"})
|
120 |
|
121 |
+
|
122 |
@mcp.tool()
|
123 |
async def fetch_cricket_details(mode: Literal["live", "upcomming"])-> str:
|
124 |
""" Get cricket Live or Upcomming match details
|
|
|
286 |
return json.dumps({"error": str(e)})
|
287 |
|
288 |
|
|
|
289 |
@mcp.tool()
|
290 |
async def get_pr_templates() -> str:
|
291 |
"""List available PR templates with their content."""
|
|
|
301 |
return json.dumps(templates, indent=2)
|
302 |
|
303 |
|
|
|
304 |
@mcp.tool()
|
305 |
async def suggest_template(changes_summary: str, change_type: str) -> str:
|
306 |
"""Let LLM analyze the changes and suggest the most appropriate PR template.
|
|
|
330 |
|
331 |
return json.dumps(suggestion, indent=2)
|
332 |
|
333 |
+
|
334 |
if __name__ == "__main__":
|
335 |
# Argument parser to handle CLI args
|
336 |
parser = argparse.ArgumentParser()
|
337 |
|
338 |
+
parser.add_argument("--transport", type= str, default = "stdio", help= "Which transport type do you want to run mcp server?. Controlled by --transport cli arg OR TRANSPORT env. If didn't provide either of those default to stdio.")
|
339 |
args = parser.parse_args()
|
340 |
|
341 |
+
transport = os.environ.get("TRANSPORT") or args.transport
|
342 |
|
343 |
+
logger.info(f"multitools-server is started via {transport} transport")
|
344 |
mcp.run(transport = transport)
|