Title: Build a Python MCP Client to Test Servers From Your Terminal – Real Python
Open Graph Title: Build a Python MCP Client to Test Servers From Your Terminal – Real Python
Description: Follow this Python project to build an MCP client that discovers MCP server capabilities and feeds an AI-powered chat with tool calls.
Open Graph Description: Follow this Python project to build an MCP client that discovers MCP server capabilities and feeds an AI-powered chat with tool calls.
Mail addresses
?subject=Python article for you&body=Build a Python MCP Client to Test Servers From Your Terminal on Real Python
https://realpython.com/python-mcp-client/
Opengraph URL: https://realpython.com/python-mcp-client/
X: @realpython
Domain: realpython.com
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "Build a Python MCP Client to Test Servers From Your Terminal",
"image": {
"@type": "ImageObject",
"url": "https://files.realpython.com/media/How-to-Build-a-Minimal-MCP-Client-in-Python-to-Test-Your-MCP-Servers_Watermarked.0507b57d9828.jpg",
"width": 1920,
"height": 1080
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://realpython.com/python-mcp-client/",
"lastReviewed": "2026-11-05",
"author": {
"@type": "Person",
"name": "Leodanis Pozo Ramos",
"image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
"url": "https://realpython.com/team/lpozoramos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"reviewedBy": [
{
"@type": "Person",
"name": "Aldren Santos",
"image": "https://realpython.com/cdn-cgi/image/width=500,height=500,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Aldren_Santos_Real_Python.6b0861d8b841.png",
"url": "https://realpython.com/team/asantos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Brenda Weleschuk",
"image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
"url": "https://realpython.com/team/bweleschuk/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Bartosz Zaczy\u0144ski",
"image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
"url": "https://realpython.com/team/bzaczynski/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
{
"@type": "Person",
"name": "Martin Breuss",
"image": "https://realpython.com/cdn-cgi/image/width=456,height=456,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/martin_breuss_python_square.efb2b07faf9f.jpg",
"url": "https://realpython.com/team/mbreuss/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
}
]
},
"datePublished": "2026-10-28T14:00:00+00:00",
"dateModified": "2026-11-05T06:02:02.425627+00:00",
"publisher": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": {
"@type": "ImageObject",
"url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
"width": 512,
"height": 512
},
"description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
"slogan": "Become a Python Expert",
"email": "info@realpython.com",
"sameAs": [
"https://github.com/realpython",
"https://www.youtube.com/realpython",
"https://twitter.com/realpython",
"https://x.com/realpython",
"https://www.linkedin.com/company/realpython-com/",
"https://www.facebook.com/learnrealpython",
"https://www.instagram.com/realpython",
"https://www.tiktok.com/@realpython.com"
]
},
"author": {
"@type": "Person",
"name": "Leodanis Pozo Ramos",
"image": "https://realpython.com/cdn-cgi/image/width=862,height=862,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Perfil_final1.9f896bc212f6.jpg",
"url": "https://realpython.com/team/lpozoramos/",
"affiliation": {
"@type": "Organization",
"@id": "https://realpython.com/#organization",
"name": "Real Python",
"url": "https://realpython.com",
"logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
}
},
"description": "Follow this Python project to build an MCP client that discovers MCP server capabilities and feeds an AI-powered chat with tool calls.",
"hasPart": {
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "How do you connect a Python MCP client to a server over stdio?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYou create a client by calling \u003ccode\u003estdio_client()\u003c/code\u003e with \u003ccode\u003eStdioServerParameters\u003c/code\u003e and wrapping the input and output streams in a \u003ccode\u003eClientSession\u003c/code\u003e instance.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How do you list an MCP server\u2019s tools, prompts, and resources?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYou call \u003ccode\u003e.list_tools()\u003c/code\u003e, \u003ccode\u003e.list_prompts()\u003c/code\u003e, and \u003ccode\u003e.list_resources()\u003c/code\u003e on a \u003ccode\u003eClientSession\u003c/code\u003e instance. You can read each item\u0026rsquo;s \u003ccode\u003e.name\u003c/code\u003e and \u003ccode\u003e.description\u003c/code\u003e attributes to get a more detailed summary.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "Why does the client use an async context manager with AsyncExitStack?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eThe client uses an async context manager to safely manage the stdio transport and session lifetime by entering and exiting in one place. \u003ccode\u003eAsyncExitStack\u003c/code\u003e lets you acquire the read and write streams, attach \u003ccode\u003eClientSession()\u003c/code\u003e, and guarantee cleanup even if a step fails.\u003c/p\u003e"
}
}
]
}
}
| author | Real Python |
| theme-color | #18354c |
| color-scheme | light dark |
| twitter:card | summary_large_image |
| twitter:image | https://files.realpython.com/media/How-to-Build-a-Minimal-MCP-Client-in-Python-to-Test-Your-MCP-Servers_Watermarked.0507b57d9828.jpg |
| og:image | https://files.realpython.com/media/How-to-Build-a-Minimal-MCP-Client-in-Python-to-Test-Your-MCP-Servers_Watermarked.0507b57d9828.jpg |
| twitter:creator | @realpython |
| og:type | article |
| og:site_name | Real Python |
| apple-mobile-web-app-title | Real Python |
Links:
Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover
Robots: max-image-preview:large