paycoreDb

paycoreDb

Custom MCP server connected to a read-only SQLite database, exposing a schema resource and a query tool for safe data retrieval.

Category
Visit Server

README

TP Chapitre 4 — Serveur MCP custom & agent contrôlé

Ce dossier contient tous les fichiers nécessaires au TP : serveur MCP custom, base SQLite fictive, outils SQL read-only, agent Gemini et orchestration multi-agents.

1. Créer et ouvrir le projet

mkdir paycore-mcp-agent
cd paycore-mcp-agent
code .

Copiez les fichiers de cette archive dans le dossier paycore-mcp-agent.

2. Créer l'environnement Python

PowerShell :

py -m venv .venv
.\.venv\Scripts\Activate.ps1

Si PowerShell bloque :

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\.venv\Scripts\Activate.ps1

Bash Windows / Git Bash :

python -m venv .venv
source .venv/Scripts/activate

macOS / Linux / WSL :

python3 -m venv .venv
source .venv/bin/activate

3. Installer les dépendances

pip install -r requirements.txt

4. Configurer Gemini

PowerShell :

$env:GEMINI_API_KEY="VOTRE_CLE_API"

Bash :

export GEMINI_API_KEY="VOTRE_CLE_API"

Tester :

python -c "import os; print('OK' if os.getenv('GEMINI_API_KEY') else 'CLE MANQUANTE')"

5. Créer et tester la base

python setup_db.py

Vérifier qu'il y a 4 lignes :

python -c "import sqlite3; conn=sqlite3.connect('paycore_demo.db'); print(conn.execute('SELECT COUNT(*) FROM incidents').fetchone()); conn.close()"

Résultat attendu :

(4,)

6. Tester les outils SQL

python test_db_tools.py

Résultat attendu :

  • le schéma s'affiche ;
  • la requête SELECT fonctionne ;
  • la requête DELETE est bloquée.

7. Tester le serveur MCP manuellement

python mcp_server.py

Le terminal reste actif. Arrêtez avec :

Ctrl + C

8. Configurer MCP dans VS Code

Le fichier .vscode/mcp.json fourni est configuré pour Windows :

{
  "servers": {
    "paycoreDb": {
      "type": "stdio",
      "command": "${workspaceFolder}\\.venv\\Scripts\\python.exe",
      "args": ["mcp_server.py"],
      "cwd": "${workspaceFolder}"
    }
  }
}

Pour macOS / Linux / WSL, remplacez son contenu par celui de .vscode/mcp.unix.json.

9. Démarrer MCP dans VS Code

Dans VS Code :

Ctrl + Shift + P
MCP: List Servers
paycoreDb
Start Server

Tester la resource :

Ctrl + Shift + P
MCP: Browse Resources
paycoreDb
paycore://schema

10. Prompt de test dans le chat VS Code compatible MCP

Utilise le serveur MCP paycoreDb.

Commence par consulter la resource paycore://schema.

Puis utilise l’outil query_incidents pour répondre à la question suivante :

Quels incidents de double débit sont encore ouverts ou en investigation ?

Contraintes :
- utilise uniquement une requête SELECT ;
- interroge uniquement la table incidents ;
- cite la requête SQL utilisée ;
- cite les données utilisées ;
- indique les limites ;
- ne propose aucune action client automatique.

Résultat attendu : deux incidents double_debit :

  • mobile_app, open, 120.50 ;
  • ecommerce, investigating, 89.90.

11. Tester l'agent Gemini

python agent_demo.py

12. Tester l'orchestration multi-agents

python multi_agent_demo.py

13. Dépannage rapide

  • Serveur MCP absent : vérifier .vscode/mcp.json.
  • Erreur No module named mcp : relancer pip install -r requirements.txt et vérifier le chemin Python de .venv.
  • Base absente : relancer python setup_db.py.
  • Tool absent : MCP: Reset Cached Tools puis redémarrer le serveur.
  • Logs : MCP: List Servers puis Show Output.

14. Ce que l'apprenant doit savoir dire

J'ai développé un serveur MCP custom connecté à une base SQLite. Je l'ai déclaré dans VS Code, puis j'ai utilisé une resource et un tool MCP. J'ai ensuite simulé un agent contrôlé capable de transformer une question en requête SQL, d'exécuter l'outil autorisé, d'observer le résultat et de répondre avec limites.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured