Skip to main content
Glama
nictuku

Python MCP Server Template

by nictuku

py-mcp-server-テンプレート

このリポジトリは、Pythonで独自のMCP(モデルコンテキストプロトコル)サーバーを作成するのに役立つテンプレートです。始めるには、このリポジトリをフォークしてください。

UVを使ったセットアップ

このプロジェクトでは、Pythonのパッケージングと仮想環境の管理にuvを使用しています。UV uvインストールされていない場合は、公式のUVインストールガイドを参照してください。

  1. フォークしたリポジトリをクローンします。

    git clone https://github.com/YOUR_USERNAME/YOUR_REPOSITORY_NAME.git
    cd YOUR_REPOSITORY_NAME
  2. **仮想環境を作成してアクティブ化します。**通常、 uvプロジェクト ルートに.venvディレクトリを作成します。

    uv venv
    source .venv/bin/activate  # On macOS/Linux
    # .venv\Scripts\activate   # On Windows
  3. **依存関係のインストール:**このプロジェクトは、依存関係を管理するためにpyproject.tomlを使用します。

    uv pip install .

    新しい依存関係を追加する場合は、 pyproject.tomlファイルで定義し、このコマンドを再度実行してください。何らかの理由でrequirements.txtファイルを使用している場合は、 uv pip install -r requirements.txtでインストールできます。

Related MCP server: mcp-framework-starter

サーバーの実行

mcp_server.pyスクリプトは MCP サーバーを起動します。

サーバーを直接実行するには:

uv run python mcp_server.py

Claude DesktopまたはCursorとの統合

このMCPサーバーをClaude DesktopやCursorなどのアプリケーションで使用するには、アプリケーションの設定で設定する必要があります。設定には通常、サーバーを実行するコマンドの指定が含まれます。

設定例を以下に示します。/ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME /ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAMEシステム上のプロジェクトディレクトリへの実際の絶対パスに置き換える必要があります。

{
    "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"
        }
    }
}

構成の説明:

  • "my-custom-python-server" : これはサーバー構成に付ける名前です。

  • "command": "uv" : 実行するコマンドとしてuvを指定します。

  • "args" : uvコマンドの引数のリスト:

    • "run" : 管理対象環境内でコマンドを実行するようにuvに指示します。

    • "--python" : 使用するPythonインタープリタを指定します。UV uv環境( .venv/bin/python )内のPythonインタープリタを指定することが重要です。

    • "/ABSOLUTE/PATH/TO/PARENT/FOLDER/YOUR_REPOSITORY_NAME/mcp_server.py" : サーバー スクリプトへの絶対パス。

  • "workingDirectory" : サーバー プロセスの作業ディレクトリを指定します。これはプロジェクトのルート ディレクトリである必要があります。

重要:

  • argsとworkingDirectory内のパスがシステムに対して正しいことを確認してください。

  • アプリケーションがuvを見つけられない場合は、 "command"フィールドにフルパスを指定する必要があるかもしれません。通常、macOSまたはLinuxのターミナルでwhich uv実行するか、Windowsの場合はwhere uv実行することで、このパスを見つけることができます。

  • サーバーは、 mcp_server.py ( mcp.run(transport='stdio') ) で設定されているとおり、デフォルトでstdioをリッスンします。これは通常、Cursor などのアプリケーションが期待するものです。

設定後、アプリケーションは Python MCP サーバーと通信できるようになります。

Available Tools

3 tools
get_jokeD
ParametersJSON Schema
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
ParametersJSON Schema
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
ParametersJSON Schema
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
    3 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
    3 npm
    -