# AI use cases for Python SDK (modelcontextprotocol/python-sdk)

Repo: [modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Use cases: 3 | Page: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/

The MCP Python SDK is the official Python implementation of the Model Context Protocol. It builds MCP servers that expose tools, resources and prompts to any MCP host and MCP clients that connect to any server, over stdio, Streamable HTTP and SSE. Type hints become the schema, and the optional cli extra adds the mcp command with mcp dev, mcp run and mcp install.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Build an MCP server and test it in the Inspector: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/build-and-inspect-an-mcp-server/
- Serve an MCP server over HTTP and call it from Python: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/serve-mcp-over-http-and-call-it-from-python/
- Try MCP commands without setting up a project: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/run-mcp-commands-without-a-project/

## How to build an MCP server and test it in the Inspector with Python SDK

Repo: [modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Difficulty: Beginner | Time: 15 minutes | Basis: From the README

Write a two-function server with the official SDK and try its tools in the MCP Inspector.

**Who it is for:** A developer new to MCP who wants to see a server working before wiring it into an assistant.

**The problem:** It is hard to know whether a new MCP server works until it is connected to a host.

**The outcome:** A server.py with a tool and a templated resource, tested interactively in the MCP Inspector.

### Steps

1. Install with `uv add "mcp[cli]"`
2. Create server.py with an MCPServer, an add tool and a greeting resource, as in the README
3. Open it in the Inspector with `uv run mcp dev server.py`
4. Call add with a=1 and b=2 and check you get 3 back
5. Continue with the Get started guide in the docs

### Prompt to paste into your agent

```text
Using modelcontextprotocol/python-sdk, create a server.py that exposes <tools> and a resource for <data>. Open it with `uv run mcp dev server.py` and show me each tool working in the Inspector.
```

### Caveat

The SDK is on v2; code written for v1 needs the migration guide.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/build-and-inspect-an-mcp-server/

## How to serve an MCP server over HTTP and call it from Python with Python SDK

Repo: [modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Difficulty: Intermediate | Time: 20 minutes | Basis: From the README

Run your server with Streamable HTTP and connect the SDK's Client to it with a URL.

**Who it is for:** An engineer preparing to deploy an MCP server rather than run it as a local subprocess.

**The problem:** Local stdio servers are fine for one laptop, but a shared server needs an HTTP transport and a client to test it.

**The outcome:** A server reachable at a URL and a short Python client that calls its tools and prints structured results.

### Steps

1. Install with `uv add "mcp[cli]"`
2. Serve your server with `uv run mcp run server.py --transport streamable-http`
3. Write a client that opens Client("http://localhost:8000/mcp") and calls call_tool, as in the README
4. Read result.structured_content for the output
5. See the Clients docs to launch a local server as a stdio subprocess instead

### Prompt to paste into your agent

```text
Using modelcontextprotocol/python-sdk, serve my server.py with `uv run mcp run server.py --transport streamable-http` and write a Python client that calls <tool> with <arguments> and prints the structured result.
```

### Caveat

The README example runs on localhost with no authentication; add auth before exposing a server beyond your machine.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/serve-mcp-over-http-and-call-it-from-python/

## How to try MCP commands without setting up a project with Python SDK

Repo: [modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Difficulty: Beginner | Time: 10 minutes | Basis: From the README

Use uv to run the mcp CLI one-off, so you can test a server file without adding the SDK to a project.

**Who it is for:** Someone reviewing a colleague's server.py who does not want to create a Python project for it.

**The problem:** Installing the SDK into a project just to poke at one server file adds clutter.

**The outcome:** The mcp dev, mcp run and mcp install commands available on demand through uv.

### Steps

1. Install uv if you do not have it
2. Use `uv run --with "mcp[cli]" mcp ...` to run any mcp command without a project
3. Open a server in the Inspector with mcp dev, or run it with mcp run
4. Use mcp install to install a server for a host, per the README's list of commands
5. Install plain mcp instead of the cli extra in projects that do not need the command-line tool

### Prompt to paste into your agent

```text
Without creating a project, use the modelcontextprotocol/python-sdk CLI through `uv run --with "mcp[cli]" mcp ...` to open <server file> in the MCP Inspector and list what it exposes.
```

### Caveat

The README lists mcp install but does not say which hosts it supports, so check the docs before relying on it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/modelcontextprotocol-python-sdk/run-mcp-commands-without-a-project/
