-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
early version of huggingface open deep research project as an mcp ser…
…ver and copier mcp server template (#322) It works, but requires API keys for services that we'd like to swap out, but merging for folks to access early.
- Loading branch information
Showing
51 changed files
with
6,287 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
GIPHY_API_KEY=REPLACE_WITH_YOUR_GIPHY_API_KEY | ||
# Optional for the service | ||
#LOG_LEVEL=DEBUG | ||
|
||
# Required for the service | ||
GIPHY_API_KEY=REPLACE_WITH_YOUR_GIPHY_API_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
repo_root = $(shell git rev-parse --show-toplevel) | ||
include $(repo_root)/tools/makefiles/python.mk | ||
include $(repo_root)/tools/makefiles/docker-assistant.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from dotenv import load_dotenv | ||
from . import config | ||
|
||
# Load environment variables from .env into the settings object. | ||
load_dotenv() | ||
settings = config.Settings() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os | ||
from pydantic_settings import BaseSettings | ||
|
||
log_level = os.environ.get("LOG_LEVEL", "INFO") | ||
|
||
def load_required_env_var(env_var_name: str) -> str: | ||
value = os.environ.get(env_var_name, "") | ||
if not value: | ||
raise ValueError(f"Missing required environment variable: {env_var_name}") | ||
return value | ||
|
||
giphy_api_key = load_required_env_var("GIPHY_API_KEY") | ||
|
||
class Settings(BaseSettings): | ||
log_level: str = log_level | ||
giphy_api_key: str = giphy_api_key |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import Optional | ||
from mcp.server.fastmcp import FastMCP | ||
|
||
|
||
from . import settings | ||
from .giphy_search import perform_search | ||
|
||
# Set the name of the MCP server | ||
server_name = "GIPHY MCP Server" | ||
|
||
def create_mcp_server() -> FastMCP: | ||
|
||
# Initialize FastMCP with debug logging. | ||
mcp = FastMCP(name=server_name, log_level=settings.log_level) | ||
|
||
# Define each tool and its setup. | ||
|
||
@mcp.tool() | ||
async def giphy_search_tool(context: str, search_term: str) -> Optional[list]: | ||
# Perform search using context and search term | ||
search_results = perform_search(context, search_term) | ||
|
||
# Sampling isn't implemented in FastMCP yet, so we'll need to extend it. | ||
# For now, just return a simplified list. | ||
|
||
return [ | ||
{ | ||
"title": result["title"], | ||
"alt_text": result["alt_text"], | ||
"image": result["images"]["original"], | ||
} | ||
for result in search_results | ||
] | ||
|
||
# # Create sampling request message, integrating search results and context | ||
# sampling_result = await perform_sampling(search_results, context) | ||
|
||
# # Extract and return image selected by sampling | ||
# final_image = next( | ||
# (content for content in sampling_result if content['type'] == "image"), None) | ||
# return final_image["data"] if final_image else None | ||
|
||
return mcp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Main entry point for the MCP Server | ||
|
||
import argparse | ||
|
||
from .server import create_mcp_server | ||
|
||
def main() -> None: | ||
# Command-line arguments for transport and port | ||
parse_args = argparse.ArgumentParser(description=f"Start the MCP server.") | ||
parse_args.add_argument( | ||
"--transport", | ||
default="stdio", | ||
choices=["stdio", "sse"], | ||
help="Transport protocol to use ('stdio' or 'sse'). Default is 'stdio'.", | ||
) | ||
parse_args.add_argument( | ||
"--port", | ||
type=int, | ||
default=8000, | ||
help="Port to use for SSE (default is 8000)." | ||
) | ||
args = parse_args.parse_args() | ||
|
||
mcp = create_mcp_server() | ||
if args.transport == "sse": | ||
mcp.settings.port = args.port | ||
|
||
mcp.run(transport=args.transport) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Optional for the service | ||
#DATA_FOLDER=.data | ||
#LOG_LEVEL=DEBUG | ||
|
||
# Required for the service | ||
HUGGINGFACE_API_KEY=YOUR_HUGGINGFACE_API_KEY | ||
OPENAI_API_KEY=YOUR_OPENAI_API_KEY | ||
SERP_API_KEY=YOUR_SERP_API_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Python files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# Virtual environment | ||
.venv | ||
|
||
# Poetry | ||
poetry.lock | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
|
||
# Environment variables | ||
.env |
15 changes: 15 additions & 0 deletions
15
mcp-servers/mcp-server-open-deep-research/.vscode/launch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "debugpy", | ||
"request": "launch", | ||
"name": "mcp-servers: mcp-server-open-deep-research", | ||
"cwd": "${workspaceFolder}", | ||
"module": "mcp_server.start", | ||
"args": ["--transport", "sse", "--port", "6020"], | ||
"consoleTitle": "mcp-server-open-deep-research" | ||
// "justMyCode": false // Set to false to debug external libraries | ||
} | ||
] | ||
} |
Oops, something went wrong.