push-umtslxtpqxls #1

Merged
eric merged 5 commits from push-umtslxtpqxls into main 2026-01-31 10:36:47 +01:00
5 changed files with 68 additions and 2 deletions
Showing only changes of commit 9f9d9bc3b3 - Show all commits

6
.gitignore vendored
View File

@@ -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
.pypirc

16
Dockerfile Normal file
View File

@@ -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"]

9
opencode.json Normal file
View File

@@ -0,0 +1,9 @@
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"echo-server": {
"type": "remote",
"url": "http://localhost:7860/mcp"
}
}
}

32
src/mon_mcp.py Normal file
View File

@@ -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)
)

7
test.py Normal file
View File

@@ -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