{"id":39769,"date":"2025-03-31T17:10:45","date_gmt":"2025-03-31T09:10:45","guid":{"rendered":"https:\/\/17aitech.com\/?p=39769"},"modified":"2025-03-31T18:25:33","modified_gmt":"2025-03-31T10:25:33","slug":"%e3%80%90%e5%ad%a6%e4%b9%a0%e6%80%bb%e7%bb%93%e3%80%91mcp-server%e7%9a%84%e5%ae%9e%e8%b7%b5%e4%b9%8bopenai-agent%e7%9a%84%e8%b0%83%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/17aitech.com\/?p=39769","title":{"rendered":"\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_78 ez-toc-wrap-left-text counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/17aitech.com\/?p=39769\/#%E8%83%8C%E6%99%AF\" >\u80cc\u666f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/17aitech.com\/?p=39769\/#%E5%86%85%E5%AE%B9%E6%A6%82%E8%BF%B0\" >\u5185\u5bb9\u6982\u8ff0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/17aitech.com\/?p=39769\/#%E5%85%B7%E4%BD%93%E5%86%85%E5%AE%B9\" >\u5177\u4f53\u5185\u5bb9<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/17aitech.com\/?p=39769\/#1_%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE\" >1. \u521b\u5efa\u9879\u76ee<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/17aitech.com\/?p=39769\/#2_%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%A4%BA%E4%BE%8B\" >2. \u4e00\u4e2a\u7b80\u5355\u793a\u4f8b<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/17aitech.com\/?p=39769\/#21_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E5%88%9D%E5%A7%8B%E5%8C%96%E9%83%A8%E5%88%86\" >2.1 \u65e5\u5fd7\u5206\u6790\uff1a\u521d\u59cb\u5316\u90e8\u5206<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/17aitech.com\/?p=39769\/#22_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E7%AC%AC%E4%B8%80%E6%AC%A1%E8%AF%B7%E6%B1%82%E5%A4%A7%E6%A8%A1%E5%9E%8B\" >2.2 \u65e5\u5fd7\u5206\u6790\uff1a\u7b2c\u4e00\u6b21\u8bf7\u6c42\u5927\u6a21\u578b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/17aitech.com\/?p=39769\/#23_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E8%B0%83%E7%94%A8get_weather%E5%B7%A5%E5%85%B7\" >2.3 \u65e5\u5fd7\u5206\u6790\uff1a\u8c03\u7528get_weather\u5de5\u5177<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/17aitech.com\/?p=39769\/#24_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E7%AC%AC%E4%BA%8C%E6%AC%A1%E8%AF%B7%E6%B1%82%E5%A4%A7%E6%A8%A1%E5%9E%8B\" >2.4 \u65e5\u5fd7\u5206\u6790\uff1a\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u5927\u6a21\u578b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/17aitech.com\/?p=39769\/#25_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E8%BE%93%E5%87%BA%E7%BB%93%E6%9E%9C\" >2.5 \u65e5\u5fd7\u5206\u6790\uff1a\u8f93\u51fa\u7ed3\u679c<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/17aitech.com\/?p=39769\/#3_%E9%80%9A%E8%BF%87mlflow%E5%8F%AF%E8%A7%86%E5%8C%96Agent%E8%BF%90%E8%A1%8C%E6%83%85%E5%86%B5\" >3. \u901a\u8fc7mlflow\u53ef\u89c6\u5316Agent\u8fd0\u884c\u60c5\u51b5<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/17aitech.com\/?p=39769\/#31_MLflow%E7%AE%80%E4%BB%8B\" >3.1 MLflow\u7b80\u4ecb<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/17aitech.com\/?p=39769\/#32_%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96%E5%8C%85\" >3.2 \u5b89\u88c5\u4f9d\u8d56\u5305<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/17aitech.com\/?p=39769\/#33_%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1\" >3.3 \u542f\u52a8\u670d\u52a1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/17aitech.com\/?p=39769\/#34_%E6%94%B9%E9%80%A0Agent%E4%BB%A3%E7%A0%81\" >3.4 \u6539\u9020Agent\u4ee3\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/17aitech.com\/?p=39769\/#35_%E9%87%8D%E6%96%B0%E8%BF%90%E8%A1%8CAgent%E4%BB%A3%E7%A0%81\" >3.5 \u91cd\u65b0\u8fd0\u884cAgent\u4ee3\u7801<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/17aitech.com\/?p=39769\/#4_%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E8%B0%83%E7%94%A8MCP%E6%9C%8D%E5%8A%A1%E7%9A%84Agent%E7%A4%BA%E4%BE%8B\" >4. \u4e00\u4e2a\u53ef\u4ee5\u8c03\u7528MCP\u670d\u52a1\u7684Agent\u793a\u4f8b<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/17aitech.com\/?p=39769\/#41_%E5%90%AF%E5%8A%A8mcp-weather-server%E6%9C%8D%E5%8A%A1\" >4.1 \u542f\u52a8mcp-weather-server\u670d\u52a1<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/17aitech.com\/?p=39769\/#42_%E6%94%B9%E9%80%A0Agent%E7%9A%84%E4%BB%A3%E7%A0%81\" >4.2 \u6539\u9020Agent\u7684\u4ee3\u7801<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/17aitech.com\/?p=39769\/#43_%E8%BF%90%E8%A1%8CAgent%E7%9A%84%E4%BB%A3%E7%A0%81\" >4.3 \u8fd0\u884cAgent\u7684\u4ee3\u7801<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/17aitech.com\/?p=39769\/#%E6%80%BB%E7%BB%93\" >\u603b\u7ed3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/17aitech.com\/?p=39769\/#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\" >\u53c2\u8003\u8d44\u6599<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/17aitech.com\/?p=39769\/#%E5%85%B6%E4%BB%96%E6%96%87%E7%AB%A0\" >\u5176\u4ed6\u6587\u7ae0<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"%E8%83%8C%E6%99%AF\"><\/span>\u80cc\u666f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>OpenAI\u57283\u670827\u65e5\u5ba3\u5e03\u5bf9\u5176 Agent SDK \u8fdb\u884c\u91cd\u5927\u66f4\u65b0\uff0c\u6b63\u5f0f\u652f\u6301 Model Context Protocol\uff08MCP\uff09\u670d\u52a1\u3002\u7531\u4e8e\u8be5\u9879\u6280\u672f\u5bf9\u4e8e\u672a\u6765Agent\u6280\u672f\u6f14\u8fdb\u8f83\u4e3a\u91cd\u8981\uff0c\u6240\u4ee5\u672c\u7ae0\u5185\u5bb9\u8fdb\u884c\u4e86OpenAI Agent SDK\u4f7f\u7528MCP\u670d\u52a1\u7684\u5b9e\u6218\u8fdb\u884c\u4e86\u603b\u7ed3\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%86%85%E5%AE%B9%E6%A6%82%E8%BF%B0\"><\/span>\u5185\u5bb9\u6982\u8ff0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\u901a\u8fc7OpenAI SDK\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684Agent\u793a\u4f8b<\/li>\n<li>\u901a\u8fc7MLfow\uff0c\u53ef\u89c6\u5316\u67e5\u770bAgent\u7684\u8fd0\u884c\u60c5\u51b5<\/li>\n<li>\u901a\u8fc7OpenAI SDK\u5b9e\u73b0\u4e00\u4e2a\u53ef\u4ee5\u8c03\u7528MCP\u7684Agent\u793a\u4f8b<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E5%85%B7%E4%BD%93%E5%86%85%E5%AE%B9\"><\/span>\u5177\u4f53\u5185\u5bb9<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"1_%E5%88%9B%E5%BB%BA%E9%A1%B9%E7%9B%AE\"><\/span>1. \u521b\u5efa\u9879\u76ee<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-bash\"># \u521d\u59cb\u5316\u9879\u76ee\nuv init mcp-with-openai-agents\ncd mcp-with-openai-agents\n\n# \u521b\u5efa\u865a\u62df\u73af\u5883\nuv venv\nsource .venv\/bin\/activate\n\n# \u5b89\u88c5\u4f9d\u8d56\nuv add openai-agents<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"2_%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E7%A4%BA%E4%BE%8B\"><\/span>2. \u4e00\u4e2a\u7b80\u5355\u793a\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-python\">import asyncio\nimport logging\nfrom openai import AsyncOpenAI\nfrom agents import Agent, OpenAIChatCompletionsModel, Runner, function_tool, set_tracing_disabled\n\nlogging.basicConfig(level=logging.DEBUG)\n\nBASE_URL = &quot;https:\/\/api.deepseek.com\/v1&quot;\nAPI_KEY = &quot;sk-0d9449d235*******&quot;\nMODEL_NAME = &quot;deepseek-chat&quot;\n\nif not BASE_URL or not API_KEY or not MODEL_NAME:\n    raise ValueError(\n        &quot;Please set EXAMPLE_BASE_URL, EXAMPLE_API_KEY, EXAMPLE_MODEL_NAME via env var or code.&quot;\n    )\n\nclient = AsyncOpenAI(base_url=BASE_URL, api_key=API_KEY)\nset_tracing_disabled(disabled=True)\n\n@function_tool\ndef get_weather(city: str):\n    logging.info(f&quot;[DEBUG] Getting weather for {city}&quot;)\n    return f&quot;The weather in {city} is sunny.&quot;\n\nasync def main():\n    # \u6b64\u4ee3\u7406\u5c06\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u5927\u6a21\u578bLLM \n    agent = Agent(\n        name=&quot;Assistant&quot;,\n        instructions=&quot;You only respond in haikus.&quot;,\n        model=OpenAIChatCompletionsModel(model=MODEL_NAME, openai_client=client),\n        tools=[get_weather],\n    )\n\n    result = await Runner.run(agent, &quot;What&#039;s the weather in Tokyo?&quot;)\n    print(result.final_output)\n\nif __name__ == &quot;__main__&quot;:\n    asyncio.run(main())\n<\/code><\/pre>\n<p>\u8fd0\u884c\u4ee5\u4e0a\u4ee3\u7801\uff0c\u8f93\u51fa\u65e5\u5fd7\u4e4b\u540e\uff0c\u6211\u4eec\u8be6\u7ec6\u5206\u6790\u65e5\u5fd7\u7684\u7ec4\u6210\u90e8\u5206\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"21_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E5%88%9D%E5%A7%8B%E5%8C%96%E9%83%A8%E5%88%86\"><\/span>2.1 \u65e5\u5fd7\u5206\u6790\uff1a\u521d\u59cb\u5316\u90e8\u5206<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">DEBUG:openai.agents:Tracing is disabled. Not creating trace Agent workflow\nDEBUG:openai.agents:Setting current trace: no-op\nDEBUG:openai.agents:Tracing is disabled. Not creating span &lt;agents.tracing.span_data.AgentSpanData object at 0x108bccd70&gt;\nDEBUG:openai.agents:Running agent Assistant (turn 1)\nDEBUG:openai.agents:Tracing is disabled. Not creating span &lt;agents.tracing.span_data.GenerationSpanData object at 0x108bccfb0&gt;\nDEBUG:openai.agents:[\n  {\n    &quot;content&quot;: &quot;You only respond in haikus.&quot;,\n    &quot;role&quot;: &quot;system&quot;\n  },\n  {\n    &quot;role&quot;: &quot;user&quot;,\n    &quot;content&quot;: &quot;What&#039;s the weather in Tokyo?&quot;\n  }\n]\nTools:\n[\n  {\n    &quot;type&quot;: &quot;function&quot;,\n    &quot;function&quot;: {\n      &quot;name&quot;: &quot;get_weather&quot;,\n      &quot;description&quot;: &quot;&quot;,\n      &quot;parameters&quot;: {\n        &quot;properties&quot;: {\n          &quot;city&quot;: {\n            &quot;title&quot;: &quot;City&quot;,\n            &quot;type&quot;: &quot;string&quot;\n          }\n        },\n        &quot;required&quot;: [\n          &quot;city&quot;\n        ],\n        &quot;title&quot;: &quot;get_weather_args&quot;,\n        &quot;type&quot;: &quot;object&quot;,\n        &quot;additionalProperties&quot;: false\n      }\n    }\n  }\n]\nStream: False\nTool choice: NOT_GIVEN\nResponse format: NOT_GIVEN\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"22_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E7%AC%AC%E4%B8%80%E6%AC%A1%E8%AF%B7%E6%B1%82%E5%A4%A7%E6%A8%A1%E5%9E%8B\"><\/span>2.2 \u65e5\u5fd7\u5206\u6790\uff1a\u7b2c\u4e00\u6b21\u8bf7\u6c42\u5927\u6a21\u578b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">DEBUG:openai._base_client:Request options: {&#039;method&#039;: &#039;post&#039;, &#039;url&#039;: &#039;\/chat\/completions&#039;, &#039;headers&#039;: {&#039;User-Agent&#039;: &#039;Agents\/Python 0.0.0&#039;}, &#039;files&#039;: None, &#039;json_data&#039;: {&#039;messages&#039;: [{&#039;content&#039;: &#039;You only respond in haikus.&#039;, &#039;role&#039;: &#039;system&#039;}, {&#039;role&#039;: &#039;user&#039;, &#039;content&#039;: &quot;What&#039;s the weather in Tokyo?&quot;}], &#039;model&#039;: &#039;deepseek-chat&#039;, &#039;stream&#039;: False, &#039;tools&#039;: [{&#039;type&#039;: &#039;function&#039;, &#039;function&#039;: {&#039;name&#039;: &#039;get_weather&#039;, &#039;description&#039;: &#039;&#039;, &#039;parameters&#039;: {&#039;properties&#039;: {&#039;city&#039;: {&#039;title&#039;: &#039;City&#039;, &#039;type&#039;: &#039;string&#039;}}, &#039;required&#039;: [&#039;city&#039;], &#039;title&#039;: &#039;get_weather_args&#039;, &#039;type&#039;: &#039;object&#039;, &#039;additionalProperties&#039;: False}}}]}}\n\n... \u4e2d\u95f4\u90e8\u5206\u7701\u7565\n\nDEBUG:openai._base_client:HTTP Request: POST https:\/\/api.deepseek.com\/v1\/chat\/completions &quot;200 OK&quot;\nDEBUG:openai.agents:LLM resp:\n{\n  &quot;content&quot;: &quot;&quot;,\n  &quot;refusal&quot;: null,\n  &quot;role&quot;: &quot;assistant&quot;,\n  &quot;annotations&quot;: null,\n  &quot;audio&quot;: null,\n  &quot;function_call&quot;: null,\n  &quot;tool_calls&quot;: [\n    {\n      &quot;id&quot;: &quot;call_0_6f04a7e3-acde-4ff1-b925-68c6294f3955&quot;,\n      &quot;function&quot;: {\n        &quot;arguments&quot;: &quot;{\\&quot;city\\&quot;:\\&quot;Tokyo\\&quot;}&quot;,\n        &quot;name&quot;: &quot;get_weather&quot;\n      },\n      &quot;type&quot;: &quot;function&quot;,\n      &quot;index&quot;: 0\n    }\n  ]\n}\n\nDEBUG:openai.agents:Tracing is disabled. Not creating span &lt;agents.tracing.span_data.FunctionSpanData object at 0x108c4b290&gt;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"23_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E8%B0%83%E7%94%A8get_weather%E5%B7%A5%E5%85%B7\"><\/span>2.3 \u65e5\u5fd7\u5206\u6790\uff1a\u8c03\u7528get_weather\u5de5\u5177<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">DEBUG:openai.agents:Invoking tool get_weather with input {&quot;city&quot;:&quot;Tokyo&quot;}\nDEBUG:openai.agents:Tool call args: [&#039;Tokyo&#039;], kwargs: {}\nINFO:root:[DEBUG] Getting weather for Tokyo\nDEBUG:openai.agents:Tool get_weather returned The weather in Tokyo is sunny.\nDEBUG:openai.agents:Running agent Assistant (turn 2)\nDEBUG:openai.agents:Tracing is disabled. Not creating span &lt;agents.tracing.span_data.GenerationSpanData object at 0x108718dd0&gt;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"24_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E7%AC%AC%E4%BA%8C%E6%AC%A1%E8%AF%B7%E6%B1%82%E5%A4%A7%E6%A8%A1%E5%9E%8B\"><\/span>2.4 \u65e5\u5fd7\u5206\u6790\uff1a\u7b2c\u4e8c\u6b21\u8bf7\u6c42\u5927\u6a21\u578b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">DEBUG:openai.agents:[\n  {\n    &quot;content&quot;: &quot;You only respond in haikus.&quot;,\n    &quot;role&quot;: &quot;system&quot;\n  },\n  {\n    &quot;role&quot;: &quot;user&quot;,\n    &quot;content&quot;: &quot;What&#039;s the weather in Tokyo?&quot;\n  },\n  {\n    &quot;role&quot;: &quot;assistant&quot;,\n    &quot;tool_calls&quot;: [\n      {\n        &quot;id&quot;: &quot;call_0_6f04a7e3-acde-4ff1-b925-68c6294f3955&quot;,\n        &quot;type&quot;: &quot;function&quot;,\n        &quot;function&quot;: {\n          &quot;name&quot;: &quot;get_weather&quot;,\n          &quot;arguments&quot;: &quot;{\\&quot;city\\&quot;:\\&quot;Tokyo\\&quot;}&quot;\n        }\n      }\n    ]\n  },\n  {\n    &quot;role&quot;: &quot;tool&quot;,\n    &quot;tool_call_id&quot;: &quot;call_0_6f04a7e3-acde-4ff1-b925-68c6294f3955&quot;,\n    &quot;content&quot;: &quot;The weather in Tokyo is sunny.&quot;\n  }\n]\nTools:\n[\n  {\n    &quot;type&quot;: &quot;function&quot;,\n    &quot;function&quot;: {\n      &quot;name&quot;: &quot;get_weather&quot;,\n      &quot;description&quot;: &quot;&quot;,\n      &quot;parameters&quot;: {\n        &quot;properties&quot;: {\n          &quot;city&quot;: {\n            &quot;title&quot;: &quot;City&quot;,\n            &quot;type&quot;: &quot;string&quot;\n          }\n        },\n        &quot;required&quot;: [\n          &quot;city&quot;\n        ],\n        &quot;title&quot;: &quot;get_weather_args&quot;,\n        &quot;type&quot;: &quot;object&quot;,\n        &quot;additionalProperties&quot;: false\n      }\n    }\n  }\n]\nStream: False\nTool choice: NOT_GIVEN\nResponse format: NOT_GIVEN\n\nDEBUG:openai._base_client:Request options: {&#039;method&#039;: &#039;post&#039;, &#039;url&#039;: &#039;\/chat\/completions&#039;, &#039;headers&#039;: {&#039;User-Agent&#039;: &#039;Agents\/Python 0.0.0&#039;}, &#039;files&#039;: None, &#039;json_data&#039;: {&#039;messages&#039;: [{&#039;content&#039;: &#039;You only respond in haikus.&#039;, &#039;role&#039;: &#039;system&#039;}, {&#039;role&#039;: &#039;user&#039;, &#039;content&#039;: &quot;What&#039;s the weather in Tokyo?&quot;}, {&#039;role&#039;: &#039;assistant&#039;, &#039;tool_calls&#039;: [{&#039;id&#039;: &#039;call_0_6f04a7e3-acde-4ff1-b925-68c6294f3955&#039;, &#039;type&#039;: &#039;function&#039;, &#039;function&#039;: {&#039;name&#039;: &#039;get_weather&#039;, &#039;arguments&#039;: &#039;{&quot;city&quot;:&quot;Tokyo&quot;}&#039;}}]}, {&#039;role&#039;: &#039;tool&#039;, &#039;tool_call_id&#039;: &#039;call_0_6f04a7e3-acde-4ff1-b925-68c6294f3955&#039;, &#039;content&#039;: &#039;The weather in Tokyo is sunny.&#039;}], &#039;model&#039;: &#039;deepseek-chat&#039;, &#039;stream&#039;: False, &#039;tools&#039;: [{&#039;type&#039;: &#039;function&#039;, &#039;function&#039;: {&#039;name&#039;: &#039;get_weather&#039;, &#039;description&#039;: &#039;&#039;, &#039;parameters&#039;: {&#039;properties&#039;: {&#039;city&#039;: {&#039;title&#039;: &#039;City&#039;, &#039;type&#039;: &#039;string&#039;}}, &#039;required&#039;: [&#039;city&#039;], &#039;title&#039;: &#039;get_weather_args&#039;, &#039;type&#039;: &#039;object&#039;, &#039;additionalProperties&#039;: False}}}]}}\n\nDEBUG:openai._base_client:HTTP Request: POST https:\/\/api.deepseek.com\/v1\/chat\/completions &quot;200 OK&quot;\nDEBUG:openai.agents:LLM resp:\n{\n  &quot;content&quot;: &quot;Sunshine graces Tokyo,  \\nWarm and bright, the skies are clear\\u2014  \\nPerfect day to roam.&quot;,\n  &quot;refusal&quot;: null,\n  &quot;role&quot;: &quot;assistant&quot;,\n  &quot;annotations&quot;: null,\n  &quot;audio&quot;: null,\n  &quot;function_call&quot;: null,\n  &quot;tool_calls&quot;: null\n}<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"25_%E6%97%A5%E5%BF%97%E5%88%86%E6%9E%90%EF%BC%9A%E8%BE%93%E5%87%BA%E7%BB%93%E6%9E%9C\"><\/span>2.5 \u65e5\u5fd7\u5206\u6790\uff1a\u8f93\u51fa\u7ed3\u679c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">Sunshine graces Tokyo,  \nWarm and bright, the skies are clear\u2014  \nPerfect day to roam.\nDEBUG:openai.agents:Shutting down trace provider\nDEBUG:openai.agents:Shutting down trace processor &lt;agents.tracing.processors.BatchTraceProcessor object at 0x108304b10&gt;<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"3_%E9%80%9A%E8%BF%87mlflow%E5%8F%AF%E8%A7%86%E5%8C%96Agent%E8%BF%90%E8%A1%8C%E6%83%85%E5%86%B5\"><\/span>3. \u901a\u8fc7mlflow\u53ef\u89c6\u5316Agent\u8fd0\u884c\u60c5\u51b5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u7531\u4e8e\u4e0a\u9762logging\u8f93\u5165\u7684\u65e5\u5fd7\u9605\u8bfb\u8d77\u6765\u4e0d\u4fbf\uff0c\u6240\u4ee5\u5728\u6b64\u63d2\u5165\u4e00\u6b3e\u5f00\u6e90\u5de5\u5177MLflow\uff0c\u65b9\u4fbf\u53ef\u89c6\u5316\u7684\u65b9\u5f0f\u67e5\u770bAgent\u8fd0\u884c\u60c5\u51b5\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"31_MLflow%E7%AE%80%E4%BB%8B\"><\/span>3.1 MLflow\u7b80\u4ecb<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>MLflow \u662f\u4e00\u4e2a\u5f00\u6e90\u5e73\u53f0\uff0c\u4e13\u4e3a\u534f\u52a9\u673a\u5668\u5b66\u4e60\u4ece\u4e1a\u8005\u548c\u56e2\u961f\u5e94\u5bf9\u673a\u5668\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u7684\u590d\u6742\u6027\u800c\u8bbe\u8ba1\u3002MLflow \u5173\u6ce8\u673a\u5668\u5b66\u4e60\u9879\u76ee\u7684\u6574\u4e2a\u751f\u547d\u5468\u671f\uff0c\u786e\u4fdd\u6bcf\u4e2a\u9636\u6bb5\u90fd\u6613\u4e8e\u7ba1\u7406\u3001\u53ef\u8ffd\u6eaf\u4e14\u53ef\u91cd\u73b0\u3002<\/p>\n<p>\u5b98\u7f51\uff1a<a href=\"https:\/\/mlflow.org\/docs\/latest\/\">https:\/\/mlflow.org\/docs\/latest\/<\/a><\/p>\n<h4><span class=\"ez-toc-section\" id=\"32_%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96%E5%8C%85\"><\/span>3.2 \u5b89\u88c5\u4f9d\u8d56\u5305<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-bash\">pip install mlflow\n\n# \u53ef\u4ee5\u901a\u8fc7uv\u65b9\u5f0f\u5b89\u88c5\n# uv add openai-agents<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"33_%E5%90%AF%E5%8A%A8%E6%9C%8D%E5%8A%A1\"><\/span>3.3 \u542f\u52a8\u670d\u52a1<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5b89\u88c5\u5b8c\u6bd5\u4e4b\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u670d\u52a1<\/p>\n<pre><code class=\"language-bash\">mlflow server --host 127.0.0.1 --port 5000<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"34_%E6%94%B9%E9%80%A0Agent%E4%BB%A3%E7%A0%81\"><\/span>3.4 \u6539\u9020Agent\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728Agent\u4ee3\u7801\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-python\">import mlflow\n\n# Enable auto tracing for OpenAI Agents SDK\nmlflow.openai.autolog()\n\n# Optional: Set a tracking URI and an experiment\nmlflow.set_tracking_uri(&quot;http:\/\/127.0.0.1:5000&quot;)\nmlflow.set_experiment(&quot;OpenAI Agent&quot;)\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"35_%E9%87%8D%E6%96%B0%E8%BF%90%E8%A1%8CAgent%E4%BB%A3%E7%A0%81\"><\/span>3.5 \u91cd\u65b0\u8fd0\u884cAgent\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u91cd\u65b0\u8fd0\u884c\u4e0a\u8ff0\u793a\u4f8b\u4e2d\u7684Agent\u4ee3\u7801\uff0c\u7136\u540e\u8bbf\u95eehttp:\/\/127.0.0.1:5000\uff0c\u70b9\u51fb\u5bf9\u5e94\u9879\u76ee\u4e0b\u7684traces\uff0c\u5373\u53ef\u67e5\u770bAgent\u7684\u8c03\u7528\u8bb0\u5f55\u3002<br \/>\n<a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/Agent\u8c03\u7528\u8bb0\u5f55.png\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/Agent\u8c03\u7528\u8bb0\u5f55.png\" alt=\"\" \/><\/a><\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_%E4%B8%80%E4%B8%AA%E5%8F%AF%E4%BB%A5%E8%B0%83%E7%94%A8MCP%E6%9C%8D%E5%8A%A1%E7%9A%84Agent%E7%A4%BA%E4%BE%8B\"><\/span>4. \u4e00\u4e2a\u53ef\u4ee5\u8c03\u7528MCP\u670d\u52a1\u7684Agent\u793a\u4f8b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u57fa\u4e8eOpenAI\u5b98\u7f51\u63d0\u4f9b\u7684\u6848\u4f8b\uff0c\u5c1d\u8bd5\u901a\u8fc7AgentSDK\u5b9e\u73b0\u4e00\u4e2a\u53ef\u4ee5\u8c03\u7528MCP\u670d\u52a1\u7684Agent\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"41_%E5%90%AF%E5%8A%A8mcp-weather-server%E6%9C%8D%E5%8A%A1\"><\/span>4.1 \u542f\u52a8mcp-weather-server\u670d\u52a1<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u542f\u52a8\u5728<a href=\"https:\/\/17aitech.com\/?p=39764\">MCP\u534f\u8bae\u7b80\u8ff0\u81f3Mcp-server\u5b9e\u6218<\/a>\u4e2d\u521b\u5efa\u7684MCP SSE\u670d\u52a1\u3002<\/p>\n<pre><code>uv run weather.py<\/code><\/pre>\n<blockquote>\n<p>\u5907\u6ce8\uff1a\u53ef\u4ee5\u5728cherry-studio\u4e2d\u786e\u8ba4\u8be5\u670d\u52a1\u5df2\u7ecf\u542f\u52a8\u3002<\/p>\n<\/blockquote>\n<h4><span class=\"ez-toc-section\" id=\"42_%E6%94%B9%E9%80%A0Agent%E7%9A%84%E4%BB%A3%E7%A0%81\"><\/span>4.2 \u6539\u9020Agent\u7684\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li>\u6539\u9020\u83b7\u53d6\u5929\u6c14\u7684\u51fd\u6570\u3002<\/li>\n<\/ol>\n<p>\u6211\u4eec\u5c06<code>2.\u4e00\u4e2a\u7b80\u5355\u793a\u4f8b<\/code>\u4e2d\u7684 <code>get_weather()<\/code> \u51fd\u6570\u66ff\u6362\u4e3a\u4e0b\u9762\u7684\u4ee3\u7801\u3002<\/p>\n<pre><code class=\"language-python\">async def run(mcp_server: MCPServer):\n    # \u521d\u59cb\u5316OpenAI\u5ba2\u6237\u7aef\n    client = AsyncOpenAI(base_url=BASE_URL, api_key=API_KEY)\n    set_tracing_disabled(disabled=True)\n    agent = Agent(\n        name=&quot;Assistant&quot;,\n        instructions=&quot;Use the tools to get the weather of the city.&quot;,\n        mcp_servers=[mcp_server],\n        model=OpenAIChatCompletionsModel(model=MODEL_NAME, openai_client=client),\n    )\n\n    message = &quot;\u5317\u4eac\u4eca\u5929\u5929\u6c14\u600e\u4e48\u6837?&quot;\n    print(f&quot;Running: {message}&quot;)\n    result = await Runner.run(starting_agent=agent, input=message)\n    print(result.final_output)<\/code><\/pre>\n<ol start=\"2\">\n<li>\u4fee\u6539main\u51fd\u6570\u4e2d\u7684\u4ee3\u7801\n<pre><code class=\"language-python\">async with MCPServerSse(\n    name=&quot;weather SSE Server&quot;,\n    params={\n        &quot;url&quot;: &quot;http:\/\/localhost:8000\/sse&quot;,\n    },\n) as server:\n    await run(server)<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>\u5176\u4f59\u90e8\u5206\u4ee3\u7801\u4e0d\u53d8\uff0c\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-python\">import asyncio\nimport logging\nimport mlflow\nimport os\nfrom openai import AsyncOpenAI\nfrom agents import Agent, OpenAIChatCompletionsModel, Runner, set_tracing_disabled\nfrom agents.mcp import MCPServer, MCPServerSse\n\n# \u521d\u59cb\u5316\u53d8\u91cf\nBASE_URL = os.getenv(&quot;BASE_URL&quot;, &quot;https:\/\/api.deepseek.com\/v1&quot;)\nAPI_KEY = os.getenv(&quot;API_KEY&quot;, &quot;sk-0d9449d2355a4c63******&quot;)\nMODEL_NAME = os.getenv(&quot;MODEL_NAME&quot;, &quot;deepseek-chat&quot;)\n\n# \u542f\u7528OpenAI Agents SDK\u7684\u81ea\u52a8\u8ffd\u8e2a\nmlflow.openai.autolog()\n\n# \u8bbe\u7f6e\u8ffd\u8e2aURI\u548c\u5b9e\u9a8c\nmlflow.set_tracking_uri(&quot;http:\/\/127.0.0.1:5000&quot;)\nmlflow.set_experiment(&quot;OpenAI Agent&quot;)\n\nasync def run(mcp_server: MCPServer):\n    # \u521d\u59cb\u5316OpenAI\u5ba2\u6237\u7aef\n    client = AsyncOpenAI(base_url=BASE_URL, api_key=API_KEY)\n    set_tracing_disabled(disabled=True)\n\n    agent = Agent(\n        name=&quot;Assistant&quot;,\n        instructions=&quot;Use the tools to get the weather of the city.&quot;,\n        mcp_servers=[mcp_server],\n        model=OpenAIChatCompletionsModel(model=MODEL_NAME, openai_client=client),\n    )\n\n    message = &quot;\u5317\u4eac\u4eca\u5929\u5929\u6c14\u600e\u4e48\u6837?&quot;\n    print(f&quot;Running: {message}&quot;)\n    result = await Runner.run(starting_agent=agent, input=message)\n    print(result.final_output)\n\nasync def main():\n    async with MCPServerSse(\n        name=&quot;weather SSE Server&quot;,\n        params={\n            &quot;url&quot;: &quot;http:\/\/localhost:8000\/sse&quot;,\n        },\n    ) as server:\n        await run(server)\n\nif __name__ == &quot;__main__&quot;:\n    asyncio.run(main())<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"43_%E8%BF%90%E8%A1%8CAgent%E7%9A%84%E4%BB%A3%E7%A0%81\"><\/span>4.3 \u8fd0\u884cAgent\u7684\u4ee3\u7801<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<br \/>\n<a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/agent\u8fd0\u884c\u7ed3\u679c.png\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/agent\u8fd0\u884c\u7ed3\u679c.png\" alt=\"\" \/><\/a><\/p>\n<p>\u67e5\u770bMLflow\u4e2d\u7684Trace\u65e5\u5fd7\uff1a<br \/>\n<a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/mlflow\u4e2dget_weather.png\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/mlflow\u4e2dget_weather.png\" alt=\"\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E6%80%BB%E7%BB%93\"><\/span>\u603b\u7ed3<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\u901a\u8fc7<code>OpenAI<\/code>\u7684<code>Agent SDK<\/code>\uff0c\u53ef\u4ee5\u5feb\u901f\u5b9e\u73b0\u4e00\u4e2a<code>Agent<\/code>\u3002<\/li>\n<li>\u5728<code>Agent SDK<\/code>\u4e2d\u5982\u679c\u8c03\u7528\u975e<code>OpenAI<\/code>\u7684API\uff0c\u53ef\u4ee5\u901a\u8fc7<code>AsyncOpenAI(base_url=BASE_URL, api_key=API_KEY)<\/code>\u6765\u6307\u5b9aAPI\u5730\u5740\u548cAPI Key\u3002<\/li>\n<li>\u901a\u8fc7\u5f00\u6e90\u9879\u76ee<code>MLflow<\/code>\uff0c\u53ef\u4ee5\u8bb0\u5f55<code>Agent<\/code>\u7684\u8fd0\u884c\u65e5\u5fd7\uff0c\u4fbf\u4e8e\u540e\u7eed\u5206\u6790\u3002<\/li>\n<li><code>Agent<\/code>\u5728\u8c03\u7528<code>MCP\u670d\u52a1(SSE\u534f\u8bae)<\/code>\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7<code>async with MCPServerSse<\/code>\u6765\u5b9e\u73b0\u3002<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99\"><\/span>\u53c2\u8003\u8d44\u6599<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/openai.github.io\/openai-agents-python\/mcp\/\">OpenAI\u5b98\u65b9\u6587\u6863\uff1amcp\u793a\u4f8b<\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E5%85%B6%E4%BB%96%E6%96%87%E7%AB%A0\"><\/span>\u5176\u4ed6\u6587\u7ae0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><a href=\"https:\/\/17aitech.com\/?p=39674\">\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4bMCP\u7b80\u8ff0<\/a><\/li>\n<li><a href=\"https:\/\/17aitech.com\/?p=39764\">\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4bMCP-server(sse\u65b9\u5f0f)\u5b9e\u8df5<\/a><\/li>\n<li><a href=\"https:\/\/17aitech.com\/?p=39769\">\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server<\/a><\/li>\n<\/ul>\n<p align=\"center\">\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\u4ee5\u83b7\u5f97\u6700\u65b0\u7684\u6587\u7ae0\u548c\u65b0\u95fb<\/p>\n<p><a href=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/09\/\u626b\u7801_\u641c\u7d22\u8054\u5408\u4f20\u64ad\u6837\u5f0f-\u767d\u8272\u7248.bmp\" data-fancybox=\"images\" data-fancybox=\"gallery\"><img decoding=\"async\" src=\"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/09\/\u626b\u7801_\u641c\u7d22\u8054\u5408\u4f20\u64ad\u6837\u5f0f-\u767d\u8272\u7248.bmp\" alt=\"\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u80cc\u666f OpenAI\u57283\u670827\u65e5\u5ba3\u5e03\u5bf9\u5176  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":39774,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"aside","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[28],"tags":[70,85],"class_list":["post-39769","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-blog","tag-agent","tag-mcp","post_format-post-format-aside"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server - \u4e00\u8d77AI\u6280\u672f<\/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:\/\/17aitech.com\/?p=39769\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/17aitech.com\/?p=39769\",\"url\":\"https:\/\/17aitech.com\/?p=39769\",\"name\":\"\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server - \u4e00\u8d77AI\u6280\u672f\",\"isPartOf\":{\"@id\":\"https:\/\/17aitech.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/17aitech.com\/?p=39769#primaryimage\"},\"image\":{\"@id\":\"https:\/\/17aitech.com\/?p=39769#primaryimage\"},\"thumbnailUrl\":\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/\u5c01\u9762-2.jpeg\",\"datePublished\":\"2025-03-31T09:10:45+00:00\",\"dateModified\":\"2025-03-31T10:25:33+00:00\",\"author\":{\"@id\":\"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739\"},\"breadcrumb\":{\"@id\":\"https:\/\/17aitech.com\/?p=39769#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/17aitech.com\/?p=39769\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/17aitech.com\/?p=39769#primaryimage\",\"url\":\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/\u5c01\u9762-2.jpeg\",\"contentUrl\":\"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/\u5c01\u9762-2.jpeg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/17aitech.com\/?p=39769#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/17aitech.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/17aitech.com\/#website\",\"url\":\"https:\/\/17aitech.com\/\",\"name\":\"\u4e00\u8d77AI\u6280\u672f\",\"description\":\"\u8ba9AI\u77e5\u8bc6\u89e6\u624b\u53ef\u53ca\",\"alternateName\":\"\u4e00\u8d77AI\u6280\u672f\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/17aitech.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739\",\"name\":\"Dongming\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/17aitech.com\/#\/schema\/person\/image\/\",\"url\":\"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg\",\"contentUrl\":\"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg\",\"caption\":\"Dongming\"},\"description\":\"\u89c1\u5929\u5730\uff0c\u89c1\u4f17\u751f\uff0c\u89c1\u81ea\u5df1\u3002\",\"sameAs\":[\"http:\/\/17aitech.com\"],\"url\":\"https:\/\/17aitech.com\/?page_id=33738&user=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server - \u4e00\u8d77AI\u6280\u672f","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:\/\/17aitech.com\/?p=39769","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/17aitech.com\/?p=39769","url":"https:\/\/17aitech.com\/?p=39769","name":"\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server - \u4e00\u8d77AI\u6280\u672f","isPartOf":{"@id":"https:\/\/17aitech.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/17aitech.com\/?p=39769#primaryimage"},"image":{"@id":"https:\/\/17aitech.com\/?p=39769#primaryimage"},"thumbnailUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/\u5c01\u9762-2.jpeg","datePublished":"2025-03-31T09:10:45+00:00","dateModified":"2025-03-31T10:25:33+00:00","author":{"@id":"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739"},"breadcrumb":{"@id":"https:\/\/17aitech.com\/?p=39769#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/17aitech.com\/?p=39769"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/17aitech.com\/?p=39769#primaryimage","url":"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/\u5c01\u9762-2.jpeg","contentUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2025\/03\/\u5c01\u9762-2.jpeg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/17aitech.com\/?p=39769#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/17aitech.com\/"},{"@type":"ListItem","position":2,"name":"\u3010\u5b66\u4e60\u603b\u7ed3\u3011MCP\u534f\u8bae\u4e4b\u4f7f\u7528AgentSDK\u8c03\u7528MCP-server"}]},{"@type":"WebSite","@id":"https:\/\/17aitech.com\/#website","url":"https:\/\/17aitech.com\/","name":"\u4e00\u8d77AI\u6280\u672f","description":"\u8ba9AI\u77e5\u8bc6\u89e6\u624b\u53ef\u53ca","alternateName":"\u4e00\u8d77AI\u6280\u672f","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/17aitech.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739","name":"Dongming","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/17aitech.com\/#\/schema\/person\/image\/","url":"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg","contentUrl":"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg","caption":"Dongming"},"description":"\u89c1\u5929\u5730\uff0c\u89c1\u4f17\u751f\uff0c\u89c1\u81ea\u5df1\u3002","sameAs":["http:\/\/17aitech.com"],"url":"https:\/\/17aitech.com\/?page_id=33738&user=1"}]}},"_links":{"self":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/39769","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39769"}],"version-history":[{"count":6,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/39769\/revisions"}],"predecessor-version":[{"id":39789,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/39769\/revisions\/39789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/media\/39774"}],"wp:attachment":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}