Ajout de Dockerfile et configuration MCP
Ajout du Dockerfile pour containeriser l'application MCP - Création du Dockerfile avec l'image Python 3.11 slim - Installation du SDK FastMCP - Copie du code source dans le conteneur - Exposition du port 6666 - Configuration du point d'entrée Ajout du fichier opencode.json pour la configuration MCP Ajout du script Python src/mon_mcp.py avec les outils echo, shout et additionner Ajout du fichier test.py pour les tests de l'API
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,3 +1,5 @@
|
|||||||
|
reseau
|
||||||
|
|
||||||
# ---> macOS
|
# ---> macOS
|
||||||
# General
|
# General
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -5,7 +7,8 @@
|
|||||||
.LSOverride
|
.LSOverride
|
||||||
|
|
||||||
# Icon must end with two \r
|
# Icon must end with two \r
|
||||||
Icon
|
Icon
|
||||||
|
|
||||||
|
|
||||||
# Thumbnails
|
# Thumbnails
|
||||||
._*
|
._*
|
||||||
@@ -201,4 +204,3 @@ cython_debug/
|
|||||||
|
|
||||||
# PyPI configuration file
|
# PyPI configuration file
|
||||||
.pypirc
|
.pypirc
|
||||||
.pypirc
|
|
||||||
|
|||||||
16
Dockerfile
Normal file
16
Dockerfile
Normal 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
9
opencode.json
Normal 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
32
src/mon_mcp.py
Normal 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)
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user