mcp-server-test

i-icc/mcp-server-test

3.1

If you are the rightful owner of mcp-server-test and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MCP server test involves setting up a Model Context Protocol server using Python, specifically with pyenv for environment management.

mcp-server-test

MCP サーバーのテスト

公式だと uv を使用して環境構築している

pyenv でやりたい

https://modelcontextprotocol.io/quickstart/server

まずは好きなバージョンのpython をインストール

Python 3.10 or higher installed.

と言われているのでとりあえず 3.11.5 をインストール

global で設定

コードはそのまま

MCPの設定

{
    "mcpServers": {
        "weather": {
            "command": "python",
            "args": [
                "MY-PATH/mcp-server-test/src/main.py"
            ]
        }
    }
}

すると下記のエラーが

2025-04-15T14:13:02.862Z [weather] [info] Initializing server...

2025-04-15T14:13:02.891Z [weather] [error] spawn python ENOENT {"context":"connection","stack":"Error: spawn python ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n    at onErrorNT (node:internal/child_process:483:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}

2025-04-15T14:13:02.891Z [weather] [error] spawn python ENOENT {"stack":"Error: spawn python ENOENT\n    at ChildProcess._handle.onexit (node:internal/child_process:285:19)\n    at onErrorNT (node:internal/child_process:483:16)\n    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"}

2025-04-15T14:13:02.896Z [weather] [info] Server transport closed

2025-04-15T14:13:02.896Z [weather] [info] Client transport closed

2025-04-15T14:13:02.896Z [weather] [info] Server transport closed unexpectedly, this is likely due to the process exiting early. If you are developing this MCP server you can add output to stderr (i.e. `console.error('...')` in JavaScript, `print('...', file=sys.stderr)` in python) and it will appear in this log.

2025-04-15T14:13:02.896Z [weather] [error] Server disconnected. For troubleshooting guidance, please visit our [debugging documentation](https://modelcontextprotocol.io/docs/tools/debugging) {"context":"connection"}

python コマンドがないとのことなので下記に修正します

$ which python
MY-PATH/.pyenv/shims/python
{
    "mcpServers": {
        "weather": {
            "command": "MY-PATH/.pyenv/shims/python",
            "args": [
                "MY-PATH/mcp-server-test/src/main.py"
            ]
        }
    }
}