Title: Python MCP Server: Connect LLMs to Your Data – Real Python
Open Graph Title: Python MCP Server: Connect LLMs to Your Data – Real Python
Description: Learn how to build a Model Context Protocol (MCP) server in Python. Connect tools, prompts, and data to AI agents like Cursor for smarter assistants.
Open Graph Description: Learn how to build a Model Context Protocol (MCP) server in Python. Connect tools, prompts, and data to AI agents like Cursor for smarter assistants.
Mail addresses
?subject=Python article for you&body=Python MCP Server: Connect LLMs to Your Data on Real Python
https://realpython.com/python-mcp/
Opengraph URL: https://realpython.com/python-mcp/
X: @realpython
Domain: realpython.com
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "Python MCP Server: Connect LLMs to Your Data",
"image": {
"@type": "ImageObject",
"url": "https://files.realpython.com/media/How-to-Properly-Indent-Your-Python-Code_Watermarked.24ef559fc78a.jpg",
"width": 1920,
"height": 1080
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://realpython.com/python-mcp/",
"lastReviewed": "2026-10-29",
"author": {
"@type": "Person",
"name": "Harrison Hoffman",
"image": "https://realpython.com/cdn-cgi/image/width=605,height=605,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Screenshot_2024-01-17_at_9.18.04_AM.7a08390ba349.png",
"url": "https://realpython.com/team/hhoffman/",
"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"
}
},
{
"@type": "Person",
"name": "Stephen Gruppetta",
"image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Stephen_inside_2_BW_2_square_crop_2_low_res_2_copy.4a7e2d8bc19c.png",
"url": "https://realpython.com/team/sgruppetta/",
"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": "2025-09-24T14:00:00+00:00",
"dateModified": "2026-10-29T23:55:30.435932+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": "Harrison Hoffman",
"image": "https://realpython.com/cdn-cgi/image/width=605,height=605,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/Screenshot_2024-01-17_at_9.18.04_AM.7a08390ba349.png",
"url": "https://realpython.com/team/hhoffman/",
"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": "Learn how to build a Model Context Protocol (MCP) server in Python. Connect tools, prompts, and data to AI agents like Cursor for smarter assistants.",
"hasPart": {
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is the Model Context Protocol (MCP) and why should you use it?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYou use MCP to enable AI models to call real tools through a standard client-server protocol. It removes boilerplate so you focus on defining prompts, resources, and tools that your LLM can call.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How do you install Python MCP and verify the setup?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eTo install Python MCP, create a virtual environment and run \u003ccode\u003epython -m pip install \"mcp[cli]\"\u003c/code\u003e. To confirm the install, you can optionally import \u003ccode\u003emcp\u003c/code\u003e in a REPL.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "What are prompts, resources, and tools in MCP?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYou store reusable instructions as prompts, expose read-only data via resource URIs, and implement callable actions as tools. The client exposes these to the LLM so it can select resources and invoke tool functions.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How do you build and run a simple MCP server in Python?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eTo build a simple MCP server in Python, you create a \u003ccode\u003eFastMCP\u003c/code\u003e instance, decorate async tool functions with \u003ccode\u003e@mcp.tool()\u003c/code\u003e, and call \u003ccode\u003emcp.run(transport=\"stdio\")\u003c/code\u003e to serve them.\u003c/p\u003e"
}
},
{
"@type": "Question",
"name": "How do you test your MCP server and confirm the available tools?",
"acceptedAnswer": {
"@type": "Answer",
"text": "\u003cp\u003eYou open a \u003ccode\u003eClientSession\u003c/code\u003e over \u003ccode\u003estdio\u003c/code\u003e using \u003ccode\u003eStdioServerParameters\u003c/code\u003e and \u003ccode\u003estdio_client()\u003c/code\u003e, then call \u003ccode\u003esession.initialize()\u003c/code\u003e followed by \u003ccode\u003esession.list_tools()\u003c/code\u003e.\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-Properly-Indent-Your-Python-Code_Watermarked.24ef559fc78a.jpg |
| og:image | https://files.realpython.com/media/How-to-Properly-Indent-Your-Python-Code_Watermarked.24ef559fc78a.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