{"id":463387,"date":"2025-06-14T21:00:25","date_gmt":"2025-06-14T21:00:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=463387"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=463387","title":{"rendered":"<span>MCP (Model Context Protocol) \u0434\u043b\u044f \u043d\u0435\u0438\u0441\u043a\u0443\u0448\u0435\u043d\u043d\u044b\u0445<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0431\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0442\u0438\u0432 \u0431\u044b\u043b \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0441\u0442\u043d\u043e, \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u043e \u0440\u044f\u0434\u0443 \u043f\u0440\u0438\u0447\u0438\u043d, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432 \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0440\u0435\u0448\u0438\u043b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0412\u0441\u0435 \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0433\u043b\u0430\u0437\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u043d\u0430\u0434\u0435\u0436\u0438\u0432\u0430\u044e\u0449\u0435 \u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e.  \u0421 \u043c\u0435\u0441\u0442\u0430 \u0432\u0441\u0435 \u0441\u0434\u0432\u0438\u043d\u0443\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 <a href=\"https:\/\/habr.com\/ru\/companies\/datafeel\/articles\/907448\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/a>. \u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u044b\u043c, \u0447\u0442\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u043a\u043e\u043f\u0430\u0442\u044c \u0432\u0433\u043b\u0443\u0431\u044c \u0442\u0435\u043c\u044b. \u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0438 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0431\u044b\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0436\u0435 llm \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0438 \u0447\u0442\u043e \u044d\u0442\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u043e\u0433\u0443\u0442. <\/p>\n<\/li>\n<li>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e \u0442\u043e\u043c \u0432\u0441\u0435 \u043b\u0438 llm \u0434\u0440\u0443\u0436\u0430\u0442 \u0441 mcp \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0433 \u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u043e \u0438 \u043d\u0435 \u0431\u044b\u043b \u0431\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u00a0Claude Desktop.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">  import os from mcp.server.fastmcp import FastMCP  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c MCP \u0441\u0435\u0440\u0432\u0435\u0440 mcp = FastMCP(\"FileTools\")  # \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 (\u0432\u043c\u0435\u0441\u0442\u043e CFG.BASE_DIR) BASE_DIR = os.path.join(os.path.dirname(__file__), \"files\")  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0435\u0441\u043b\u0438 \u0435\u0451 \u043d\u0435\u0442 os.makedirs(BASE_DIR, exist_ok=True)    @mcp.tool() def create_folder(folder_name: str) -&gt; str:     \"\"\"\u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     folder_path = os.path.join(BASE_DIR, folder_name)     try:         os.makedirs(folder_path, exist_ok=True)         return f\"\u041f\u0430\u043f\u043a\u0430 '{folder_name}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0432 {folder_path}\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0430\u043f\u043a\u0438: {e}\"  @mcp.tool() def create_text_file(file_name: str, content: str) -&gt; str:     \"\"\"\u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     file_path = os.path.join(BASE_DIR, file_name)     try:         with open(file_path, 'w', encoding='utf-8') as file:             file.write(content)         return f\"\u0424\u0430\u0439\u043b '{file_name}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d \u0432 {file_path}\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430: {e}\"  @mcp.tool() def read_text_file(file_name: str) -&gt; str:     \"\"\"\u0427\u0438\u0442\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.\"\"\"     file_path = os.path.join(BASE_DIR, file_name)     try:         with open(file_path, 'r', encoding='utf-8') as file:             content = file.read()         return f\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 '{file_name}':\\n{content}\"     except FileNotFoundError:         return f\"\u0424\u0430\u0439\u043b '{file_name}' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430: {e}\"  @mcp.tool() def list_files() -&gt; str:     \"\"\"\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     try:         items = os.listdir(BASE_DIR)         if not items:             return \"\u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043f\u0443\u0441\u0442\u0430\"                  files = []         folders = []         for item in items:             item_path = os.path.join(BASE_DIR, item)             if os.path.isfile(item_path):                 files.append(f\"\ud83d\udcc4 {item}\")             else:                 folders.append(f\"\ud83d\udcc1 {item}\")                  result = f\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 {BASE_DIR}:\\n\"         if folders:             result += \"\u041f\u0430\u043f\u043a\u0438:\\n\" + \"\\n\".join(folders) + \"\\n\"         if files:             result += \"\u0424\u0430\u0439\u043b\u044b:\\n\" + \"\\n\".join(files)                  return result     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432: {e}\"  @mcp.tool() def delete_file(file_name: str) -&gt; str:     \"\"\"\u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     file_path = os.path.join(BASE_DIR, file_name)     try:         if os.path.exists(file_path):             if os.path.isfile(file_path):                 os.remove(file_path)                 return f\"\u0424\u0430\u0439\u043b '{file_name}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0434\u0430\u043b\u0435\u043d\"             else:                 return f\"'{file_name}' \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u043f\u043a\u043e\u0439, \u043d\u0435 \u0444\u0430\u0439\u043b\u043e\u043c\"         else:             return f\"\u0424\u0430\u0439\u043b '{file_name}' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430: {e}\"  if __name__ == \"__main__\":     print(f\"\u0417\u0430\u043f\u0443\u0441\u043a \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f: {BASE_DIR}\")     mcp.run(transport=\"stdio\")  <\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0410 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 MultiServerMCPClient \u0438\u0437  langchain_mcp_adapters.client import <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0431\u0435\u0437 llm<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">#\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \"args\": [r\".\\mcp_server\\server_2.py\"], \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0443\u0442\u044c \u043a \u0432\u0430\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 import asyncio from langchain_mcp_adapters.client import MultiServerMCPClient  async def main():     client = MultiServerMCPClient(         {             \"db_sqlite\": {                 \"command\": \"python\",                 \"args\": [r\".\\mcp_server\\server_2.py\"],                 \"transport\": \"stdio\",                 # \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \"env\": {...}             }         }     )     try:         async with client.session(\"db_sqlite\") as session:             tools = await client.get_tools(server_name=\"db_sqlite\")             if tools:                 print(\"\u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:\")                 for tool in tools:                     print(f\"- {tool.name}: {tool.description}\")             else:                 print(\"\u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d, \u043d\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b.\")     except Exception as e:         print(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443:\", e)  if __name__ == \"__main__\":     asyncio.run(main())<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>MultiServerMCPClient<\/code>\u00a0 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 mcp \u0441\u0435\u0440\u0432\u0435\u0440, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f!<\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0430:  <code>MultiServerMCPClient<\/code>\u00a0&#8212; \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<code>langchain-mcp-adapters<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 MCP (Model Context Protocol) \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.  <\/p>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b( \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code><strong>get_tools)<\/strong><\/code>:<\/p>\n<ol start=\"2\">\n<li>\n<p><code>session()<\/code>: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p><code><strong>get_tools()<\/strong><\/code><strong>: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<\/strong><\/p>\n<\/li>\n<li>\n<p><code>get_prompt()<\/code>: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p><code>get_resources()<\/code>: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p><strong><em>\u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/em><\/strong><\/p>\n<ul>\n<li>\n<p><strong><em>create_folder: \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>create_text_file: \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>read_text_file: \u0427\u0438\u0442\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>list_files: \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>delete_file: \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438<\/em><\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043b\u0430\u0441\u0441\u0443 MultiServerMCPClient, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 ( tools) \u0442\u0430\u043a \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435   \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <strong>\u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/strong>\u00a0(docstring)! \u0418 \u044d\u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u043c\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 LLM \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430. \u0422\u043e \u0435\u0441\u0442\u044c, \u0447\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u0443\u043f\u0440\u0435\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442.<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e!<br \/>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u044d\u0442\u043e \u043a\u0430\u043a \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u0438\u043c \u043b\u0438\u0431\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c?<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0434:<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">#\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \"args\": [r\".\\mcp_server\\server_2.py\"], \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0443\u0442\u044c \u043a \u0432\u0430\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 import asyncio from langchain_mcp_adapters.client import MultiServerMCPClient from langchain_mcp_adapters.tools import load_mcp_tools  async def main():     # \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f MCP \u0441\u0435\u0440\u0432\u0435\u0440\u0430     client = MultiServerMCPClient(         {             \"files\": {                 \"command\": \"python\",                 \"args\": [r\".\\mcp_server\\server_2.py\"],                 \"transport\": \"stdio\",             }         }     )      try:         # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \"files\"         async with client.session(\"files\") as session:             # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430             tools = await load_mcp_tools(session)             if not tools:                 print(\"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.\")                 return              print(\"\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:\")             for tool in tools:                 print(f\"- {tool.name}: {tool.description}\")              # \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \"list_files\"             list_files_tool = next((t for t in tools if t.name == \"list_files\"), None)             print ('\u0422\u0438\u043f list_files_tool',type(list_files_tool))             print ('\u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 list_files_tool: \\n',list_files_tool)             print(list_files_tool.coroutine)              if not list_files_tool:                 print(\"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 'list_files' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.\")                 return              # \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 (\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430)             # \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043f\u0443\u0442\u0438             input_args = {\"path\": \".\"}  # \u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f              # \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e             result = await list_files_tool.arun(input_args)             print(\"\\n\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a):\")             print(result)      except Exception as e:         print(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 MCP \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c:\", e)  if __name__ == \"__main__\":     asyncio.run(main()) <\/code><\/pre>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/91a\/355\/eac\/91a355eacf63ec4450d309185bfb1101.jpg\" width=\"2826\" height=\"868\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/91a\/355\/eac\/91a355eacf63ec4450d309185bfb1101.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/91a\/355\/eac\/91a355eacf63ec4450d309185bfb1101.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e mcp \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 LLM.<\/p>\n<p>\u041f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u0432 \u044d\u0442\u043e\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441\u043b\u0443\u0436\u0430\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Langchain \u0438 <code>Langgraph \u0432   \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f create_react_agent ( \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 ,\u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c\u043e\u0439 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435)<\/code><\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0430:<br \/><code>create_react_agent<\/code>\u00a0&#8212; \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LangGraph, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u0433\u0435\u043d\u0442\u0430 \u0441 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 ReAct (Reasoning and Acting). \u0412\u043e\u0442 \u0435\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/p>\n<p>\u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 reasoning (\u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c) \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<p><strong>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0441\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 :<\/p>\n<ul>\n<li>\n<p>\u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c LLM \u043e \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u0432\u044b\u0437\u043e\u0432\u0430.<\/p>\n<\/li>\n<li>\n<p>LLM \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0442\u0430\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e \u0432\u044b\u0431\u043e\u0440 LLM.<\/p>\n<p>\u041e\u0442\u0432\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439: \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 LLM \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0440\u0435\u0436\u0438\u043c tools. \u041f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c qwen \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0414\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u0432\u043e\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0442 \u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 tools. \u041d\u043e, \u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u044d\u0442\u043e \u0434\u0435\u043b\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u0418 \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u0440\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u041f\u043e\u043c\u0438\u043c\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0440\u0430\u0437\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043a\u0430\u043a\u043e\u0439 \u0432\u0430\u043c \u043f\u043e \u0434\u0443\u0448\u0435. \u042f \u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b PyQt5 \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043c\u044b \u043e\u043f\u0438\u0448\u0443 \u0441\u0432\u043e\u0439 \u043e\u043f\u044b\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f sqllite \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0441\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/918390\/\"> https:\/\/habr.com\/ru\/articles\/918390\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u043e\u0431\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0442\u0438\u0432 \u0431\u044b\u043b \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0441\u0442\u043d\u043e, \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u0430\u043b \u043f\u043e \u0440\u044f\u0434\u0443 \u043f\u0440\u0438\u0447\u0438\u043d, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u0432 \u043d\u043e\u0432\u043e\u0439 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0440\u0435\u0448\u0438\u043b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f. \u0412\u0441\u0435 \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0433\u043b\u0430\u0437\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0431\u043d\u0430\u0434\u0435\u0436\u0438\u0432\u0430\u044e\u0449\u0435 \u0438 \u0441\u043a\u043e\u0440\u0435\u0435 \u043e\u0434\u043d\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e.  \u0421 \u043c\u0435\u0441\u0442\u0430 \u0432\u0441\u0435 \u0441\u0434\u0432\u0438\u043d\u0443\u043b\u043e\u0441\u044c \u043f\u043e\u0441\u043b\u0435 <a href=\"https:\/\/habr.com\/ru\/companies\/datafeel\/articles\/907448\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/a>. \u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0438 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u044b\u043c, \u0447\u0442\u043e \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u043a\u043e\u043f\u0430\u0442\u044c \u0432\u0433\u043b\u0443\u0431\u044c \u0442\u0435\u043c\u044b. \u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0438 \u0442\u0430\u043a:<\/p>\n<ul>\n<li>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u0431\u044b\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0436\u0435 llm \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0438 \u0447\u0442\u043e \u044d\u0442\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043c\u043e\u0433\u0443\u0442. <\/p>\n<\/li>\n<li>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e \u0442\u043e\u043c \u0432\u0441\u0435 \u043b\u0438 llm \u0434\u0440\u0443\u0436\u0430\u0442 \u0441 mcp \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0435\u0442\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0431\u044b\u043b \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0433 \u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043d\u043e \u0438 \u043d\u0435 \u0431\u044b\u043b \u0431\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u00a0Claude Desktop.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">  import os from mcp.server.fastmcp import FastMCP  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c MCP \u0441\u0435\u0440\u0432\u0435\u0440 mcp = FastMCP(\"FileTools\")  # \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432 (\u0432\u043c\u0435\u0441\u0442\u043e CFG.BASE_DIR) BASE_DIR = os.path.join(os.path.dirname(__file__), \"files\")  # \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0435\u0441\u043b\u0438 \u0435\u0451 \u043d\u0435\u0442 os.makedirs(BASE_DIR, exist_ok=True)    @mcp.tool() def create_folder(folder_name: str) -&gt; str:     \"\"\"\u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     folder_path = os.path.join(BASE_DIR, folder_name)     try:         os.makedirs(folder_path, exist_ok=True)         return f\"\u041f\u0430\u043f\u043a\u0430 '{folder_name}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0432 {folder_path}\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0430\u043f\u043a\u0438: {e}\"  @mcp.tool() def create_text_file(file_name: str, content: str) -&gt; str:     \"\"\"\u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     file_path = os.path.join(BASE_DIR, file_name)     try:         with open(file_path, 'w', encoding='utf-8') as file:             file.write(content)         return f\"\u0424\u0430\u0439\u043b '{file_name}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d \u0432 {file_path}\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430: {e}\"  @mcp.tool() def read_text_file(file_name: str) -&gt; str:     \"\"\"\u0427\u0438\u0442\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.\"\"\"     file_path = os.path.join(BASE_DIR, file_name)     try:         with open(file_path, 'r', encoding='utf-8') as file:             content = file.read()         return f\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 '{file_name}':\\n{content}\"     except FileNotFoundError:         return f\"\u0424\u0430\u0439\u043b '{file_name}' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430: {e}\"  @mcp.tool() def list_files() -&gt; str:     \"\"\"\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     try:         items = os.listdir(BASE_DIR)         if not items:             return \"\u0414\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f \u043f\u0443\u0441\u0442\u0430\"                  files = []         folders = []         for item in items:             item_path = os.path.join(BASE_DIR, item)             if os.path.isfile(item_path):                 files.append(f\"\ud83d\udcc4 {item}\")             else:                 folders.append(f\"\ud83d\udcc1 {item}\")                  result = f\"\u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 {BASE_DIR}:\\n\"         if folders:             result += \"\u041f\u0430\u043f\u043a\u0438:\\n\" + \"\\n\".join(folders) + \"\\n\"         if files:             result += \"\u0424\u0430\u0439\u043b\u044b:\\n\" + \"\\n\".join(files)                  return result     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432: {e}\"  @mcp.tool() def delete_file(file_name: str) -&gt; str:     \"\"\"\u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.\"\"\"     file_path = os.path.join(BASE_DIR, file_name)     try:         if os.path.exists(file_path):             if os.path.isfile(file_path):                 os.remove(file_path)                 return f\"\u0424\u0430\u0439\u043b '{file_name}' \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0443\u0434\u0430\u043b\u0435\u043d\"             else:                 return f\"'{file_name}' \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0430\u043f\u043a\u043e\u0439, \u043d\u0435 \u0444\u0430\u0439\u043b\u043e\u043c\"         else:             return f\"\u0424\u0430\u0439\u043b '{file_name}' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"     except Exception as e:         return f\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0444\u0430\u0439\u043b\u0430: {e}\"  if __name__ == \"__main__\":     print(f\"\u0417\u0430\u043f\u0443\u0441\u043a \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0411\u0430\u0437\u043e\u0432\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f: {BASE_DIR}\")     mcp.run(transport=\"stdio\")  <\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0410 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 MultiServerMCPClient \u0438\u0437  langchain_mcp_adapters.client import <\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0431\u0435\u0437 llm<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">#\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \"args\": [r\".\\mcp_server\\server_2.py\"], \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0443\u0442\u044c \u043a \u0432\u0430\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 import asyncio from langchain_mcp_adapters.client import MultiServerMCPClient  async def main():     client = MultiServerMCPClient(         {             \"db_sqlite\": {                 \"command\": \"python\",                 \"args\": [r\".\\mcp_server\\server_2.py\"],                 \"transport\": \"stdio\",                 # \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \"env\": {...}             }         }     )     try:         async with client.session(\"db_sqlite\") as session:             tools = await client.get_tools(server_name=\"db_sqlite\")             if tools:                 print(\"\u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:\")                 for tool in tools:                     print(f\"- {tool.name}: {tool.description}\")             else:                 print(\"\u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d, \u043d\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b.\")     except Exception as e:         print(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443:\", e)  if __name__ == \"__main__\":     asyncio.run(main())<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>MultiServerMCPClient<\/code>\u00a0 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0439 mcp \u0441\u0435\u0440\u0432\u0435\u0440, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f!<\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0430:  <code>MultiServerMCPClient<\/code>\u00a0&#8212; \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438\u00a0<code>langchain-mcp-adapters<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 MCP (Model Context Protocol) \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e.  <\/p>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b( \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code><strong>get_tools)<\/strong><\/code>:<\/p>\n<ol start=\"2\">\n<li>\n<p><code>session()<\/code>: \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p><code><strong>get_tools()<\/strong><\/code><strong>: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043e \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432<\/strong><\/p>\n<\/li>\n<li>\n<p><code>get_prompt()<\/code>: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u043f\u0442\u0430 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<li>\n<p><code>get_resources()<\/code>: \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<p><strong><em>\u0421\u0435\u0440\u0432\u0435\u0440 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e. \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:<\/em><\/strong><\/p>\n<ul>\n<li>\n<p><strong><em>create_folder: \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>create_text_file: \u0421\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>read_text_file: \u0427\u0438\u0442\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>list_files: \u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438.<\/em><\/strong><\/p>\n<\/li>\n<li>\n<p><strong><em>delete_file: \u0423\u0434\u0430\u043b\u044f\u0435\u0442 \u0444\u0430\u0439\u043b \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438<\/em><\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043b\u0430\u0441\u0441\u0443 MultiServerMCPClient, \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 ( tools) \u0442\u0430\u043a \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u0440\u0438\u0447\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435   \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f <strong>\u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/strong>\u00a0(docstring)! \u0418 \u044d\u0442\u043e \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u043e\u043c\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 LLM \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430. \u0422\u043e \u0435\u0441\u0442\u044c, \u0447\u0435\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0431\u0435\u0437\u0443\u043f\u0440\u0435\u0447\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442.<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e!<br \/>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u044d\u0442\u043e \u043a\u0430\u043a \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a\u0438\u043c \u043b\u0438\u0431\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c?<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0434:<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">#\u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \"args\": [r\".\\mcp_server\\server_2.py\"], \u0443\u043a\u0430\u0437\u0430\u0432 \u043f\u0443\u0442\u044c \u043a \u0432\u0430\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 import asyncio from langchain_mcp_adapters.client import MultiServerMCPClient from langchain_mcp_adapters.tools import load_mcp_tools  async def main():     # \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f MCP \u0441\u0435\u0440\u0432\u0435\u0440\u0430     client = MultiServerMCPClient(         {             \"files\": {                 \"command\": \"python\",                 \"args\": [r\".\\mcp_server\\server_2.py\"],                 \"transport\": \"stdio\",             }         }     )      try:         # \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \"files\"         async with client.session(\"files\") as session:             # \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430             tools = await load_mcp_tools(session)             if not tools:                 print(\"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.\")                 return              print(\"\u0414\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b:\")             for tool in tools:                 print(f\"- {tool.name}: {tool.description}\")              # \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \"list_files\"             list_files_tool = next((t for t in tools if t.name == \"list_files\"), None)             print ('\u0422\u0438\u043f list_files_tool',type(list_files_tool))             print ('\u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 list_files_tool: \\n',list_files_tool)             print(list_files_tool.coroutine)              if not list_files_tool:                 print(\"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 'list_files' \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d.\")                 return              # \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0443 (\u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430)             # \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u0435\u0437 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043f\u0443\u0442\u0438             input_args = {\"path\": \".\"}  # \u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044f              # \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e             result = await list_files_tool.arun(input_args)             print(\"\\n\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u043f\u0430\u043f\u043e\u043a):\")             print(result)      except Exception as e:         print(\"\u041e\u0448\u0438\u0431\u043a\u0430 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 MCP \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c:\", e)  if __name__ == \"__main__\":     asyncio.run(main()) <\/code><\/pre>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><\/figure>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e mcp \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0438 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435. \u0415\u0441\u0442\u044c \u0435\u0449\u0435 \u0438 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0435\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f mcp \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 LLM.<\/p>\n<p>\u041f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u043e\u043c \u0432 \u044d\u0442\u043e\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0432 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0441\u043b\u0443\u0436\u0430\u0442 \u043a\u043b\u0430\u0441\u0441\u044b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 Langchain \u0438 <code>Langgraph \u0432   \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f create_react_agent ( \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0441\u0442\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 ,\u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c\u043e\u0439 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435)<\/code><\/p>\n<p>\u0420\u0435\u043c\u0430\u0440\u043a\u0430:<br \/><code>create_react_agent<\/code>\u00a0&#8212; \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 LangGraph, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u0433\u0435\u043d\u0442\u0430 \u0441 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 ReAct (Reasoning and Acting). \u0412\u043e\u0442 \u0435\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435:<\/p>\n<p>\u041f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u043b\u043b\u0435\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0430\u0433\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 reasoning (\u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u0442\u044c) \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<p><strong>\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0414\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0432\u044b\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u043e\u0448\u0430\u0433\u043e\u0432\u044b\u0445 \u0437\u0430\u0434\u0430\u0447<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-463387","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=463387"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/463387\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=463387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=463387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=463387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}