mcp-infra
Provides tools to query and manage SQLite databases, including SELECT, INSERT/UPDATE/DELETE, and listing tables.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-infrashow system info"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
đď¸ MCP Infrastructure
Eine vollständige Model Context Protocol (MCP) Implementierung in Python mit SSE-Transport, die Tools, Resources und Prompts bereitstellt.
đ Ăberblick
Dieses Projekt implementiert das offizielle MCP-Protokoll von Anthropic und bietet:
MCP Server mit SSE (Server-Sent Events) Transport
MCP Client zum Testen und zur Interaktion
11 Tools fĂźr Dateisystem, Datenbank, Web, System und Shell-Operationen
Resources fĂźr strukturierten Zugriff auf Daten
Prompt Templates fßr häufige Aufgaben
Related MCP server: emcp
đ Features
Tools (Funktionen)
Dateisystem
read_file- Dateiinhalte lesenwrite_file- Dateien schreibenlist_directory- Verzeichnisinhalte auflisten
Datenbank
query_sqlite- SELECT-Abfragen ausfĂźhrenexecute_sql- INSERT/UPDATE/DELETE ausfĂźhrenlist_tables- Tabellen auflisten
Web/API
fetch_url- URLs abrufenhttp_request- HTTP-Requests mit Custom-Headers
System
get_system_info- System-Informationen (CPU, RAM, Disk)list_processes- Laufende Prozesse auflisten
Shell
execute_shell_command- Shell-Befehle ausfĂźhren
Resources (Datenquellen)
file:// - Dateien als Resources
db:// - Datenbank-Tabellen als Resources
system:// - System-Informationen als Resources
Prompts (Templates)
code_review- Code-Review-Assistentsql_helper- SQL-Query-Generatorsystem_diagnostics- System-Diagnose-Helferapi_integration- API-Integration-Guide
đŚ Installation
1. Repository klonen und Setup
cd mcp-infrastructure
python -m venv venv
source venv/bin/activate # Auf Windows: venv\Scripts\activate
pip install -r requirements.txt2. Abhängigkeiten
Das Projekt benĂśtigt:
Python 3.10+
MCP Python SDK
aiohttp (fĂźr SSE-Server)
aiosqlite (fĂźr Datenbank-Tools)
httpx (fĂźr HTTP-Tools)
psutil (fĂźr System-Tools)
đŻ Verwendung
Server starten
cd server
python main.pyDer Server läuft auf:
HTTP:
http://localhost:8000SSE Endpoint:
http://localhost:8000/sseMessages Endpoint:
http://localhost:8000/messages
Client Demo ausfĂźhren
cd client
python client.pyDie Demo zeigt:
Verbindung zum Server
Auflistung aller Tools, Resources und Prompts
Beispiel-Aufrufe von Tools
Lesen von Resources
Verwendung von Prompts
Eigenen Client erstellen
import asyncio
from mcp import ClientSession
from mcp.client.sse import sse_client
async def main():
async with sse_client("http://localhost:8000/sse") as (read, write):
async with ClientSession(read, write) as session:
# Initialize
await session.initialize()
# List tools
tools = await session.list_tools()
print(f"Available tools: {[t.name for t in tools.tools]}")
# Call a tool
result = await session.call_tool("get_system_info", {})
print(f"Result: {result.content}")
# Read a resource
resource = await session.read_resource("system://info")
print(f"Resource: {resource.contents}")
# Get a prompt
prompt = await session.get_prompt(
"code_review",
{"code": "def hello(): return 'world'"}
)
print(f"Prompt: {prompt.messages}")
asyncio.run(main())đď¸ Projektstruktur
mcp-infrastructure/
âââ README.md # Diese Datei
âââ requirements.txt # Python-Abhängigkeiten
â
âââ server/ # MCP Server
â âââ main.py # Server-Hauptdatei (SSE Transport)
â âââ tools/ # Tool-Implementierungen
â â âââ filesystem.py # Dateisystem-Tools
â â âââ database.py # Datenbank-Tools
â â âââ web.py # Web/API-Tools
â â âââ system.py # System-Tools
â â âââ shell.py # Shell-Tools
â âââ resources/ # Resource-Provider
â â âââ providers.py # File/DB/System Resource Provider
â âââ prompts/ # Prompt-Templates
â âââ templates.py # Template-Definitionen
â
âââ client/ # MCP Client
â âââ client.py # Client-Implementierung + Demo
â
âââ tests/ # Tests (TODO)
âââ ...đ§ Konfiguration
Server-Port ändern
In server/main.py:
site = web.TCPSite(runner, "localhost", 8000) # Port hier ändernTimeout fßr Shell-Befehle anpassen
In server/tools/shell.py:
async def execute_shell_command(command: str, timeout: int = 30): # Timeout hierđĄ MCP Protokoll
Dieses Projekt implementiert das offizielle Model Context Protocol (MCP) von Anthropic:
Transport: SSE (Server-Sent Events) Ăźber HTTP
Capabilities: Tools, Resources, Prompts
SDK: Verwendet das offizielle
mcpPython-Paket
Protokoll-Flow
Client verbindet sich via SSE zum
/sseEndpointInitialize: Client sendet Initialisierung
Capabilities: Server antwortet mit verfĂźgbaren Tools/Resources/Prompts
Requests: Client kann Tools aufrufen, Resources lesen, Prompts abrufen
Responses: Server antwortet mit strukturierten Daten
đ Learning Path
1. Grundlagen verstehen
Lies die offizielle MCP-Dokumentation
Verstehe Tools, Resources und Prompts
Lerne SSE (Server-Sent Events)
2. Server erkunden
Starte den Server und Ăśffne
server/main.pySchaue dir die Tool-Registrierung an (
@app.list_tools())Verstehe wie Tools aufgerufen werden (
@app.call_tool())
3. Client ausprobieren
FĂźhre
client/client.pyausModifiziere die Demo-Aufrufe
Erstelle eigene Client-Interaktionen
4. Erweitern
FĂźge neue Tools hinzu (z.B. E-Mail-Versand)
Erstelle neue Resources (z.B. Git-Repositories)
Entwickle neue Prompt-Templates
đ Sicherheitshinweise
â ď¸ WICHTIG: Dieses Projekt ist fĂźr Learning/Experimentieren gedacht!
Produktions-Ăberlegungen:
Shell-Befehle:
execute_shell_commandkann beliebige Befehle ausfĂźhrenImplementiere Whitelisting/Sandboxing
Validiere Input streng
Dateisystem-Zugriff: Tools haben Zugriff auf das gesamte Dateisystem
Beschränke auf bestimmte Verzeichnisse
Implementiere Permissions
Datenbank-Zugriff: SQL-Injection-Gefahr
Verwende Prepared Statements
Validiere Queries
HTTP-Requests: SSRF-Gefahr (Server-Side Request Forgery)
Blocke interne IPs
Implementiere Rate-Limiting
Authentication: Aktuell keine Authentifizierung
FĂźge API-Keys hinzu
Implementiere OAuth/JWT
đ§Ş Testing
Tools testen
# Server starten
cd server && python main.py
# In anderem Terminal: Client ausfĂźhren
cd client && python client.pyEinzelne Tools testen
from server.tools.filesystem import read_file
import asyncio
result = asyncio.run(read_file("README.md"))
print(result)đ ď¸ Entwicklung
Neue Tools hinzufĂźgen
Erstelle Funktion in
server/tools/Registriere in
server/main.pybei@app.list_tools()Handle in
@app.call_tool()
Beispiel:
# In server/tools/email.py
async def send_email(to: str, subject: str, body: str):
# Implementation
return {"success": True}
# In server/main.py
@app.list_tools()
async def list_tools():
return [
# ... existing tools
types.Tool(
name="send_email",
description="Send an email",
inputSchema={
"type": "object",
"properties": {
"to": {"type": "string"},
"subject": {"type": "string"},
"body": {"type": "string"}
},
"required": ["to", "subject", "body"]
}
)
]
@app.call_tool()
async def call_tool(name: str, arguments: Any):
if name == "send_email":
result = await send_email(
arguments["to"],
arguments["subject"],
arguments["body"]
)
# ... handle other toolsđ Ressourcen
đ¤ Beiträge
Dieses Projekt ist ein Learning-Projekt. FĂźhle dich frei:
Issues zu erstellen
Pull Requests einzureichen
Verbesserungen vorzuschlagen
đ Lizenz
MIT License - Frei verwendbar fĂźr Learning und Experimente
đŻ Roadmap
Unit Tests hinzufĂźgen
WebSocket-Transport implementieren
Authentication/Authorization
Docker-Container
Mehr Tools (Git, Docker, etc.)
Web-UI fĂźr Testing
Logging und Monitoring
Rate Limiting
Input Validation/Sanitization
đĄ Beispiele
Beispiel 1: Datei lesen und analysieren
# Mit Client
result = await session.call_tool("read_file", {"path": "data.txt"})
# Dann verwende ein Prompt
prompt = await session.get_prompt("code_review", {"code": result.content[0].text})Beispiel 2: Datenbank abfragen
# Tabellen auflisten
tables = await session.call_tool("list_tables", {"db_path": "app.db"})
# Query ausfĂźhren
result = await session.call_tool("query_sqlite", {
"db_path": "app.db",
"query": "SELECT * FROM users LIMIT 10"
})Beispiel 3: System-Diagnose
# System-Info abrufen
info = await session.call_tool("get_system_info", {})
# Mit Diagnostics-Prompt kombinieren
prompt = await session.get_prompt("system_diagnostics", {
"issue": f"High memory usage: {info.content[0].text}"
})đ Troubleshooting
Server startet nicht
PrĂźfe ob Port 8000 frei ist:
lsof -i :8000Ăndere Port in
main.py
Client kann nicht verbinden
Stelle sicher, dass Server läuft
PrĂźfe URL:
http://localhost:8000/sseĂberprĂźfe Firewall-Einstellungen
Tools funktionieren nicht
PrĂźfe Logs im Server
Validiere Input-Parameter
Teste Tools direkt (siehe Testing)
Happy MCP Learning! đ
Bei Fragen oder Problemen, erstelle ein Issue im Repository.
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server with quote and live cryptocurrency price tools, local and cloud-deployed transports.
An MCP server that provides read access to your cloud storage providers, bank accounts and more.
Nifty's MCP server â exposes tasks, projects, messages, and files as tools for AI agents.
Related MCP Servers
- AlicenseBqualityAmaintenanceA secure MCP server for shell operations, terminal management, and process control, enabling AI assistants to safely execute commands and manage interactive sessions.13153 npm6MIT
- FlicenseNot gradedqualityDmaintenanceMCP server providing filesystem operations, shell execution, and web search capabilities.-
- AlicenseNot gradedqualityBmaintenanceA full-featured MCP server for local development with filesystem, shell, editor, session persistence, and security features.481 PyPI2MIT
- AlicenseNot gradedqualityCmaintenanceA production-ready MCP server for secure, session-based command execution, file manipulation, and system inspection via local terminal sessions.9 npmISC