MCP Python SDK

MCPGitHubLevel: IntermediateFree
Logo MCP Python SDK

MCP Python SDK

4.0/5OPCAIOS rating

A fast way to write an MCP server in Python.

The official library for writing MCP servers and clients in Python.

What is MCP Python SDK and who is it for?

The OPCAIOS tools library files MCP Python SDK under MCP: it is an MCP server. Short label: GitHub. The official library for writing MCP servers and clients in Python. The MCP Python SDK is the official Python library set for building both MCP servers and MCP clients. For servers, you declare tools, resources and prompts using simple decorators on Python functions with type hints; for clients, you connect to any MCP server. Best suited to: Python developers, automation teams. According to OPCAIOS, the editorial score of MCP Python SDK is 4.0 out of 5: A fast way to write an MCP server in Python.

  • Platform: Python 3.10+ on macOS, Windows, Linux.
  • Difficulty to get started: intermediate.

Is MCP Python SDK free, and what does it cost?

MCP Python SDK is free to use. Free, open source (MIT). Additionally, prices are set by the provider and can change, so compare with the official MCP Python SDK site before you pay. To compare costs, the MCP group of the library also includes Model Context Protocol (free), MCP Servers (free), and MCP specification (free).

What are the main features of MCP Python SDK?

According to OPCAIOS, the standout strengths of MCP Python SDK are official, MIT license, decorator-based declaration, and both server and client, among others. Additionally, the list below explains each of the 6 recorded features.

  1. Official, MIT license: The SDK is developed by the MCP project and licensed under MIT.
  2. Decorator-based declaration: Use @mcp.tool() and @mcp.resource() on Python functions to turn them into tools and data for AI.
  3. Both server and client: Build a server and also use the Client class to call tools on other servers.
  4. Three transports: Supports stdio, Streamable HTTP and SSE.
  5. Handy mcp command: mcp dev opens the server in the Inspector, mcp run runs the server, mcp install installs it into an app.
  6. Upgrade docs available: The documentation has a section introducing v2 and a migration guide.

When should you use MCP Python SDK?

MCP Python SDK is used for 5 kinds of work. When using MCP Python SDK, the most typical case is expose sales data to AI. Additionally, the main audience is python developers, automation teams.

  1. Expose sales data to AI: Write a Python tool that queries the order database so an AI assistant can answer revenue questions.
  2. Reuse existing scripts: Wrap Excel and reporting scripts as tools that employees call through AI.
  3. Connect internal systems: Create a server that calls your company's CRM or warehouse software APIs.
  4. Build your own agent: Use the Client part so your Python app can call tools from multiple MCP servers.
  5. Deploy a remote server: Run the server over Streamable HTTP so many people in the company can share it.

How do you get started with MCP Python SDK?

When using MCP Python SDK for the first time, you go through 5 steps, which OPCAIOS rates as intermediate difficulty. The first step is to install the SDK with uv, and the last is to run over HTTP. The steps are listed in order below.

  1. Install the SDK with uv. A project using uv can add the package with the CLI extra.
  2. Or install with pip. Use pip if you don't use uv; drop [cli] if you don't need the mcp command.
  3. Write a minimal server. Create server.py, initialize MCPServer and attach @mcp.tool() to a function with type hints.
  4. Try it in the Inspector. Open the server in the MCP Inspector to test the tool before connecting it to an AI app.
  5. Run over HTTP. Serve the server over Streamable HTTP; the default endpoint in the README is localhost:8000/mcp.

What is MCP Python SDK?

The MCP Python SDK is the official Python library set for building both MCP servers and MCP clients. For servers, you declare tools, resources and prompts using simple decorators on Python functions with type hints; for clients, you connect to any MCP server.

The SDK requires Python 3.10 or later and supports the stdio, Streamable HTTP and SSE transports. The package with the cli extra provides the mcp command to run a server, open the MCP Inspector or install a server into an AI app.

It is a good fit for businesses that already have Python scripts, data systems or Python automation and want to expose them to AI assistants.

How much does MCP Python SDK cost?

Free, open source (MIT)

Prices are set by the provider and can change; check the official site for the latest.

Key features of MCP Python SDK

01

Official, MIT license

The SDK is developed by the MCP project and licensed under MIT.

02

Decorator-based declaration

Use @mcp.tool() and @mcp.resource() on Python functions to turn them into tools and data for AI.

03

Both server and client

Build a server and also use the Client class to call tools on other servers.

04

Three transports

Supports stdio, Streamable HTTP and SSE.

05

Handy mcp command

mcp dev opens the server in the Inspector, mcp run runs the server, mcp install installs it into an app.

06

Upgrade docs available

The documentation has a section introducing v2 and a migration guide.

What is MCP Python SDK used for?

Expose sales data to AI

Write a Python tool that queries the order database so an AI assistant can answer revenue questions.

Reuse existing scripts

Wrap Excel and reporting scripts as tools that employees call through AI.

Connect internal systems

Create a server that calls your company's CRM or warehouse software APIs.

Build your own agent

Use the Client part so your Python app can call tools from multiple MCP servers.

Deploy a remote server

Run the server over Streamable HTTP so many people in the company can share it.

How to use MCP Python SDK

  1. 1

    Install the SDK with uv

    A project using uv can add the package with the CLI extra.

    $uv add "mcp[cli]"
  2. 2

    Or install with pip

    Use pip if you don't use uv; drop [cli] if you don't need the mcp command.

    $pip install "mcp[cli]"
  3. 3

    Write a minimal server

    Create server.py, initialize MCPServer and attach @mcp.tool() to a function with type hints.

  4. 4

    Try it in the Inspector

    Open the server in the MCP Inspector to test the tool before connecting it to an AI app.

    $uv run mcp dev server.py
  5. 5

    Run over HTTP

    Serve the server over Streamable HTTP; the default endpoint in the README is localhost:8000/mcp.

    $uv run mcp run server.py --transport streamable-http

MCP Python SDK video guides

Intro to MCP Servers – Model Context Protocol with Python Course

freeCodeCamp.org

Build Anything With a CUSTOM MCP Server - Python Tutorial

Tech With Tim

Python + MCP: Building MCP servers with FastMCP

Microsoft Reactor

Real-world example: MCP Python SDK

Illustrative scenario

A cosmetics store chain in Ho Chi Minh City already has a Python script that totals revenue by branch. A developer wraps that function as a tool with the MCP Python SDK, tests it in the Inspector, then runs the server over Streamable HTTP on an internal machine. A regional manager asks the AI assistant about last week's branch revenue and the AI calls the existing function instead of staff running it by hand.

Tips for using MCP Python SDK

  • Write full type hints

    The SDK relies on function types to describe parameters to the AI.

  • Name and describe tools clearly

    A good description helps the model pick the right tool.

  • Always test with mcp dev

    Check the tool in the Inspector before handing it to users.

  • Check the v2 docs

    If you follow older guides, compare against the migration page since examples now use MCPServer.

MCP Python SDK: frequently asked questions

Which Python version is needed?

Python 3.10 or later.

Is the [cli] extra required?

No. You only need it if you want the mcp commands such as mcp dev, mcp run, mcp install.

Is the SDK free?

Yes, open source under the MIT license.

Can I build a client?

Yes, the SDK provides a Client class to connect to and call tools on HTTP or stdio servers.

Useful links

Want to apply this in your business?

OPCAIOS looks at your workflows, picks the right tools and sets them up with your team. The first call is free.

Book a call