Python Mcp Server Sample
Description
### uvのインストール ``` curl -LsSf https://astral.sh/uv/install.sh | sh ``` ### Pythonプロジェクトを作成 ``` # mcp-server-demoというPythonプロジェクトを作成 uv init mcp-server-demo ``` ### MCP SDKのインストール ``` # mcp-server-demoプロジェクト配下に移動 cd mcp-server-demo # mcp-server-demoプロジェクトにmcp sdkをインストール uv add…
About
### uvのインストール ``` curl -LsSf https://astral.sh/uv/install.sh | sh ``` ### Pythonプロジェクトを作成 ``` # mcp-server-demoというPythonプロジェクトを作成 uv init mcp-server-demo ``` ### MCP SDKのインストール ``` # mcp-server-demoプロジェクト配下に移動 cd mcp-server-demo # mcp-server-demoプロジェクトにmcp sdkをインストール uv add "mcp[cli]" ``` ### MCPサーバの構築…
Details
- Author
- 0shimax
- Downloads
- 220
- Categories
- Other
Jump to
- Built with FastMCP for quick server setup.
- Includes a single add tool that sums two integers.
- Runs with debug mode enabled for development.
- Uses stdio transport for local communication.
- Designed for integration with the Cline MCP client.
Install uv, then create a new Python project with uv init mcp-server-demo, install the MCP CLI SDK (uv add "mcp[cli]"), and write the provided server code in server.py. To run, use the command uv run server.py from the project directory, or register the server in Cline’s MCP configuration by specifying the uv command with the --directory and run arguments.
uvのインストール
curl -LsSf https://astral.sh/uv/install.sh | sh
Pythonプロジェクトを作成
# mcp-server-demoというPythonプロジェクトを作成
uv init mcp-server-demo
MCP SDKのインストール
# mcp-server-demoプロジェクト配下に移動
cd mcp-server-demo
mcp-server-demoプロジェクトにmcp sdkをインストール
uv add "mcp[cli]"
MCPサーバの構築
server.pyファイルの作成(ファイル名はなんでもよい)
mv main.py server.py
server.pyに以下のように記述
from mcp.server.fastmcp import FastMCP
Create an MCP server with debug enabled
mcp = FastMCP("Demo", debug=True)
Add an addition tool
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers"""
return a + b
Add this part to run the server
if __name__ == "__main__":
# stdioトランスポートを使用
print("Starting MCP server in stdio mode")
mcp.run(transport="stdio")
ClineへのMCPサーバの登録
ClineのプロジェクトMCPファイルを以下のように編集{
"mcpServers": {
"mcp-demo-server": {
"command": "uv",
"args": [
"--directory",
<path to mcp-server-demo>,
"run",
"server.py"
],
"alwaysAllow": [
"add"
],
"disabled": false
}
}
}
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



