diff --git a/.gitignore b/.gitignore index 4a945b3..3a12a40 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +reseau + # ---> macOS # General .DS_Store @@ -5,7 +7,8 @@ .LSOverride # Icon must end with two \r -Icon +Icon + # Thumbnails ._* @@ -201,4 +204,3 @@ cython_debug/ # PyPI configuration file .pypirc - diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e05aa76 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Dockerfile +FROM python:3.11-slim + +WORKDIR /app + +# Installer le SDK MCP Python +RUN pip install --no-cache-dir fastmcp + +# Copier le serveur +COPY src/* . + +# Exposer le port +EXPOSE 6666 + +# Lancer le serveur +CMD ["python", "./mon_mcp.py"] diff --git a/opencode.json b/opencode.json new file mode 100644 index 0000000..ad01805 --- /dev/null +++ b/opencode.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://opencode.ai/config.json", + "mcp": { + "echo-server": { + "type": "remote", + "url": "http://localhost:7860/mcp" + } + } +} diff --git a/src/mon_mcp.py b/src/mon_mcp.py new file mode 100644 index 0000000..6aed017 --- /dev/null +++ b/src/mon_mcp.py @@ -0,0 +1,32 @@ +from fastmcp import FastMCP + +# Création du serveur MCP +mcp = FastMCP("Serveur Echo MCP") + + +# Déclaration d'un outil +@mcp.tool(description="Renvoie le texte reçu") +def echo_texte(texte: str) -> str: + return f"Écho du serveur : {texte} mec" + + +# Déclaration d'un second outil pour démonstration +@mcp.tool(description="Renvoie le texte en majuscules") +def shout_texte(texte: str) -> str: + return texte.upper() + + +# Déclaration d'un outil pour additionner deux nombres +@mcp.tool(description="Additionne deux nombres") +def additionner(a: float, b: float) -> float: + return a + b + + +# Lancement du serveur MCP +if __name__ == "__main__": + mcp.run( + transport="http", # Transport réseau HTTP + host="0.0.0.0", # Adresse d’écoute + port=7860, # Port TCP + path="/mcp", # Chemin MCP (par défaut /mcp) + ) diff --git a/test.py b/test.py new file mode 100644 index 0000000..2b0a299 --- /dev/null +++ b/test.py @@ -0,0 +1,7 @@ +import requests + +url = "http://localhost:6666" # point d'entrée principal +payload = {"tool": "echo", "input": {"text": "Bonjour MCP!"}} + +resp = requests.post(url, json=payload) +print(resp.json()) # {"echo": "Bonjour MCP!"} attendu