Skip to main content
Glama
nictuku

Python MCP Server Template

by nictuku

py-mcp-Server-Vorlage

Dieses Repository dient als Vorlage für die Erstellung eigener MCP-Server (Model Context Protocol) in Python. Forken Sie dieses Repository, um loszulegen.

Setup mit UV

Dieses Projekt verwendet uv für die Python-Paketierung und die Verwaltung virtueller Umgebungen. Wenn Sie uv nicht installiert haben, lesen Sie bitte die offizielle UV-Installationsanleitung .

  1. Klonen Sie Ihr gegabeltes Repository:

    git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git
    cd YOUR_REPOSITORY_NAME
  2. Erstellen und aktivieren Sie die virtuelle Umgebung: uv erstellt normalerweise ein .venv -Verzeichnis im Stammverzeichnis Ihres Projekts.

    uv venv
    source .venv/bin/activate  # On macOS/Linux
    # .venv\Scripts\activate   # On Windows
  3. Abhängigkeiten installieren: Dieses Projekt verwendet pyproject.toml zur Verwaltung von Abhängigkeiten.

    uv pip install .

    Wenn Sie neue Abhängigkeiten hinzufügen, definieren Sie diese in Ihrer Datei pyproject.toml und führen Sie diesen Befehl erneut aus. Wenn Sie aus irgendeinem Grund eine Datei requirements.txt verwenden, können Sie diese mit uv pip install -r requirements.txt installieren.

Related MCP server: mcp-framework-starter

Ausführen des Servers

Das Skript mcp_server.py startet den MCP-Server.

So führen Sie den Server direkt aus:

uv run python mcp_server.py

Integration mit Claude Desktop oder Cursor

Um diesen MCP-Server mit einer Anwendung wie Claude Desktop oder Cursor zu verwenden, müssen Sie ihn in den Anwendungseinstellungen konfigurieren. Die Konfiguration umfasst in der Regel die Angabe des Befehls zum Ausführen Ihres Servers.

Hier ist ein Beispiel für eine Konfiguration. Sie müssen /ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME durch den tatsächlichen absoluten Pfad zu Ihrem Projektverzeichnis auf Ihrem System ersetzen.

{
    "mcpServers": {
        "my-custom-python-server": {
            "command": "uv",
            "args": [
                "run",
                "--python",
                "/ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME/.venv/bin/python",
                "/ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME/mcp_server.py"
            ],
            "workingDirectory": "/ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME"
        }
    }
}

Erklärung der Konfiguration:

  • "my-custom-python-server" : Dies ist ein Name, den Sie Ihrer Serverkonfiguration geben.

  • "command": "uv" : Gibt uv als auszuführenden Befehl an.

  • "args" : Eine Liste von Argumenten für den uv Befehl:

    • "run" : Weist uv an, einen Befehl innerhalb seiner verwalteten Umgebung auszuführen.

    • "--python" : Gibt den zu verwendenden Python-Interpreter an. Es ist wichtig, dass Sie hier auf den Python-Interpreter in Ihrer virtuellen uv Umgebung ( .venv/bin/python ) verweisen.

    • "/ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME/mcp_server.py" : Der absolute Pfad zu Ihrem Serverskript.

  • "workingDirectory" : Gibt das Arbeitsverzeichnis für den Serverprozess an, das das Stammverzeichnis Ihres Projekts sein sollte.

Wichtig:

  • Stellen Sie sicher, dass die Pfade in den args und workingDirectory für Ihr System korrekt sind.

  • Wenn die Anwendung uv nicht finden kann, müssen Sie möglicherweise den vollständigen Pfad im Feld "command" angeben. Sie finden diesen Pfad normalerweise, indem Sie unter macOS oder Linux which uv oder unter Windows where uv in Ihrem Terminal ausführen.

  • Der Server hört standardmäßig auf stdio , wie in mcp_server.py ( mcp.run(transport='stdio') ) konfiguriert, was normalerweise auch von Anwendungen wie Cursor erwartet wird.

Nach der Konfiguration sollte die Anwendung mit Ihrem Python MCP-Server kommunizieren können.

Available Tools

3 tools
get_jokeD
NameRequiredDescriptionDefault

No parameters

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_pingD
NameRequiredDescriptionDefault
messageYes

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_weatherD
NameRequiredDescriptionDefault
cityYes

TDQS

D1/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updates
    • First observedget_joke
    • First observedget_ping
    • First observedget_weather

TDQS

D1.8/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: get_joke retrieves jokes, get_ping checks server status, and get_weather fetches weather data. There is no overlap in functionality, making it easy for an agent to select the correct tool without confusion.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with 'get_' as the prefix, using snake_case throughout. This predictable naming scheme enhances readability and usability for agents.

Tool Count3/5

With only 3 tools, the server feels thin for a general-purpose template, as it lacks depth in any specific domain. While the count is not extreme, it may be insufficient for complex workflows, though it's reasonable for a basic example.

Completeness2/5

The tool set is severely incomplete for a Python MCP server template, as it only includes three unrelated, trivial functions without covering any meaningful domain or lifecycle operations. There are significant gaps that would hinder agent performance in practical scenarios.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    C
    quality
    D
    maintenance
    A starter template for building Model Context Protocol servers that integrate with AI assistants like Claude and Cursor, providing custom tools, resource providers, and prompt templates.
    2
    5 npm
    -
  • F
    license
    C
    quality
    D
    maintenance
    A starter template for building Model Context Protocol servers that integrate with AI assistants like Claude and Cursor, providing custom tools, resource providers, and prompt templates.
    2
    5 npm
    -