# Build a Python MCP Client to Test Servers From Your Terminal

DevFeed: [Build a Python MCP Client to Test Servers From Your Terminal](<https://devfeed.tech/articles/build-a-python-mcp-client-to-test-servers-from-your-terminal-104499.md>)

Original publisher: [Read original article](<https://realpython.com/python-mcp-client/>)

Author: Leodanis Pozo Ramos

Published: 2026-10-28T14:00:00Z

Content type: tutorial

Language: en

Sources: [Real Python](<https://devfeed.tech/sources/real-python.md>)

Topics: [client](<https://devfeed.tech/topics/client.md>), [Python](<https://devfeed.tech/topics/python.md>), [AI Chat](<https://devfeed.tech/topics/ai-chat.md>), [Terminal](<https://devfeed.tech/topics/terminal.md>), [client library](<https://devfeed.tech/topics/client-library.md>), [Build tool](<https://devfeed.tech/topics/build-tool.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-powered](<https://devfeed.tech/tags/ai-powered.md>), [build](<https://devfeed.tech/tags/build.md>), [capabilities](<https://devfeed.tech/tags/capabilities.md>), [chat](<https://devfeed.tech/tags/chat.md>), [cli](<https://devfeed.tech/tags/cli.md>), [client](<https://devfeed.tech/tags/client.md>), [command-line](<https://devfeed.tech/tags/command-line.md>), [mcp](<https://devfeed.tech/tags/mcp.md>), [mcp-server](<https://devfeed.tech/tags/mcp-server.md>), [project](<https://devfeed.tech/tags/project.md>), [python](<https://devfeed.tech/tags/python.md>), [server](<https://devfeed.tech/tags/server.md>), [servers](<https://devfeed.tech/tags/servers.md>), [terminal](<https://devfeed.tech/tags/terminal.md>), [test](<https://devfeed.tech/tags/test.md>), [tool](<https://devfeed.tech/tags/tool.md>)

## AI overview

The tutorial builds a minimal Python command-line MCP client that launches a local server over stdio, discovers its tools, prompts, and resources, and connects server tools to an OpenAI-powered chat. It uses the MCP and OpenAI Python SDKs, `argparse`, and `AsyncExitStack` to manage the asynchronous session and clean up resources. The example client offers mutually exclusive `--members` and `--chat` modes, requires `OPENAI_API_KEY` for chat, and packages an executable command with `uv` and setuptools. The tutorial uses stdio for local processes; Streamable HTTP is mentioned as an extension for remote servers. It assumes some familiarity with Python project management, `asyncio`, and `argparse`, and notes that this minimal example leaves production concerns such as security, concurrency, error handling, and tool permissions uncovered.

## Source excerpt

Follow this Python project to build an MCP client that discovers MCP server capabilities and feeds an AI-powered chat with tool calls.