-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
42 lines (32 loc) · 1.06 KB
/
server.py
File metadata and controls
42 lines (32 loc) · 1.06 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
from __future__ import annotations
import os
from mcp.server.fastmcp import FastMCP
from deepfetch import __version__
from deepfetch.logging import configure_logging
from deepfetch.search.internet_search import (
INTERNET_SEARCH_TOOL_DESCRIPTION,
internet_search,
)
from deepfetch.search.pdf_utils import (
PDF_EXTRACT_TEXT_TOOL_DESCRIPTION,
pdf_extract_text,
)
_log_path = os.getenv("DEEPFETCH_LOG_PATH")
_log_dir = os.getenv("DEEPFETCH_LOG_DIR")
if _log_path or _log_dir:
configure_logging(
os.getenv("DEEPFETCH_LOG_LEVEL", "INFO"),
log_path=_log_path,
run_id=os.getenv("DEEPFETCH_LOG_RUN_ID"),
)
mcp = FastMCP("deepfetch")
mcp._mcp_server.version = __version__
mcp.tool(description=INTERNET_SEARCH_TOOL_DESCRIPTION)(internet_search)
mcp.tool(description=PDF_EXTRACT_TEXT_TOOL_DESCRIPTION)(pdf_extract_text)
def run() -> None:
transport = str(os.getenv("DEEPFETCH_TRANSPORT", "stdio") or "stdio").strip()
if not transport:
transport = "stdio"
mcp.run(transport=transport)
if __name__ == "__main__":
run()