About mcp-server-test
A Python project note for testing an MCP server, focused on setting up an environment with pyenv and troubleshooting client startup failures. It is intended as a reference for developers configuring a local MCP server.
Key features
- 01Python environment setup notes
- 02MCP server launch configuration
- 03Python command path troubleshooting
Use cases
- 01Set up a Python environment with pyenv
- 02Configure a client to launch a local server
- 03Troubleshoot spawn python ENOENT
MCP support
The example configures an MCP client to launch a local server through a Python command; it does not describe exposed tools or resources.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEmcp-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"
]
}
}
}
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.