mcpField
P
Python Mcp Server Sample

Python Mcp Server Sample

Local
github.com/0shimaxDeveloper Tools1Updated 81w ago

About Python Mcp Server Sample

A Python sample project that demonstrates building an MCP server with the MCP SDK and registering it in Cline. It is aimed at developers learning a basic server setup.

Key features

  1. 01Python project setup with uv
  2. 02MCP SDK installation
  3. 03FastMCP server scaffold
  4. 04Cline server registration example

Use cases

  1. 01Learning the Python MCP server setup flow
  2. 02Starting a small MCP server project

MCP support

Demonstrates creating an MCP server with the Python MCP SDK and configuring Cline to launch it.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README
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
    }
  }
}

Comments

Markdown supported

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.