{"id":43512,"date":"2025-06-12T19:55:57","date_gmt":"2025-06-12T11:55:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/43512.html"},"modified":"2025-06-12T19:55:57","modified_gmt":"2025-06-12T11:55:57","slug":"pydanticai-mcp-python%e4%bb%a3%e7%a0%81%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%bd%bf%e7%94%a8%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/43512.html","title":{"rendered":"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b"},"content":{"rendered":"<\/p>\n<h4>\u76ee\u5f55<\/h4>\n<ul>\n<li>\n<ul>\n<li>1. \u73af\u5883\u51c6\u5907<\/li>\n<li>\n<ul>\n<li>1.1 \u5b89\u88c5 Deno (Ubuntu)<\/li>\n<li>1.2 \u5b89\u88c5 Python \u4f9d\u8d56<\/li>\n<\/ul>\n<\/li>\n<li>2. \u521b\u5efa MCP \u5ba2\u6237\u7aef\u4ee3\u7801<\/li>\n<li>3. \u8fd0\u884c\u4ee3\u7801<\/li>\n<li>4. \u9884\u671f\u8f93\u51fa<\/li>\n<li>5. \u5de5\u4f5c\u539f\u7406<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u4e0b\u9762\u5c06\u4ecb\u7ecd\u8bbe\u7f6e\u548c\u4f7f\u7528 PydanticAI \u7684 MCP (Model Context Protocol) Python \u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0\u5728\u9694\u79bb\u73af\u5883\u4e2d\u8fd0\u884c Python \u4ee3\u7801\u3002<\/p>\n<h3>1. \u73af\u5883\u51c6\u5907<\/h3>\n<h4>1.1 \u5b89\u88c5 Deno (Ubuntu)<\/h4>\n<p><span class=\"token comment\"># \u66f4\u65b0\u7cfb\u7edf\u5305<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> update<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5 unzip \u5de5\u5177&#xff08;Deno \u5b89\u88c5\u9700\u8981&#xff09;<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> <span class=\"token function\">unzip<\/span><\/p>\n<p><span class=\"token comment\"># \u4e0b\u8f7d\u5e76\u5b89\u88c5 Deno<\/span><br \/>\n<span class=\"token function\">curl<\/span> <span class=\"token parameter variable\">-fsSL<\/span> https:\/\/deno.land\/install.sh <span class=\"token operator\">|<\/span> <span class=\"token function\">sh<\/span><\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e&#xff0c;\u7cfb\u7edf\u4f1a\u8be2\u95ee\u662f\u5426\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf&#xff0c;\u9009\u62e9 \u2018Yes\u2019\u3002<\/p>\n<p>\u91cd\u542f\u7ec8\u7aef\u5e76\u9a8c\u8bc1\u5b89\u88c5&#xff1a;<\/p>\n<p>deno <span class=\"token parameter variable\">&#8211;version<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612115556-684ac04c333fb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>1.2 \u5b89\u88c5 Python \u4f9d\u8d56<\/h4>\n<p>\u89c1&#xff1a;PydanticAI\u5feb\u901f\u5165\u95e8\u793a\u4f8b<\/p>\n<h3>2. \u521b\u5efa MCP \u5ba2\u6237\u7aef\u4ee3\u7801<\/h3>\n<p>\u521b\u5efa mcp_server.py \u6587\u4ef6&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> asyncio<br \/>\n<span class=\"token keyword\">from<\/span> mcp <span class=\"token keyword\">import<\/span> ClientSession<span class=\"token punctuation\">,<\/span> StdioServerParameters<br \/>\n<span class=\"token keyword\">from<\/span> mcp<span class=\"token punctuation\">.<\/span>client<span class=\"token punctuation\">.<\/span>stdio <span class=\"token keyword\">import<\/span> stdio_client<\/p>\n<p><span class=\"token comment\"># \u8981\u6267\u884c\u7684 Python \u4ee3\u7801<\/span><br \/>\ncode <span class=\"token operator\">&#061;<\/span> <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;<br \/>\nimport numpy<br \/>\na &#061; numpy.array([1, 2, 3])<br \/>\nprint(a)<br \/>\na<br \/>\n&#034;&#034;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u914d\u7f6e MCP \u670d\u52a1\u5668\u53c2\u6570<\/span><br \/>\nserver_params <span class=\"token operator\">&#061;<\/span> StdioServerParameters<span class=\"token punctuation\">(<\/span><br \/>\n    command<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;deno&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    args<span class=\"token operator\">&#061;<\/span><span class=\"token punctuation\">[<\/span><br \/>\n        <span class=\"token string\">&#039;run&#039;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#039;-N&#039;<\/span><span class=\"token punctuation\">,<\/span>                           <span class=\"token comment\"># \u5141\u8bb8\u7f51\u7edc\u8bbf\u95ee<\/span><br \/>\n        <span class=\"token string\">&#039;-R&#061;node_modules&#039;<\/span><span class=\"token punctuation\">,<\/span>              <span class=\"token comment\"># \u5141\u8bb8\u8bfb\u53d6 node_modules<\/span><br \/>\n        <span class=\"token string\">&#039;-W&#061;node_modules&#039;<\/span><span class=\"token punctuation\">,<\/span>              <span class=\"token comment\"># \u5141\u8bb8\u5199\u5165 node_modules<\/span><br \/>\n        <span class=\"token string\">&#039;&#8211;node-modules-dir&#061;auto&#039;<\/span><span class=\"token punctuation\">,<\/span>      <span class=\"token comment\"># \u81ea\u52a8\u7ba1\u7406 node_modules<\/span><br \/>\n        <span class=\"token string\">&#039;jsr:&#064;pydantic\/mcp-run-python&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token comment\"># JSR \u5305\u5730\u5740<\/span><br \/>\n        <span class=\"token string\">&#039;stdio&#039;<\/span><span class=\"token punctuation\">,<\/span>                        <span class=\"token comment\"># \u4f7f\u7528 stdio \u901a\u4fe1<\/span><br \/>\n    <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">async<\/span> <span class=\"token keyword\">def<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token comment\"># \u5efa\u7acb\u4e0e MCP \u670d\u52a1\u5668\u7684\u8fde\u63a5<\/span><br \/>\n        <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">with<\/span> stdio_client<span class=\"token punctuation\">(<\/span>server_params<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token punctuation\">(<\/span>read<span class=\"token punctuation\">,<\/span> write<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">with<\/span> ClientSession<span class=\"token punctuation\">(<\/span>read<span class=\"token punctuation\">,<\/span> write<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> session<span class=\"token punctuation\">:<\/span><br \/>\n                <span class=\"token comment\"># \u521d\u59cb\u5316\u4f1a\u8bdd<\/span><br \/>\n                <span class=\"token keyword\">await<\/span> session<span class=\"token punctuation\">.<\/span>initialize<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>                <span class=\"token comment\"># \u83b7\u53d6\u53ef\u7528\u5de5\u5177\u5217\u8868<\/span><br \/>\n                tools <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> session<span class=\"token punctuation\">.<\/span>list_tools<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u53ef\u7528\u5de5\u5177\u6570\u91cf: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token builtin\">len<\/span><span class=\"token punctuation\">(<\/span>tools<span class=\"token punctuation\">.<\/span>tools<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u5de5\u5177\u540d\u79f0: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token builtin\">repr<\/span><span class=\"token punctuation\">(<\/span>tools<span class=\"token punctuation\">.<\/span>tools<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span>name<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u8f93\u5165\u6a21\u5f0f: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token builtin\">repr<\/span><span class=\"token punctuation\">(<\/span>tools<span class=\"token punctuation\">.<\/span>tools<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span>inputSchema<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>                <span class=\"token comment\"># \u8c03\u7528 Python \u4ee3\u7801\u6267\u884c\u5de5\u5177<\/span><br \/>\n                result <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> session<span class=\"token punctuation\">.<\/span>call_tool<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;run_python_code&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#039;python_code&#039;<\/span><span class=\"token punctuation\">:<\/span> code<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\\\\n\u6267\u884c\u7ed3\u679c:&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n                <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span>result<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span>text<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">print<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u53d1\u751f\u9519\u8bef: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> __name__ <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token string\">&#034;__main__&#034;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    asyncio<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span>main<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<h3>3. \u8fd0\u884c\u4ee3\u7801<\/h3>\n<p><span class=\"token comment\"># \u8fd0\u884c MCP \u5ba2\u6237\u7aef<\/span><br \/>\nuv run mcp_server.py<\/p>\n<h3>4. \u9884\u671f\u8f93\u51fa<\/h3>\n<p>\u6210\u529f\u8fd0\u884c\u540e&#xff0c;\u5e94\u8be5\u770b\u5230\u7c7b\u4f3c\u4ee5\u4e0b\u7684\u8f93\u51fa&#xff1a;<\/p>\n<p>\u53ef\u7528\u5de5\u5177\u6570\u91cf: 1<br \/>\n\u5de5\u5177\u540d\u79f0: &#039;run_python_code&#039;<br \/>\n\u8f93\u5165\u6a21\u5f0f: {&#039;type&#039;: &#039;object&#039;, &#039;properties&#039;: {&#039;python_code&#039;: {&#039;type&#039;: &#039;string&#039;, &#039;description&#039;: &#039;Python code to run&#039;}}, &#039;required&#039;: [&#039;python_code&#039;], &#039;additionalProperties&#039;: False, &#039;$schema&#039;: &#039;http:\/\/json-schema.org\/draft-07\/schema#&#039;}<\/p>\n<p>\u6267\u884c\u7ed3\u679c:<br \/>\n&lt;status&gt;success&lt;\/status&gt;<br \/>\n&lt;dependencies&gt;[&#034;numpy&#034;]&lt;\/dependencies&gt;<br \/>\n&lt;output&gt;<br \/>\n[1 2 3]<br \/>\n&lt;\/output&gt;<br \/>\n&lt;return_value&gt;<br \/>\n[<br \/>\n  1,<br \/>\n  2,<br \/>\n  3<br \/>\n]<br \/>\n&lt;\/return_value&gt;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612115556-684ac04c5df46.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>5. \u5de5\u4f5c\u539f\u7406<\/h3>\n<li>MCP \u670d\u52a1\u5668: Deno \u8fd0\u884c JSR \u5305 &#064;pydantic\/mcp-run-python&#xff0c;\u63d0\u4f9b Python \u4ee3\u7801\u6267\u884c\u670d\u52a1<\/li>\n<li>\u9694\u79bb\u73af\u5883: \u4f7f\u7528 Pyodide \u5728\u6c99\u7bb1\u73af\u5883\u4e2d\u6267\u884c Python \u4ee3\u7801<\/li>\n<li>\u901a\u4fe1\u534f\u8bae: \u901a\u8fc7 stdio \u8fdb\u884c\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u901a\u4fe1<\/li>\n<li>\u4f9d\u8d56\u7ba1\u7406: \u81ea\u52a8\u5904\u7406 Python \u5305\u4f9d\u8d56&#xff08;\u5982 numpy&#xff09;<\/li>\n<p>\u53c2\u8003\u94fe\u63a5&#xff1a;https:\/\/ai.pydantic.dev\/mcp\/run-python\/#direct-usage<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb828\u6b21\uff0c\u70b9\u8d5e16\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u8bbe\u7f6e\u548c\u4f7f\u7528 PydanticAI \u7684 MCP (Model Context Protocol) Python \u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u5728\u9694\u79bb\u73af\u5883\u4e2d\u8fd0\u884c Python \u4ee3\u7801\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u7cfb\u7edf\u4f1a\u8be2\u95ee\u662f\u5426\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff0c\u9009\u62e9\u3002<\/p>\n","protected":false},"author":2,"featured_media":43510,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[73,4032,81,190],"topic":[],"class_list":["post-43512","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-mcp","tag-pydantci_ai","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/43512.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb828\u6b21\uff0c\u70b9\u8d5e16\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u8bbe\u7f6e\u548c\u4f7f\u7528 PydanticAI \u7684 MCP (Model Context Protocol) Python \u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u5728\u9694\u79bb\u73af\u5883\u4e2d\u8fd0\u884c Python \u4ee3\u7801\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u7cfb\u7edf\u4f1a\u8be2\u95ee\u662f\u5426\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff0c\u9009\u62e9\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/43512.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-12T11:55:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612115556-684ac04c333fb.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/43512.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/43512.html\",\"name\":\"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-12T11:55:57+00:00\",\"dateModified\":\"2025-06-12T11:55:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/43512.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/43512.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/43512.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/43512.html","og_locale":"zh_CN","og_type":"article","og_title":"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb828\u6b21\uff0c\u70b9\u8d5e16\u6b21\uff0c\u6536\u85cf15\u6b21\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u8bbe\u7f6e\u548c\u4f7f\u7528 PydanticAI \u7684 MCP (Model Context Protocol) Python \u670d\u52a1\u5668\uff0c\u5b9e\u73b0\u5728\u9694\u79bb\u73af\u5883\u4e2d\u8fd0\u884c Python \u4ee3\u7801\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u7cfb\u7edf\u4f1a\u8be2\u95ee\u662f\u5426\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff0c\u9009\u62e9\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/43512.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-12T11:55:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/06\/20250612115556-684ac04c333fb.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/43512.html","url":"https:\/\/www.wsisp.com\/helps\/43512.html","name":"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-12T11:55:57+00:00","dateModified":"2025-06-12T11:55:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/43512.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/43512.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/43512.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"PydanticAI MCP Python\u4ee3\u7801\u670d\u52a1\u5668\u4f7f\u7528\u793a\u4f8b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/43512","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=43512"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/43512\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/43510"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=43512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=43512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=43512"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=43512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}