Skip to main content
Glama

🏗️ 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: MCP Shell Server

🚀 Features

Tools (Funktionen)

Dateisystem

  • read_file - Dateiinhalte lesen

  • write_file - Dateien schreiben

  • list_directory - Verzeichnisinhalte auflisten

Datenbank

  • query_sqlite - SELECT-Abfragen ausfĂźhren

  • execute_sql - INSERT/UPDATE/DELETE ausfĂźhren

  • list_tables - Tabellen auflisten

Web/API

  • fetch_url - URLs abrufen

  • http_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-Assistent

  • sql_helper - SQL-Query-Generator

  • system_diagnostics - System-Diagnose-Helfer

  • api_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.txt

2. 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.py

Der Server läuft auf:

  • HTTP: http://localhost:8000

  • SSE Endpoint: http://localhost:8000/sse

  • Messages Endpoint: http://localhost:8000/messages

Client Demo ausfĂźhren

cd client
python client.py

Die Demo zeigt:

  1. Verbindung zum Server

  2. Auflistung aller Tools, Resources und Prompts

  3. Beispiel-Aufrufe von Tools

  4. Lesen von Resources

  5. 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 ändern

Timeout 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 mcp Python-Paket

Protokoll-Flow

  1. Client verbindet sich via SSE zum /sse Endpoint

  2. Initialize: Client sendet Initialisierung

  3. Capabilities: Server antwortet mit verfĂźgbaren Tools/Resources/Prompts

  4. Requests: Client kann Tools aufrufen, Resources lesen, Prompts abrufen

  5. Responses: Server antwortet mit strukturierten Daten

🎓 Learning Path

1. Grundlagen verstehen

2. Server erkunden

  • Starte den Server und Ăśffne server/main.py

  • Schaue dir die Tool-Registrierung an (@app.list_tools())

  • Verstehe wie Tools aufgerufen werden (@app.call_tool())

3. Client ausprobieren

  • FĂźhre client/client.py aus

  • Modifiziere 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:

  1. Shell-Befehle: execute_shell_command kann beliebige Befehle ausfĂźhren

    • Implementiere Whitelisting/Sandboxing

    • Validiere Input streng

  2. Dateisystem-Zugriff: Tools haben Zugriff auf das gesamte Dateisystem

    • Beschränke auf bestimmte Verzeichnisse

    • Implementiere Permissions

  3. Datenbank-Zugriff: SQL-Injection-Gefahr

    • Verwende Prepared Statements

    • Validiere Queries

  4. HTTP-Requests: SSRF-Gefahr (Server-Side Request Forgery)

    • Blocke interne IPs

    • Implementiere Rate-Limiting

  5. 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.py

Einzelne 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

  1. Erstelle Funktion in server/tools/

  2. Registriere in server/main.py bei @app.list_tools()

  3. 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.

F
license - not found
-
quality - not tested
B
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • MCP server for interacting with the Supabase platform

  • The MCP server for Azure DevOps, bringing the power of Azure DevOps directly to your agents.

  • An MCP server for deep research or task groups

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DerWolk/mcp-infra'

If you have feedback or need assistance with the MCP directory API, please join our Discord server