{
  "canonical_name": "LeelaissakAttota/mcp-ai-agent",
  "compilation_id": "pack_21e1962276ad40c299659db3ac1ec275",
  "created_at": "2026-05-15T07:19:50.109936+00:00",
  "created_by": "project-pack-compiler",
  "feedback": {
    "carrier_selection_notes": [
      "viable_asset_types=mcp_config, recipe, host_instruction, eval, preflight",
      "recommended_asset_types=mcp_config, recipe, host_instruction, eval, preflight"
    ],
    "evidence_delta": {
      "confirmed_claims": [
        "identity_anchor_present",
        "capability_and_host_targets_present",
        "install_path_declared_or_better"
      ],
      "missing_required_fields": [],
      "must_verify_forwarded": [
        "Run or inspect `npx metmuseum-mcp` in an isolated environment.",
        "Confirm the project exposes the claimed capability to at least one target host."
      ],
      "quickstart_execution_scope": "allowlisted_sandbox_smoke",
      "sandbox_command": "npx metmuseum-mcp",
      "sandbox_container_image": "node:22-slim",
      "sandbox_execution_backend": "docker",
      "sandbox_planner_decision": "llm_execute_isolated_install",
      "sandbox_validation_id": "sbx_ccdb5337e58a4efa940bd0efa5441305"
    },
    "feedback_event_type": "project_pack_compilation_feedback",
    "learning_candidate_reasons": [],
    "template_gaps": []
  },
  "identity": {
    "canonical_id": "project_9c93cf81c5d4c68e58c1726d77770728",
    "canonical_name": "LeelaissakAttota/mcp-ai-agent",
    "homepage_url": null,
    "license": "unknown",
    "repo_url": "https://github.com/LeelaissakAttota/mcp-ai-agent",
    "slug": "mcp-ai-agent",
    "source_packet_id": "phit_eb5664b8920445c19f82f29bffba7a1e",
    "source_validation_id": "dval_f6686d472c4548ada16c6e08363cb8f5"
  },
  "merchandising": {
    "best_for": "需要工具连接与集成能力，并使用 mcp_host的用户",
    "github_forks": 0,
    "github_stars": 1,
    "one_liner_en": "Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory",
    "one_liner_zh": "Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory",
    "primary_category": {
      "category_id": "tool-integrations",
      "confidence": "high",
      "name_en": "Tool Integrations",
      "name_zh": "工具连接与集成",
      "reason": "matched_keywords:mcp, server, github"
    },
    "target_user": "使用 mcp_host 等宿主 AI 的用户",
    "title_en": "mcp-ai-agent",
    "title_zh": "mcp-ai-agent 能力包",
    "visible_tags": [
      {
        "label_en": "MCP Tools",
        "label_zh": "MCP 工具",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "product_domain-mcp-tools",
        "type": "product_domain"
      },
      {
        "label_en": "Knowledge Base Q&A",
        "label_zh": "知识库问答",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "user_job-knowledge-base-q-a",
        "type": "user_job"
      },
      {
        "label_en": "Workflow Automation",
        "label_zh": "流程自动化",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "core_capability-workflow-automation",
        "type": "core_capability"
      },
      {
        "label_en": "Checkpoint Resume",
        "label_zh": "断点恢复流程",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "workflow_pattern-checkpoint-resume",
        "type": "workflow_pattern"
      },
      {
        "label_en": "Evaluation Suite",
        "label_zh": "评测体系",
        "source": "repo_evidence_project_characteristics",
        "tag_id": "selection_signal-evaluation-suite",
        "type": "selection_signal"
      }
    ]
  },
  "packet_id": "phit_eb5664b8920445c19f82f29bffba7a1e",
  "page_model": {
    "artifacts": {
      "artifact_slug": "mcp-ai-agent",
      "files": [
        "PROJECT_PACK.json",
        "QUICK_START.md",
        "PROMPT_PREVIEW.md",
        "HUMAN_MANUAL.md",
        "AI_CONTEXT_PACK.md",
        "BOUNDARY_RISK_CARD.md",
        "PITFALL_LOG.md",
        "REPO_INSPECTION.json",
        "REPO_INSPECTION.md",
        "CAPABILITY_CONTRACT.json",
        "EVIDENCE_INDEX.json",
        "CLAIM_GRAPH.json"
      ],
      "required_files": [
        "PROJECT_PACK.json",
        "QUICK_START.md",
        "PROMPT_PREVIEW.md",
        "HUMAN_MANUAL.md",
        "AI_CONTEXT_PACK.md",
        "BOUNDARY_RISK_CARD.md",
        "PITFALL_LOG.md",
        "REPO_INSPECTION.json"
      ]
    },
    "detail": {
      "capability_source": "Project Hit Packet + DownstreamValidationResult",
      "commands": [
        {
          "command": "npx metmuseum-mcp",
          "label": "Node.js / npx · 官方安装入口",
          "source": "https://github.com/LeelaissakAttota/mcp-ai-agent#readme",
          "verified": true
        }
      ],
      "display_tags": [
        "MCP 工具",
        "知识库问答",
        "流程自动化",
        "断点恢复流程",
        "评测体系"
      ],
      "eyebrow": "工具连接与集成",
      "glance": [
        {
          "body": "判断自己是不是目标用户。",
          "label": "最适合谁",
          "value": "需要工具连接与集成能力，并使用 mcp_host的用户"
        },
        {
          "body": "先理解能力边界，再决定是否继续。",
          "label": "核心价值",
          "value": "Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory"
        },
        {
          "body": "未完成验证前保持审慎。",
          "label": "继续前",
          "value": "publish to Doramagic.ai project surfaces"
        }
      ],
      "guardrail_source": "Boundary & Risk Card",
      "guardrails": [
        {
          "body": "Prompt Preview 只展示流程，不证明项目已安装或运行。",
          "label": "Check 1",
          "value": "不要把试用当真实运行"
        },
        {
          "body": "mcp_host",
          "label": "Check 2",
          "value": "确认宿主兼容"
        },
        {
          "body": "publish to Doramagic.ai project surfaces",
          "label": "Check 3",
          "value": "先隔离验证"
        }
      ],
      "mode": "mcp_config, recipe, host_instruction, eval, preflight",
      "pitfall_log": {
        "items": [
          {
            "body": "仓库名 `mcp-ai-agent` 与安装入口 `metmuseum-mcp` 不完全一致。",
            "category": "身份坑",
            "evidence": [
              "identity.distribution | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | repo=mcp-ai-agent; install=metmuseum-mcp"
            ],
            "severity": "medium",
            "suggested_check": "在 npm/PyPI/GitHub 上确认包名映射和官方 README 说明。",
            "title": "仓库名和安装名不一致",
            "user_impact": "用户照着仓库名搜索包或照着包名找仓库时容易走错入口。"
          },
          {
            "body": "README/documentation is current enough for a first validation pass.",
            "category": "能力坑",
            "evidence": [
              "capability.assumptions | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | README/documentation is current enough for a first validation pass."
            ],
            "severity": "medium",
            "suggested_check": "将假设转成下游验证清单。",
            "title": "能力判断依赖假设",
            "user_impact": "假设不成立时，用户拿不到承诺的能力。"
          },
          {
            "body": "未记录 last_activity_observed。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | last_activity_observed missing"
            ],
            "severity": "medium",
            "suggested_check": "补 GitHub 最近 commit、release、issue/PR 响应信号。",
            "title": "维护活跃度未知",
            "user_impact": "新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。"
          },
          {
            "body": "no_demo",
            "category": "安全/权限坑",
            "evidence": [
              "downstream_validation.risk_items | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium"
            ],
            "severity": "medium",
            "suggested_check": "进入安全/权限治理复核队列。",
            "title": "下游验证发现风险项",
            "user_impact": "下游已经要求复核，不能在页面中弱化。"
          },
          {
            "body": "no_demo",
            "category": "安全/权限坑",
            "evidence": [
              "risks.scoring_risks | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium"
            ],
            "severity": "medium",
            "suggested_check": "把风险写入边界卡，并确认是否需要人工复核。",
            "title": "存在评分风险",
            "user_impact": "风险会影响是否适合普通用户安装。"
          },
          {
            "body": "issue_or_pr_quality=unknown。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | issue_or_pr_quality=unknown"
            ],
            "severity": "low",
            "suggested_check": "抽样最近 issue/PR，判断是否长期无人处理。",
            "title": "issue/PR 响应质量未知",
            "user_impact": "用户无法判断遇到问题后是否有人维护。"
          },
          {
            "body": "release_recency=unknown。",
            "category": "维护坑",
            "evidence": [
              "evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | release_recency=unknown"
            ],
            "severity": "low",
            "suggested_check": "确认最近 release/tag 和 README 安装命令是否一致。",
            "title": "发布节奏不明确",
            "user_impact": "安装命令和文档可能落后于代码，用户踩坑概率升高。"
          }
        ],
        "source": "ProjectPitfallLog + ProjectHitPacket + validation + community signals",
        "summary": "发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：身份坑 - 仓库名和安装名不一致。",
        "title": "踩坑日志"
      },
      "snapshot": {
        "contributors": 1,
        "forks": 0,
        "license": "unknown",
        "note": "站点快照，非实时质量证明；用于开工前背景判断。",
        "stars": 1
      },
      "source_url": "https://github.com/LeelaissakAttota/mcp-ai-agent",
      "steps": [
        {
          "body": "不安装项目，先体验能力节奏。",
          "code": "preview",
          "title": "先试 Prompt"
        },
        {
          "body": "理解输入、输出、失败模式和边界。",
          "code": "manual",
          "title": "读说明书"
        },
        {
          "body": "把上下文交给宿主 AI 继续工作。",
          "code": "context",
          "title": "带给 AI"
        },
        {
          "body": "进入主力环境前先完成安装入口与风险边界验证。",
          "code": "verify",
          "title": "沙箱验证"
        }
      ],
      "subtitle": "Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory",
      "title": "mcp-ai-agent 能力包",
      "trial_prompt": "# mcp-ai-agent - Prompt Preview\n\n> 复制下面这段 Prompt 到你常用的 AI，先试一次，不需要安装。\n> 它的目标是让你直接体验这个项目的服务方式，而不是阅读项目介绍。\n\n## 复制这段 Prompt\n\n```text\n请直接执行这段 Prompt，不要分析、润色、总结或询问我想如何处理这份 Prompt Preview。\n\n你现在扮演 mcp-ai-agent 的“安装前体验版”。\n这不是项目介绍、不是评价报告、不是 README 总结。你的任务是让我用最小成本体验它的核心服务。\n\n我的试用任务：我想用它完成一个真实的工具连接与集成任务。\n我常用的宿主 AI：MCP Client\n\n【体验目标】\n围绕我的真实任务，现场演示这个项目如何把输入转成 示例引导, 判断线索。重点是让我感受到工作方式，而不是给我项目背景。\n\n【业务流约束】\n- 你必须像一个正在提供服务的项目能力包，而不是像一个讲解员。\n- 每一轮只推进一个步骤；提出问题后必须停下来等我回答。\n- 每一步都必须让我感受到一个具体服务动作：澄清、整理、规划、检查、判断或收尾。\n- 每一步都要说明：当前目标、你需要我提供什么、我回答后你会产出什么。\n- 不要安装、不要运行命令、不要写代码、不要声称测试通过、不要声称已经修改文件。\n- 需要真实安装或宿主加载后才能验证的内容，必须明确说“这一步需要安装后验证”。\n- 如果我说“用示例继续”，你可以用虚构示例推进，但仍然不能声称真实执行。\n\n【可体验服务能力】\n- 安装前能力预览: Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory 输入：用户任务, 当前 AI 对话上下文；输出：示例引导, 判断线索。\n\n【必须安装后才可验证的能力】\n- 命令行启动或安装流程: 项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 输入：终端环境, 包管理器, 项目依赖；输出：安装结果, 列表/更新/运行结果。\n\n【核心服务流】\n请严格按这个顺序带我体验。不要一次性输出完整流程：\n1. page-project-introduction：Project Introduction。围绕“Project Introduction”模拟一次用户任务，不展示安装或运行结果。\n2. page-tech-stack：Technology Stack。围绕“Technology Stack”模拟一次用户任务，不展示安装或运行结果。\n3. page-system-architecture：System Architecture。围绕“System Architecture”模拟一次用户任务，不展示安装或运行结果。\n4. page-agent-workflow：Agent Workflow。围绕“Agent Workflow”模拟一次用户任务，不展示安装或运行结果。\n5. page-langgraph-react-agent：LangGraph ReAct Agent。围绕“LangGraph ReAct Agent”模拟一次用户任务，不展示安装或运行结果。\n\n【核心能力体验剧本】\n每一步都必须按“输入 -> 服务动作 -> 中间产物”执行。不要只说流程名：\n1. page-project-introduction\n输入：用户提供的“Project Introduction”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n2. page-tech-stack\n输入：用户提供的“Technology Stack”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n3. page-system-architecture\n输入：用户提供的“System Architecture”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n4. page-agent-workflow\n输入：用户提供的“Agent Workflow”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n5. page-langgraph-react-agent\n输入：用户提供的“LangGraph ReAct Agent”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n【项目服务规则】\n这些规则决定你如何服务用户。不要解释规则本身，而要在每一步执行时遵守：\n- 先确认用户任务、输入材料和成功标准，再模拟项目能力。\n- 每一步都必须形成可检查的小产物，并等待用户确认后再继续。\n- 凡是需要安装、调用工具或访问外部服务的能力，都必须标记为安装后验证。\n\n【每一步的服务约束】\n- Step 1 / page-project-introduction：Step 1 必须围绕“Project Introduction”形成一个小中间产物，并等待用户确认。\n- Step 2 / page-tech-stack：Step 2 必须围绕“Technology Stack”形成一个小中间产物，并等待用户确认。\n- Step 3 / page-system-architecture：Step 3 必须围绕“System Architecture”形成一个小中间产物，并等待用户确认。\n- Step 4 / page-agent-workflow：Step 4 必须围绕“Agent Workflow”形成一个小中间产物，并等待用户确认。\n- Step 5 / page-langgraph-react-agent：Step 5 必须围绕“LangGraph ReAct Agent”形成一个小中间产物，并等待用户确认。\n\n【边界与风险】\n- 不要声称已经安装、运行、调用 API、读写本地文件或完成真实任务。\n- 安装前预览只能展示工作方式，不能证明兼容性、性能或输出质量。\n- 涉及安装、插件加载、工具调用或外部服务的能力必须安装后验证。\n\n【可追溯依据】\n这些路径只用于你内部校验或在我追问“依据是什么”时简要引用。不要在首次回复主动展开：\n- https://github.com/LeelaissakAttota/mcp-ai-agent\n- https://github.com/LeelaissakAttota/mcp-ai-agent#readme\n- README.md\n- main.py\n\n【首次问题规则】\n- 首次三问必须先确认用户目标、成功标准和边界，不要提前进入工具、安装或实现细节。\n- 如果后续需要技术条件、文件路径或运行环境，必须等用户确认目标后再追问。\n\n首次回复必须只输出下面 4 个部分：\n1. 体验开始：用 1 句话说明你将带我体验 mcp-ai-agent 的核心服务。\n2. 当前步骤：明确进入 Step 1，并说明这一步要解决什么。\n3. 你会如何服务我：说明你会先改变我完成任务的哪个动作。\n4. 只问我 3 个问题，然后停下等待回答。\n\n首次回复禁止输出：后续完整流程、证据清单、安装命令、项目评价、营销文案、已经安装或运行的说法。\n\nStep 1 / brainstorming 的二轮协议：\n- 我回答首次三问后，你仍然停留在 Step 1 / brainstorming，不要进入 Step 2。\n- 第二次回复必须产出 6 个部分：澄清后的任务定义、成功标准、边界条件、\n  2-3 个可选方案、每个方案的权衡、推荐方案。\n- 第二次回复最后必须问我是否确认推荐方案；只有我明确确认后，才能进入下一步。\n- 第二次回复禁止输出 git worktree、代码计划、测试文件、命令或真实执行结果。\n\n后续对话规则：\n- 我回答后，你先完成当前步骤的中间产物并等待确认；只有我确认后，才能进入下一步。\n- 每一步都要生成一个小的中间产物，例如澄清后的目标、计划草案、测试意图、验证清单或继续/停止判断。\n- 所有演示都写成“我会建议/我会引导/这一步会形成”，不要写成已经真实执行。\n- 不要声称已经测试通过、文件已修改、命令已运行或结果已产生。\n- 如果某个能力必须安装后验证，请直接说“这一步需要安装后验证”。\n- 如果证据不足，请明确说“证据不足”，不要补事实。\n```\n",
      "voices": [
        {
          "body": "当前没有项目级社区来源；不会把未抓取讨论包装成社会证明。",
          "items": [],
          "status": "待发现 Agent 补证",
          "title": "社区讨论"
        }
      ]
    },
    "homepage_card": {
      "category": "工具连接与集成",
      "desc": "Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory",
      "effort": "安装已验证",
      "forks": 0,
      "icon": "link",
      "name": "mcp-ai-agent 能力包",
      "risk": "需复核",
      "slug": "mcp-ai-agent",
      "stars": 1,
      "tags": [
        "MCP 工具",
        "知识库问答",
        "流程自动化",
        "断点恢复流程",
        "评测体系"
      ],
      "thumb": "gray",
      "type": "MCP 配置"
    },
    "manual": {
      "markdown": "# https://github.com/LeelaissakAttota/mcp-ai-agent 项目说明书\n\n生成时间：2026-05-15 07:01:48 UTC\n\n## 目录\n\n- [Project Introduction](#page-project-introduction)\n- [Technology Stack](#page-tech-stack)\n- [System Architecture](#page-system-architecture)\n- [Agent Workflow](#page-agent-workflow)\n- [LangGraph ReAct Agent](#page-langgraph-react-agent)\n- [Memory Management](#page-memory-management)\n- [MCP Server Integration](#page-mcp-servers)\n- [Transport Mechanisms](#page-transport-mechanisms)\n- [Installation Guide](#page-installation)\n- [Configuration](#page-configuration)\n\n<a id='page-project-introduction'></a>\n\n## Project Introduction\n\n### 相关页面\n\n相关主题：[System Architecture](#page-system-architecture), [Technology Stack](#page-tech-stack)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Project Introduction\n\n## Overview\n\nThe **mcp-ai-agent** is a multi-server AI agent built using the Model Context Protocol (MCP) that serves as a universal interface for connecting to multiple MCP servers simultaneously. The agent leverages GPT-5 Nano for autonomous reasoning and tool selection, enabling users to query diverse domains—including software library documentation and museum collections—through a natural language interface.\n\nThe project demonstrates advanced agentic AI patterns including multi-transport protocol management (STDIO and HTTP), persistent conversation memory, and LangGraph-based ReAct agent architecture.\n\n## Purpose and Scope\n\nThe primary purpose of this project is to showcase a **\"Universal Interface\"** pattern—similar to USB-C for AI systems—capable of:\n\n- Connecting to multiple MCP servers concurrently across different transport protocols\n- Autonomously selecting appropriate tools based on user queries\n- Maintaining persistent conversation memory across interaction sessions\n- Providing a unified natural language interface for multi-domain queries\n\nThe scope encompasses integration with two distinct MCP servers:\n\n| Server | Transport Protocol | Domain |\n|--------|-------------------|--------|\n| Context7 | HTTP (streamable_http) | Software library documentation |\n| MetMuseum-MCP | STDIO (via npx) | Metropolitan Museum artwork collection |\n\n## Architecture\n\n### High-Level System Architecture\n\n```mermaid\ngraph TD\n    User[User CLI Interface] --> Agent[LangGraph ReAct Agent]\n    Agent --> Model[GPT-5 Nano]\n    Model --> ToolSel[Tool Selection]\n    ToolSel --> Context7[Context7 Server]\n    ToolSel --> MetMuseum[MetMuseum-MCP Server]\n    Context7 --> Docs[Library Documentation]\n    MetMuseum --> Artworks[400K+ Artworks]\n    Agent --> Memory[InMemorySaver]\n    Memory --> Thread[Thread-based Memory]\n    \n    subgraph Transport Layer\n        HTTP[HTTP Transport]:::http\n        STDIO[STDIO Transport]:::stdio\n    end\n    \n    classDef http fill:#90EE90\n    classDef stdio fill:#87CEEB\n    \n    Agent -.-> HTTP\n    Agent -.-> STDIO\n```\n\n### Component Architecture\n\n```mermaid\ngraph TD\n    subgraph Main Application\n        Main[main.py] --> Client[MultiServerMCPClient]\n        Client --> Context7Config[Context7 Config]\n        Client --> MetMuseumConfig[MetMuseum Config]\n        Client --> Tools[Available Tools]\n        Main --> Model[ChatOpenAI]\n        Main --> Agent[ReAct Agent]\n        Main --> Checkpointer[InMemorySaver]\n    end\n    \n    subgraph MCP Servers\n        Context7[Context7 Server] --> URL[https://mcp.context7.com/mcp]\n        MetMuseum[MetMuseum-MCP] --> NPX[npx metmuseum-mcp]\n    end\n    \n    Tools --> Agent\n    Model --> Agent\n    Checkpointer --> Agent\n```\n\n## Technology Stack\n\n| Component | Technology | Version |\n|-----------|------------|---------|\n| Language | Python | 3.10+ |\n| MCP Client | langchain-mcp-adapters | Latest |\n| Agent Framework | LangGraph | Latest |\n| Language Model | OpenAI GPT-5 Nano | - |\n| Memory | InMemorySaver | - |\n| Async Runtime | asyncio | Built-in |\n\n## Core Components\n\n### MultiServerMCPClient\n\nThe `MultiServerMCPClient` from `langchain_mcp_adapters` manages connections to multiple MCP servers simultaneously.\n\n**Configuration Structure:**\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n资料来源：[main.py:45-62]()\n\n### LangGraph ReAct Agent\n\nThe agent uses the ReAct (Reasoning + Acting) pattern implemented via `create_react_agent`:\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n**Agent Capabilities:**\n\n- Receives user queries and generates responses\n- Selects appropriate tools based on query context\n- Maintains conversation history across interactions\n- Returns structured responses with tool execution results\n\n### Persistent Memory System\n\nConversation memory is managed using `InMemorySaver` with thread-based configuration:\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n资料来源：[main.py:68-70]()\n\n## Agent Workflow\n\n```mermaid\ngraph LR\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Which Server?}\n    C -->|Library Docs| D[Context7 HTTP]\n    C -->|Museum Data| E[MetMuseum STDIO]\n    D --> F[Tool Execution]\n    E --> F\n    F --> G[Result Returned]\n    G --> H[LLM Response]\n    H --> I[Memory Updated]\n    I --> J[User Response]\n```\n\n**Workflow Steps:**\n\n| Step | Description |\n|------|-------------|\n| 1 | User submits natural language query |\n| 2 | GPT-5 Nano reasons about which MCP server to use |\n| 3 | Agent calls appropriate tool(s) on selected server |\n| 4 | Tool results are returned to the LLM |\n| 5 | LLM generates natural language response |\n| 6 | Response is stored in InMemorySaver with thread_id |\n| 7 | User receives response with conversation context preserved |\n\n## Integrated MCP Servers\n\n### Context7 Server\n\n| Property | Value |\n|----------|-------|\n| Transport | HTTP (streamable_http) |\n| URL | https://mcp.context7.com/mcp |\n| Purpose | LLM-optimized documentation search |\n| Domain | Software frameworks and libraries |\n\n### MetMuseum-MCP Server\n\n| Property | Value |\n|----------|-------|\n| Transport | STDIO |\n| Execution | npx metmuseum-mcp |\n| Purpose | Access museum artwork collection |\n| Domain | Metropolitan Museum of Art |\n| Collection Size | 400,000+ artworks |\n\n## Key Features\n\n### Multi-Server Architecture\n- Simultaneous connection to multiple MCP servers\n- Support for both HTTP and STDIO transport protocols\n- Automatic tool discovery and aggregation\n\n### Autonomous Tool Selection\nThe agent intelligently routes queries to appropriate servers:\n\n```\nUser: \"What is LangChain documentation for agents?\"\n→ Routes to Context7 → Returns docs\n\nUser: \"Show me Van Gogh paintings in the Met Museum\"\n→ Routes to MetMuseum → Returns artwork metadata\n```\n\n### Persistent Conversation Memory\n- Thread-based conversation management\n- Full conversation history preserved across turns\n- Context-aware responses using previous interactions\n\n### Asynchronous Operations\n- Full async/await implementation\n- Non-blocking I/O for MCP server communication\n- Efficient concurrent tool execution\n\n## Installation and Setup\n\n### Prerequisites\n\n| Requirement | Command |\n|-------------|---------|\n| Python | 3.10+ |\n| npm | For npx execution |\n\n### Dependencies\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\n```\n\n### Environment Configuration\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n## Project Structure\n\n```\nmcp-ai-agent/\n│\n├── main.py          # Complete multi-server MCP agent implementation\n└── README.md        # Project documentation\n```\n\n## Usage Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant MCP\n    participant Memory\n    \n    User->>CLI: Start application\n    CLI->>Agent: Initial introduction request\n    Agent->>MCP: Query available tools\n    MCP-->>Agent: Tool definitions\n    Agent-->>CLI: Introduction response\n    CLI-->>User: Display response\n    \n    User->>CLI: Ask question\n    CLI->>Agent: Forward query\n    Agent->>Memory: Check conversation history\n    Memory-->>Agent: Previous context\n    Agent->>MCP: Execute appropriate tool\n    MCP-->>Agent: Tool results\n    Agent-->>Memory: Store interaction\n    Agent-->>CLI: Response\n    CLI-->>User: Display result\n```\n\n## Conclusion\n\nThe mcp-ai-agent project demonstrates a production-ready implementation of multi-server MCP client architecture with autonomous tool selection. It serves as an educational reference for building agentic AI systems that can:\n\n- Connect to diverse MCP servers across different transport protocols\n- Maintain persistent conversation context\n- Leverage LLMs for intelligent tool routing\n- Provide unified natural language interfaces to complex data sources\n\n资料来源：[README.md:1-100]()\n\n---\n\n<a id='page-tech-stack'></a>\n\n## Technology Stack\n\n### 相关页面\n\n相关主题：[Project Introduction](#page-project-introduction), [LangGraph ReAct Agent](#page-langgraph-react-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Technology Stack\n\n## Overview\n\nThe mcp-ai-agent project implements a multi-server MCP (Model Context Protocol) client architecture that connects to multiple external MCP servers simultaneously. The technology stack combines modern Python async programming with LangGraph's ReAct agent framework and OpenAI's language models to create an intelligent agent capable of autonomous tool selection across different domains.\n\n**Project Scope**: The agent serves as a \"Universal Interface\" for AI systems, connecting to MCP servers via different transport protocols while maintaining persistent conversation memory and enabling autonomous tool selection powered by GPT-5 Nano.\n\n资料来源：[README.md:1-20]()\n\n---\n\n## Core Components\n\n### Programming Language\n\n| Attribute | Value |\n|-----------|-------|\n| Language | Python |\n| Version | 3.10+ |\n| Paradigm | Async/Await, Object-Oriented |\n\n资料来源：[README.md:45-46]()\n\n### Agent Framework\n\nThe project utilizes **LangGraph ReAct** as its agent framework. LangGraph provides a declarative API for building stateful, multi-actor applications with LLMs.\n\n```python\nagent = create_react_agent(\n    model=openai_model,         # The language model to use\n    tools=tools,                # Available tools from MCP servers\n    checkpointer=checkpointer   # Memory system for conversation history\n)\n```\n\n资料来源：[main.py:65-70]()\n\n---\n\n## MCP Client Architecture\n\n### MultiServerMCPClient\n\nThe project uses `MultiServerMCPClient` from `langchain-mcp-adapters` to manage connections to multiple MCP servers simultaneously.\n\n```python\nclient = MultiServerMCPClient(\n    {\n        \"context7\": {\n            \"url\": \"https://mcp.context7.com/mcp\",\n            \"transport\": \"streamable_http\",\n        },\n        \"met-museum\": {\n            \"command\": \"npx\",\n            \"args\": [\"-y\", \"metmuseum-mcp\"],\n            \"transport\": \"stdio\",\n        }\n    }\n)\n```\n\n资料来源：[main.py:24-42]()\n\n### Transport Protocols\n\nThe architecture supports dual transport mechanisms:\n\n| Transport | Use Case | Server | Protocol |\n|------------|----------|--------|----------|\n| **streamable_http** | Remote/Cloud servers | Context7 | HTTP |\n| **stdio** | Local Node.js servers | MetMuseum-MCP | stdin/stdout |\n\n资料来源：[README.md:70-85]()\n\n---\n\n## Large Language Model Integration\n\n### OpenAI GPT-5 Nano\n\n| Parameter | Value |\n|-----------|-------|\n| Provider | OpenAI |\n| Model | gpt-5-nano |\n| Integration | langchain-openai |\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",\n)\n```\n\n资料来源：[main.py:47-50]()\n\nThe LLM powers the agent's reasoning capabilities, enabling autonomous tool selection and natural language understanding.\n\n---\n\n## Memory System\n\n### InMemorySaver\n\nThe project implements persistent conversation memory using LangGraph's `InMemorySaver`.\n\n```python\ncheckpointer = InMemorySaver()\n\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n| Feature | Implementation |\n|---------|----------------|\n| Type | In-memory checkpointing |\n| Scope | Thread-based conversation persistence |\n| Library | langgraph.checkpoint.memory |\n| Thread Identifier | Configurable `thread_id` |\n\n资料来源：[main.py:52-55]()\n\n---\n\n## MCP Server Integration\n\n### Context7 Server\n\n| Attribute | Value |\n|-----------|-------|\n| Type | Remote HTTP Server |\n| URL | https://mcp.context7.com/mcp |\n| Transport | streamable_http |\n| Purpose | LLM-optimized documentation search |\n\nContext7 provides access to documentation across major software frameworks and libraries, enabling the agent to answer code-related queries.\n\n资料来源：[README.md:78-80]()\n\n### MetMuseum-MCP Server\n\n| Attribute | Value |\n|-----------|-------|\n| Type | Local STDIO Server |\n| Command | npx |\n| Package | metmuseum-mcp |\n| Transport | stdio |\n| Purpose | Access to 400,000+ artworks |\n\nThe Met Museum MCP server is executed locally via npx and communicates through stdin/stdout, providing access to the Metropolitan Museum of Art collection.\n\n资料来源：[README.md:81-85]()\n\n---\n\n## Architecture Diagram\n\n```mermaid\ngraph TD\n    User[User CLI] --> Agent[LangGraph ReAct Agent]\n    Agent --> LLM[GPT-5 Nano]\n    Agent --> Tools[All MCP Tools]\n    \n    subgraph MCP_Clients\n        HTTP[HTTP Transport] --> Context7[Context7 Server]\n        STDIO[STDIO Transport] --> MetMuseum[MetMuseum-MCP]\n    end\n    \n    Tools --> MCP_Clients\n    LLM --> Decision[Tool Selection]\n    Decision --> MCP_Clients\n    \n    Agent --> Memory[InMemorySaver]\n    Memory --> Thread[conversation_id]\n    \n    subgraph External\n        Context7 --> Docs[Library Documentation]\n        MetMuseum --> Artworks[400K+ Artworks]\n    end\n```\n\n---\n\n## Workflow Diagram\n\n```mermaid\ngraph LR\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Which Server?}\n    C -->|Library/Code| D[Context7 HTTP]\n    C -->|Art/Museum| E[MetMuseum STDIO]\n    D --> F[Tool Execution]\n    E --> F\n    F --> G[Result to LLM]\n    G --> H[Natural Language Response]\n    H --> I[InMemorySaver]\n    I --> J[User Receives Response]\n```\n\n资料来源：[README.md:28-60]()\n\n---\n\n## Async Programming\n\n### Asyncio Integration\n\nThe project leverages Python's `asyncio` for concurrent operations:\n\n```python\nasync def main():\n    # Async operations for MCP client\n    client = MultiServerMCPClient({...})\n    tools = await client.get_tools()\n    \n    # Agent invocation\n    response = await agent.ainvoke(...)\n```\n\n| Component | Async Pattern |\n|-----------|---------------|\n| MCP Client | `await client.get_tools()` |\n| Agent Invocation | `await agent.ainvoke()` |\n| Entry Point | `asyncio.run(main())` |\n\n资料来源：[main.py:19-80]()\n\n---\n\n## Skills Demonstrated\n\nThe technology stack showcases the following competencies:\n\n| Skill | Implementation |\n|-------|----------------|\n| Multi-server MCP client architecture | MultiServerMCPClient |\n| STDIO + HTTP transport management | Dual protocol support |\n| LangGraph ReAct agent with tool calling | create_react_agent |\n| GPT-5 Nano integration | ChatOpenAI |\n| Persistent conversation memory | InMemorySaver |\n| Thread-based conversation management | thread_id config |\n| Async Python patterns | asyncio + await |\n\n资料来源：[README.md:62-75]()\n\n---\n\n## Dependencies\n\n| Package | Purpose |\n|---------|---------|\n| langchain-mcp-adapters | MultiServerMCPClient for MCP server connections |\n| langgraph | ReAct agent framework and InMemorySaver |\n| langchain-openai | OpenAI model integration |\n| npx | Node.js package runner (external) |\n\n资料来源：[README.md:88-91]()\n\n---\n\n## System Architecture Summary\n\n| Layer | Component | Technology |\n|-------|-----------|------------|\n| Interface | CLI | User input/output |\n| Agent | ReAct Agent | LangGraph |\n| Reasoning | LLM | OpenAI GPT-5 Nano |\n| Memory | Checkpointer | InMemorySaver |\n| Integration | MCP Client | langchain-mcp-adapters |\n| External Services | Documentation | Context7 (HTTP) |\n| External Services | Museum Data | MetMuseum (STDIO) |\n\n---\n\n<a id='page-system-architecture'></a>\n\n## System Architecture\n\n### 相关页面\n\n相关主题：[Agent Workflow](#page-agent-workflow), [Transport Mechanisms](#page-transport-mechanisms), [MCP Server Integration](#page-mcp-servers)\n\n<details>\n<summary>Relevant Source Files</summary>\n\nThe following source files were used to generate this page:\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# System Architecture\n\n## Overview\n\nThe mcp-ai-agent is a multi-server Model Context Protocol (MCP) client designed to act as a universal interface for AI agents. It simultaneously connects to multiple MCP servers across different transport protocols, providing persistent conversation memory and autonomous tool selection powered by GPT-5 Nano through a LangGraph ReAct agent implementation. 资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## High-Level Architecture\n\nThe system follows a layered architecture where the CLI interface communicates with a LangGraph ReAct agent that manages connections to multiple external MCP servers. The agent reasoning engine determines which server to query based on the user's domain, while the checkpointer maintains conversation state across interactions. 资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n```mermaid\ngraph TD\n    User[User CLI Interface]\n    Agent[LangGraph ReAct Agent]\n    MCPClient[MultiServerMCPClient]\n    Context7[Context7 Server]\n    MetMuseum[MetMuseum-MCP Server]\n    \n    User -->|\"User Query\"| Agent\n    Agent -->|\"Tool Execution\"| MCPClient\n    MCPClient -->|\"HTTP Transport\"| Context7\n    MCPClient -->|\"STDIO Transport\"| MetMuseum\n    Agent -->|\"Memory\"| InMemorySaver[InMemorySaver]\n    \n    subgraph \"Transport Layer\"\n        Context7\n        MetMuseum\n    end\n```\n\n## Core Components\n\n### MultiServerMCPClient\n\nThe MultiServerMCPClient from the `langchain-mcp-adapters` package handles simultaneous connections to multiple MCP servers using different transport protocols. This component abstracts the complexity of managing HTTP and STDIO connections, providing a unified interface for tool retrieval. 资料来源：[main.py:24](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n| Server | Transport Type | Purpose |\n|--------|---------------|---------|\n| Context7 | `streamable_http` | Remote cloud-based library documentation search |\n| MetMuseum-MCP | `stdio` | Local museum collection access via npx |\n\n### Configuration Parameters\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| `context7.url` | `https://mcp.context7.com/mcp` | Endpoint for Context7 MCP server |\n| `context7.transport` | `streamable_http` | HTTP-based communication protocol |\n| `met-museum.command` | `npx` | Node.js package runner |\n| `met-museum.args` | `[\"-y\", \"metmuseum-mcp\"]` | Auto-install and execute MetMuseum MCP |\n| `met-museum.transport` | `stdio` | Standard input/output protocol |\n\n资料来源：[main.py:28-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### LangGraph ReAct Agent\n\nThe agent is created using LangGraph's `create_react_agent` factory function, combining the OpenAI language model with retrieved MCP tools and a checkpointer for conversation persistence. The ReAct (Reasoning + Acting) pattern enables the agent to reason about which tools to invoke before executing them. 资料来源：[main.py:56-61](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\nagent = create_react_agent(\n    model=openai_model,         # GPT-5 Nano reasoning engine\n    tools=tools,                # Available tools from MCP servers\n    checkpointer=checkpointer   # Memory system for conversation history\n)\n```\n\n### Language Model Integration\n\nThe system uses OpenAI's GPT-5 Nano model through the `langchain_openai` package, configured with minimal parameters for cost-effective reasoning. 资料来源：[main.py:44-46](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",  # Using OpenAI's GPT-5 Nano model\n)\n```\n\n### Conversation Memory System\n\nThe InMemorySaver checkpointer provides thread-based conversation persistence. All messages within a session share the same `thread_id`, enabling the agent to maintain context across multiple user queries. 资料来源：[main.py:48-52](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n## Agent Workflow\n\n```mermaid\ngraph TD\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Which Server Has Info?}\n    C -->|\"Code/Library Docs\"| D[Context7 HTTP]\n    C -->|\"Art/Museum Data\"| E[MetMuseum STDIO]\n    D --> F[Tool Execution]\n    E --> F\n    F --> G[Result to LLM]\n    G --> H[LLM Generates Response]\n    H --> I[Store in InMemorySaver]\n    I --> J[User Receives Response]\n```\n\n### Workflow Steps\n\n1. **User Query**: The CLI receives a natural language question from the user\n2. **LLM Reasoning**: GPT-5 Nano analyzes the query to determine which MCP server contains relevant information\n3. **Tool Selection**: The agent autonomously selects the appropriate server based on domain classification\n4. **Tool Execution**: The selected MCP server is invoked via its transport protocol\n5. **Result Processing**: Tool results are returned to the LLM for natural language synthesis\n6. **Memory Storage**: The complete conversation exchange is persisted via InMemorySaver\n7. **Response Delivery**: The user receives the formatted response with preserved context\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Transport Protocols\n\n### HTTP Transport (Context7)\n\nThe Context7 server uses `streamable_http` transport for remote cloud communication. This transport is optimized for latency-sensitive operations and supports scalable server deployments. 资料来源：[main.py:29-31](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\n\"context7\": {\n    \"url\": \"https://mcp.context7.com/mcp\",\n    \"transport\": \"streamable_http\",\n}\n```\n\n### STDIO Transport (MetMuseum)\n\nThe MetMuseum MCP server uses `stdio` transport for local process communication. The server is launched via `npx` and communicates through standard input/output streams. 资料来源：[main.py:33-36](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\n\"met-museum\": {\n    \"command\": \"npx\",\n    \"args\": [\"-y\", \"metmuseum-mcp\"],\n    \"transport\": \"stdio\",\n}\n```\n\n## Async Architecture\n\nThe entire system is built on Python's `asyncio` framework, enabling concurrent handling of multiple MCP server connections and non-blocking I/O operations. The main entry point uses `asyncio.run()` to execute the async `main()` function. 资料来源：[main.py:1](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\nimport asyncio\n\nasync def main():\n    # Async MCP client initialization\n    client = MultiServerMCPClient({...})\n    \n    # Async tool retrieval\n    tools = await client.get_tools()\n    \n    # Async agent invocation\n    response = await agent.ainvoke({\"messages\": query}, config=config)\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Interaction Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant MCPClient\n    participant Server\n    \n    User->>CLI: Enter question\n    CLI->>Agent: ainvoke(query)\n    Agent->>MCPClient: get_tools()\n    MCPClient->>Server: HTTP/STDIO Request\n    Server->>MCPClient: Tool Response\n    MCPClient->>Agent: Results\n    Agent->>Agent: Generate natural language\n    Agent->>CLI: Formatted response\n    CLI->>User: Display response\n```\n\n## Dependency Stack\n\n| Layer | Technology | Version | Purpose |\n|-------|-----------|---------|---------|\n| Language | Python | 3.10+ | Runtime environment |\n| MCP Client | langchain-mcp-adapters | Latest | Multi-server MCP connections |\n| Agent Framework | langgraph | Latest | ReAct agent orchestration |\n| LLM Integration | langchain-openai | Latest | OpenAI API wrapper |\n| Runtime | npx/Node.js | Latest | Local MCP server execution |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## System Initialization Sequence\n\n```python\n# 1. Create MCP client with server configurations\nclient = MultiServerMCPClient(servers)\n\n# 2. Initialize the language model\nopenai_model = ChatOpenAI(model=\"gpt-5-nano\")\n\n# 3. Retrieve all tools from connected servers\ntools = await client.get_tools()\n\n# 4. Set up conversation memory\ncheckpointer = InMemorySaver()\n\n# 5. Create configuration with thread ID\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n\n# 6. Build the ReAct agent\nagent = create_react_agent(model, tools, checkpointer)\n```\n\n资料来源：[main.py:23-61](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Autonomous Tool Selection\n\nThe agent demonstrates intelligent routing based on query domain classification:\n\n| Query Type | Target Server | Example |\n|------------|---------------|---------|\n| Documentation/Code | Context7 | \"What LangGraph tools are available?\" |\n| Art/Museum | MetMuseum | \"Show me Van Gogh paintings\" |\n\nThis autonomous selection is powered by GPT-5 Nano's reasoning capabilities, eliminating the need for explicit routing logic in the application code. 资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n<a id='page-agent-workflow'></a>\n\n## Agent Workflow\n\n### 相关页面\n\n相关主题：[System Architecture](#page-system-architecture), [LangGraph ReAct Agent](#page-langgraph-react-agent), [Memory Management](#page-memory-management)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# Agent Workflow\n\nThe **Agent Workflow** in this MCP AI agent project defines how a user query flows through the system—from initial reasoning by the language model to autonomous tool selection and execution across multiple MCP servers, ultimately producing a contextual response with persistent conversation memory.\n\n---\n\n## Overview\n\nThe agent functions as a **Universal Interface** built on the Model Context Protocol (MCP), connecting simultaneously to multiple MCP servers across different transport protocols. It combines **GPT-5 Nano reasoning** with **autonomous tool selection** and **persistent conversation memory** to deliver intelligent, domain-aware responses.\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## High-Level Architecture\n\n```mermaid\ngraph TD\n    User[User Query] --> CLI[CLI Interface]\n    CLI --> Agent[LangGraph ReAct Agent]\n    \n    Agent --> LLM[GPT-5 Nano<br/>Reasoning Engine]\n    LLM --> Decision{Which Server?}\n    \n    Decision -->|Library/Code Docs| Context7[Context7 Server<br/>HTTP Transport]\n    Decision -->|Art/Museum Data| MetMuseum[MetMuseum-MCP<br/>STDIO Transport]\n    \n    Context7 --> Tools1[Documentation Tools]\n    MetMuseum --> Tools2[Artwork Tools]\n    \n    Tools1 --> Result1[Result Returned]\n    Tools2 --> Result2[Result Returned]\n    \n    Result1 --> LLM\n    Result2 --> LLM\n    \n    LLM --> Response[Natural Language<br/>Response]\n    Response --> Memory[InMemorySaver<br/>thread_id]\n    Memory --> User\n    \n    style User fill:#e1f5fe\n    style Agent fill:#fff3e0\n    style LLM fill:#f3e5f5\n    style Memory fill:#e8f5e9\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Workflow Stages\n\n### 1. User Query Input\n\nThe workflow begins when a user submits a natural language query through the CLI interface. The agent presents a menu with two options:\n\n| Option | Action |\n|--------|--------|\n| `1` | Ask the agent a question |\n| `2` | Quit |\n\n资料来源：[main.py:44-48](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### 2. GPT-5 Nano Reasoning\n\nThe submitted query is passed to **GPT-5 Nano** via the `ChatOpenAI` model. The LLM performs reasoning to determine:\n\n- The intent of the user's question\n- Which domain the query belongs to\n- Which MCP server has the relevant information\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",\n)\n```\n\n资料来源：[main.py:60-62](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### 3. Autonomous Tool Selection\n\nBased on the reasoning, the agent autonomously selects the appropriate MCP server:\n\n```mermaid\ngraph LR\n    Query1[\"Query about code libraries<br/>e.g., 'LangGraph tools'\"] --> Decision1{Decision}\n    Query2[\"Query about artworks<br/>e.g., 'Van Gogh paintings'\"] --> Decision1\n    \n    Decision1 -->|Code/Docs| C7[Context7 Server<br/>streamable_http]\n    Decision1 -->|Museum Data| MM[MetMuseum-MCP<br/>stdio via npx]\n    \n    C7 --> ToolsC7[Documentation<br/>Search Tools]\n    MM --> ToolsMM[Artwork Metadata<br/>& Images Tools]\n```\n\n| Server | Transport | Use Case |\n|--------|-----------|----------|\n| **Context7** | `streamable_http` | Software framework documentation, library references |\n| **MetMuseum-MCP** | `stdio` | Museum artwork metadata, images, collections |\n\n资料来源：[main.py:38-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### 4. Tool Execution\n\nTools are retrieved from both MCP servers via `MultiServerMCPClient` and attached to the agent:\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n\ntools = await client.get_tools()\n```\n\n资料来源：[main.py:38-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### 5. Result Processing\n\nAfter tool execution, results are returned to the LLM, which generates a natural language response incorporating the retrieved data.\n\n### 6. Response Delivery\n\nThe final response is displayed to the user, and the conversation is stored in memory:\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config\n)\nprint(response['messages'][-1].content)\n```\n\n资料来源：[main.py:68-72](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Core Components\n\n### LangGraph ReAct Agent\n\nThe agent is created using `create_react_agent` from LangGraph, combining reasoning and acting capabilities:\n\n| Component | Purpose |\n|-----------|---------|\n| `model` | GPT-5 Nano for LLM reasoning |\n| `tools` | All tools from MCP servers |\n| `checkpointer` | InMemorySaver for memory |\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n资料来源：[main.py:64-68](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Persistent Conversation Memory\n\nThe `InMemorySaver` provides thread-based conversation persistence:\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n| Feature | Description |\n|---------|-------------|\n| Memory Type | In-memory (volatile) |\n| Persistence Scope | Thread-based via `thread_id` |\n| Use Case | Multi-turn conversations |\n\n资料来源：[main.py:63-65](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Multi-Server MCP Client\n\nThe `MultiServerMCPClient` manages connections to multiple servers simultaneously:\n\n| Server | Transport | Protocol |\n|--------|-----------|----------|\n| Context7 | Remote HTTP | `streamable_http` |\n| MetMuseum-MCP | Local STDIO | `npx` command |\n\n资料来源：[main.py:38-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Interaction Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant Agent\n    participant LLM\n    participant Context7\n    participant MetMuseum\n    participant Memory\n\n    User->>Agent: Submit query\n    Agent->>LLM: Reason about query intent\n    LLM-->>Agent: Select appropriate server\n    \n    alt Code/Documentation Query\n        Agent->>Context7: Call documentation tools\n        Context7-->>Agent: Return documentation\n    else Museum Query\n        Agent->>MetMuseum: Call artwork tools\n        MetMuseum-->>Agent: Return artwork data\n    end\n    \n    Agent->>LLM: Generate response with context\n    LLM-->>Agent: Natural language response\n    Agent->>Memory: Store in thread\n    Agent-->>User: Display response\n    \n    Note over User,Memory: Full conversation history preserved\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## System Prompt Configuration\n\nThe agent's behavior is defined through a system message:\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": [\n        {\"role\": \"system\", \"content\": \"You are a smart, useful agent with tools to access code library documentation and the Met Museum collection.\"},\n        {\"role\": \"user\", \"content\": \"Give a brief introduction of what you do and the tools you can access.\"},\n    ]},\n    config=config\n)\n```\n\n| Message Type | Purpose |\n|--------------|---------|\n| `system` | Defines agent role and capabilities |\n| `user` | Initial introduction request |\n\n资料来源：[main.py:74-81](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Execution Model\n\nThe application uses Python's `asyncio` for asynchronous execution:\n\n```python\nasync def main():\n    # Async operations for MCP client\n    # Agent invocation with tools\n    pass\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n| Pattern | Usage |\n|---------|-------|\n| `async/await` | Non-blocking I/O for MCP servers |\n| `asyncio.run()` | Entry point for async execution |\n\n资料来源：[main.py:30-89](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Example Workflow Scenarios\n\n### Scenario 1: Documentation Query\n\n| Step | Action |\n|------|--------|\n| 1 | User asks: \"What LangGraph tools are available?\" |\n| 2 | LLM reasons → selects Context7 |\n| 3 | Context7 returns LangGraph documentation |\n| 4 | Agent generates response |\n| 5 | Response stored in memory |\n\n### Scenario 2: Museum Collection Query\n\n| Step | Action |\n|------|--------|\n| 1 | User asks: \"Show me Impressionist paintings from the Met\" |\n| 2 | LLM reasons → selects MetMuseum-MCP |\n| 3 | MetMuseum returns artwork metadata |\n| 4 | Agent generates response |\n| 5 | Response stored in memory |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Technology Stack Summary\n\n| Component | Technology | Role |\n|-----------|------------|------|\n| Language | Python 3.10+ | Runtime |\n| MCP Client | langchain-mcp-adapters | Server connectivity |\n| Agent Framework | LangGraph ReAct | Tool-augmented reasoning |\n| LLM | OpenAI GPT-5 Nano | Natural language understanding |\n| Memory | InMemorySaver | Conversation persistence |\n| Transport 1 | streamable_http | Remote server communication |\n| Transport 2 | stdio | Local server communication |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n<a id='page-langgraph-react-agent'></a>\n\n## LangGraph ReAct Agent\n\n### 相关页面\n\n相关主题：[Agent Workflow](#page-agent-workflow), [Memory Management](#page-memory-management), [MCP Server Integration](#page-mcp-servers)\n\n<details>\n<summary>Related Source Files</summary>\n\nThe following source files were used to generate this page:\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# LangGraph ReAct Agent\n\n## Overview\n\nThe LangGraph ReAct Agent is the core reasoning and decision-making engine in the `mcp-ai-agent` project. It combines the **ReAct** (Reasoning + Acting) pattern with LangGraph's stateful graph architecture to create an autonomous agent capable of selecting and executing tools from multiple MCP (Model Context Protocol) servers.\n\n**Key Responsibilities:**\n\n- Reasoning about user queries to determine which tools to invoke\n- Coordinating with multiple MCP servers across different transport protocols\n- Maintaining conversation history through persistent memory\n- Generating natural language responses based on tool execution results\n\n**资料来源：** [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Architecture\n\n### System Overview\n\nThe agent operates within a multi-server MCP client architecture that connects to both remote and local MCP servers:\n\n```mermaid\ngraph TD\n    User[User Query] --> CLI[CLI Interface]\n    CLI --> Agent[LangGraph ReAct Agent]\n    Agent --> MCPClient[MultiServerMCPClient]\n    MCPClient --> HTTP[HTTP Transport]\n    MCPClient --> STDIO[STDIO Transport]\n    HTTP --> Context7[Context7 Server]\n    STDIO --> MetMuseum[MetMuseum MCP Server]\n    Context7 --> Docs[Library Documentation]\n    MetMuseum --> Artworks[Met Museum Collection]\n    Agent <--> Memory[InMemorySaver]\n```\n\n**资料来源：** [README.md:1-80](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Agent Creation Pipeline\n\n```mermaid\ngraph LR\n    A[ChatOpenAI Model] --> B[create_react_agent]\n    C[MCP Tools] --> B\n    D[InMemorySaver] --> B\n    B --> E[ReAct Agent]\n```\n\n**资料来源：** [main.py:46-56](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Core Components\n\n### Component Configuration\n\n| Component | Class | Purpose |\n|-----------|-------|---------|\n| **MCP Client** | `MultiServerMCPClient` | Manages connections to multiple MCP servers |\n| **Agent** | `create_react_agent` | ReAct-style agent with tool-calling capabilities |\n| **Memory** | `InMemorySaver` | Persistent conversation history storage |\n| **LLM** | `ChatOpenAI` | Language model for reasoning and response generation |\n| **Checkpointer** | `InMemorySaver` | Thread-based conversation state persistence |\n\n**资料来源：** [main.py:17-21](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### MCP Server Configuration\n\n| Server | Transport | Type | Capabilities |\n|--------|-----------|------|--------------|\n| **context7** | `streamable_http` | Remote/HTTP | LLM-optimized documentation search |\n| **met-museum** | `stdio` | Local/STDIO | Metropolitan Museum artwork access |\n\n**资料来源：** [main.py:29-43](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Agent Initialization\n\n### Step 1: MCP Client Setup\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\nThe `MultiServerMCPClient` simultaneously manages:\n\n- **HTTP Transport**: Used for remote servers like Context7\n- **STDIO Transport**: Used for local servers like MetMuseum-MCP (via npx)\n\n**资料来源：** [main.py:29-43](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Step 2: Tool Retrieval\n\n```python\ntools = await client.get_tools()\n```\n\nAll tools from both MCP servers are aggregated into a single tool collection that the agent can invoke.\n\n**资料来源：** [main.py:48-49](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Step 3: Memory Checkpointer\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\nThe `InMemorySaver` provides in-memory persistence for conversation threads, enabling the agent to maintain context across multiple interactions.\n\n**资料来源：** [main.py:51-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Step 4: Agent Creation\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\nThe agent is created using LangGraph's `create_react_agent` factory with the OpenAI model, aggregated tools, and memory checkpointer.\n\n**资料来源：** [main.py:56-60](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Workflow\n\n### Query Processing Flow\n\n```mermaid\ngraph TD\n    A[User Query] --> B{Parse Query}\n    B -->|Library/Code docs| C[Call Context7 Tools]\n    B -->|Art/Museum data| D[Call MetMuseum Tools]\n    C --> E[Tool Execution]\n    D --> E\n    E --> F[Result returned to LLM]\n    F --> G[Generate Natural Language Response]\n    G --> H[Store in InMemorySaver]\n    H --> I[Return Response to User]\n```\n\n**资料来源：** [README.md:35-50](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Autonomous Tool Selection\n\nThe agent independently decides which MCP server to query based on the user's query:\n\n| Query Type | Selected Server | Example |\n|------------|-----------------|---------|\n| Documentation | Context7 | \"What is the LangChain documentation for agents?\" |\n| Artwork | MetMuseum | \"Show me Van Gogh paintings in the Met Museum\" |\n\n**资料来源：** [README.md:70-82](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Message Handling\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant Memory\n    participant MCP_Servers\n\n    User->>CLI: Enter query\n    CLI->>Agent: ainvoke with query + config\n    Agent->>Memory: Check conversation history\n    Memory-->>Agent: Previous messages\n    Agent->>MCP_Servers: Select and call appropriate tool\n    MCP_Servers-->>Agent: Tool result\n    Agent->>Memory: Store updated conversation\n    Agent-->>CLI: Response with context\n    CLI-->>User: Display final response\n```\n\n**资料来源：** [main.py:64-90](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Configuration Reference\n\n### Model Configuration\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| `model` | `gpt-5-nano` | OpenAI GPT-5 Nano model for reasoning |\n\n**资料来源：** [main.py:45-46](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Conversation Configuration\n\n| Parameter | Key | Value | Description |\n|-----------|-----|-------|-------------|\n| `configurable` | `thread_id` | `\"conversation_id\"` | Groups all messages in a session |\n\n**资料来源：** [main.py:53-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### System Prompt\n\nThe agent is initialized with a system message defining its role:\n\n```\nYou are a smart, useful agent with tools to access code library documentation and the Met Museum collection.\n```\n\n**资料来源：** [main.py:68-69](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Usage Patterns\n\n### Initial Introduction\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": [\n        {\"role\": \"system\", \"content\": \"You are a smart, useful agent...\"},\n        {\"role\": \"user\", \"content\": \"Give a brief introduction...\"},\n    ]},\n    config=config\n)\nprint(response['messages'][-1].content)\n```\n\n**资料来源：** [main.py:65-75](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Query Invocation\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config\n)\nprint(response['messages'][-1].content)\n```\n\nThe response contains all messages; the final message (`[-1]`) holds the agent's natural language response.\n\n**资料来源：** [main.py:81-88](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Dependencies\n\n| Package | Purpose |\n|---------|---------|\n| `langchain-mcp-adapters` | MultiServerMCPClient for MCP server connections |\n| `langgraph` | create_react_agent, InMemorySaver |\n| `langchain-openai` | ChatOpenAI integration |\n\n**资料来源：** [main.py:17-21](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py), [README.md:87-92](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Key Features\n\n| Feature | Implementation | Benefit |\n|---------|---------------|---------|\n| Multi-transport support | Simultaneous HTTP + STDIO | Connect to diverse MCP servers |\n| Persistent memory | InMemorySaver with thread_id | Maintains conversation context |\n| Autonomous tool selection | GPT-5 Nano reasoning | LLM decides which server to query |\n| ReAct pattern | create_react_agent | Combines reasoning with tool execution |\n| Async architecture | asyncio + await | Non-blocking concurrent operations |\n\n**资料来源：** [README.md:95-107](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n<a id='page-memory-management'></a>\n\n## Memory Management\n\n### 相关页面\n\n相关主题：[LangGraph ReAct Agent](#page-langgraph-react-agent), [Agent Workflow](#page-agent-workflow)\n\n<details>\n<summary>Relevant Source Files</summary>\n\nThe following source files were used to generate this documentation:\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Memory Management\n\n## Overview\n\nThe mcp-ai-agent implements a **persistent conversation memory system** using LangGraph's checkpointing infrastructure. This system enables the AI agent to maintain context across multiple interaction turns within a single conversation session, ensuring coherent and contextually aware responses.\n\nMemory management is critical for multi-turn conversations where the agent needs to reference previous user queries, tool invocations, and generated responses to provide meaningful follow-up interactions.\n\n---\n\n## Architecture\n\n### System Components\n\n| Component | Type | Purpose | Source |\n|-----------|------|---------|--------|\n| `InMemorySaver` | Checkpointer | Stores conversation state in memory | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n| `thread_id` | Configuration Key | Groups messages into conversation threads | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n| `config` | Dictionary | Carries configurable parameters to agent | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n| `checkpointer` | Parameter | Attaches memory to ReAct agent | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n\n### Memory Flow Architecture\n\n```mermaid\ngraph TD\n    A[User Query 1] --> B[Agent Invocation]\n    B --> C[InMemorySaver Checkpointer]\n    C --> D[Memory Storage]\n    D --> E[Response Generated]\n    \n    F[User Query 2] --> G[Agent Invocation with Config]\n    G --> C\n    C --> H[Retrieve Prior Conversation State]\n    H --> I[Full Context Available]\n    I --> J[Context-Aware Response]\n    \n    E --> D\n    J --> D\n```\n\n---\n\n## Core Components\n\n### InMemorySaver\n\nThe `InMemorySaver` class from `langgraph.checkpoint.memory` provides the foundational memory storage mechanism.\n\n```python\nfrom langgraph.checkpoint.memory import InMemorySaver\n\ncheckpointer = InMemorySaver()\n```\n\n**Characteristics:**\n\n| Property | Value |\n|----------|-------|\n| Storage Type | In-memory (volatile) |\n| Persistence | Session-scoped only |\n| Scope | Single Python process |\n| Serialization | Automatic by LangGraph |\n\n资料来源：[main.py:1-3](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Thread Configuration\n\nEach conversation is associated with a unique thread identifier, enabling isolation between different user sessions.\n\n```python\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n**Configuration Parameters:**\n\n| Parameter | Type | Default | Description |\n|-----------|------|---------|-------------|\n| `thread_id` | string | \"conversation_id\" | Unique identifier for the conversation thread |\n\n资料来源：[main.py:58-60](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Agent Integration\n\nThe checkpointer is attached to the ReAct agent during initialization, binding the memory system to the agent's lifecycle.\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n资料来源：[main.py:63-67](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Memory Lifecycle\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant Checkpointer\n    participant LLM\n\n    User->>CLI: Enter query\n    CLI->>Agent: ainvoke with config + query\n    Agent->>Checkpointer: Load thread state\n    Checkpointer-->>Agent: Prior messages\n    Agent->>LLM: Full context + new query\n    LLM-->>Agent: Generated response\n    Agent->>Checkpointer: Save updated state\n    Agent-->>CLI: Response\n    CLI-->>User: Display result\n```\n\n### Initialization Phase\n\nDuring agent initialization, the checkpointer is configured:\n\n1. `InMemorySaver` instance is created\n2. Configuration dictionary is prepared with `thread_id`\n3. Agent is created with checkpointer attached\n\n资料来源：[main.py:52-67](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Query Processing Phase\n\nEach incoming query triggers the following memory operations:\n\n1. Agent receives query with configuration containing `thread_id`\n2. Checkpointer loads all prior messages from the thread\n3. Full conversation history is prepended to current query\n4. LLM generates response with complete context\n5. New messages are appended to thread state\n6. Updated state is persisted via checkpointer\n\n资料来源：[main.py:76-86](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Usage Pattern\n\n### Basic Implementation\n\n```python\n# Import the checkpointer\nfrom langgraph.checkpoint.memory import InMemorySaver\n\n# Create in-memory storage\ncheckpointer = InMemorySaver()\n\n# Define thread configuration\nconfig = {\"configurable\": {\"thread_id\": \"user_session_123\"}}\n\n# Attach to agent\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n\n# Query with memory preservation\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config\n)\n```\n\n### Multi-Turn Conversation Example\n\n```python\n# First turn - agent introduces itself\nresponse = await agent.ainvoke(\n    {\"messages\": [\n        {\"role\": \"system\", \"content\": \"You are a smart agent...\"},\n        {\"role\": \"user\", \"content\": \"Introduce yourself\"}\n    ]},\n    config=config\n)\n\n# Second turn - user asks follow-up question\nresponse = await agent.ainvoke(\n    {\"messages\": \"What tools can you use?\"},\n    config=config\n)\n# Agent remembers the introduction from turn 1\n```\n\n资料来源：[main.py:69-86](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Configuration Options\n\n### Thread Management\n\n| Option | Description | Use Case |\n|--------|-------------|----------|\n| Static `thread_id` | Fixed identifier for entire session | Single continuous conversation |\n| Dynamic `thread_id` | Generated per user/session | Multi-user applications |\n| Per-invocation `config` | Separate config each call | Complex state management |\n\n### Memory Configuration Structure\n\n```python\nconfig = {\n    \"configurable\": {\n        \"thread_id\": str,          # Required: conversation identifier\n        # Additional configurable fields can be added here\n    }\n}\n```\n\n---\n\n## State Storage Model\n\n### Persisted State Components\n\nThe checkpointer automatically stores:\n\n| State Component | Description | Example |\n|-----------------|-------------|---------|\n| Message History | All conversation messages | System, user, assistant, tool messages |\n| Tool Call Results | Responses from MCP tool invocations | Documentation search results, artwork data |\n| Agent Memory | Intermediate agent reasoning state | ReAct thought processes |\n\n### State Access Pattern\n\n```mermaid\ngraph LR\n    A[Query N] --> B[Load State: Messages 1 to N-1]\n    B --> C[LLM Processing]\n    C --> D[Generate Response]\n    D --> E[Save State: Messages 1 to N]\n    E --> F[Return to User]\n```\n\n---\n\n## Limitations\n\n| Limitation | Impact | Mitigation |\n|------------|--------|------------|\n| In-memory only | Data lost on process restart | Not suitable for production requiring persistence |\n| Single-process | Cannot scale across instances | Use database-backed checkpointers for distributed systems |\n| Memory-bound | Large conversations consume RAM | Implement conversation truncation for extended sessions |\n\n---\n\n## Integration with MCP Tools\n\nThe memory system works seamlessly with MCP server tool calls:\n\n```python\n# When user queries about library docs:\n# 1. Memory loads prior conversation\n# 2. Agent decides to call Context7 tools\n# 3. Tool results stored in conversation state\n# 4. Agent generates response referencing full history\n\n# When user queries about museum artworks:\n# 1. Memory loads prior conversation\n# 2. Agent decides to call MetMuseum tools\n# 3. Tool results stored in conversation state\n# 4. Agent generates contextually aware response\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Dependencies\n\n| Package | Version | Purpose |\n|---------|---------|---------|\n| `langgraph` | Latest | Core agent framework with checkpointing |\n| `langgraph.checkpoint.memory` | Included | InMemorySaver implementation |\n\n资料来源：[main.py:3](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Summary\n\nThe Memory Management system in mcp-ai-agent provides:\n\n- **Conversation persistence** via thread-based state storage\n- **Context preservation** across multiple interaction turns\n- **Seamless integration** with LangGraph ReAct agent architecture\n- **Automatic state management** through the checkpointer interface\n\nThis system enables the agent to maintain coherent, context-aware conversations while preserving the full history of tool invocations and responses within each session.\n\n---\n\n<a id='page-mcp-servers'></a>\n\n## MCP Server Integration\n\n### 相关页面\n\n相关主题：[Transport Mechanisms](#page-transport-mechanisms), [System Architecture](#page-system-architecture)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# MCP Server Integration\n\n## Overview\n\nThe MCP Server Integration module serves as the core connectivity layer that enables the AI agent to communicate with multiple external services simultaneously. This integration leverages the **Model Context Protocol (MCP)** to establish connections between the agent and various MCP-compliant servers, providing access to diverse data sources and capabilities through a unified interface.\n\nThe integration supports both **HTTP** and **STDIO** transport protocols, allowing the agent to connect to remote cloud-based servers and local Node.js-based MCP servers concurrently. This dual-transport architecture enables seamless access to documentation services, museum collections, and other specialized data providers without requiring the agent to manage multiple connection protocols manually.\n\n资料来源：[main.py:28-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Architecture\n\n### High-Level System Design\n\nThe MCP Server Integration follows a client-server architecture where the `MultiServerMCPClient` acts as a central hub managing multiple server connections. The client aggregates tools from all configured servers and exposes them to the LangGraph ReAct agent for autonomous tool selection based on user queries.\n\n```mermaid\ngraph TD\n    subgraph Agent[\"LangGraph ReAct Agent\"]\n        LLM[\"GPT-5 Nano<br/>Reasoning Engine\"]\n        Tools[\"Aggregated Tools\"]\n        Mem[\"InMemorySaver<br/>Conversation Memory\"]\n    end\n    \n    subgraph Client[\"MultiServerMCPClient\"]\n        HTTP[\"HTTP Transport<br/>Manager\"]\n        STDIO[\"STDIO Transport<br/>Manager\"]\n    end\n    \n    subgraph Servers[\"MCP Servers\"]\n        C7[\"Context7 Server<br/>(Remote HTTP)\"]\n        MET[\"MetMuseum-MCP<br/>(Local STDIO)\"]\n    end\n    \n    User[\"User Query\"]\n    Response[\"AI Response\"]\n    \n    User --> LLM\n    LLM --> Tools\n    Tools --> HTTP\n    Tools --> STDIO\n    HTTP --> C7\n    STDIO --> MET\n    C7 --> Response\n    MET --> Response\n    LLM --> Mem\n    \n    style Client fill:#e1f5fe\n    style Servers fill:#fff3e0\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Component Responsibilities\n\n| Component | Responsibility | Transport Type |\n|-----------|----------------|----------------|\n| `MultiServerMCPClient` | Manages concurrent server connections and tool aggregation | Both |\n| `create_react_agent` | Creates the ReAct agent with integrated tools | N/A |\n| `InMemorySaver` | Maintains conversation history per thread | N/A |\n| `ChatOpenAI` | Powers reasoning and natural language generation | N/A |\n\n资料来源：[main.py:35-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Server Configuration\n\n### Configuration Structure\n\nThe MCP server integration uses a dictionary-based configuration passed to `MultiServerMCPClient`. Each server entry requires a transport specification and associated connection parameters.\n\n```python\nclient = MultiServerMCPClient({\n    \"server_name\": {\n        \"transport\": \"transport_type\",\n        # Transport-specific parameters\n    }\n})\n```\n\n资料来源：[main.py:29-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Supported Transport Types\n\n| Transport | Use Case | Configuration Parameters |\n|-----------|----------|-------------------------|\n| `streamable_http` | Remote cloud servers | `url` (endpoint URL) |\n| `stdio` | Local Node.js servers | `command`, `args` (executable and arguments) |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Context7 Server Configuration\n\nThe Context7 server provides LLM-optimized documentation search capabilities across major software frameworks and libraries.\n\n```python\n\"context7\": {\n    \"url\": \"https://mcp.context7.com/mcp\",\n    \"transport\": \"streamable_http\",\n}\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `context7` | Unique identifier for the server |\n| URL | `https://mcp.context7.com/mcp` | Remote HTTP endpoint |\n| Transport | `streamable_http` | HTTP-based MCP protocol |\n\n资料来源：[main.py:31-34](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### MetMuseum-MCP Server Configuration\n\nThe MetMuseum server provides access to the Metropolitan Museum of Art collection, including artwork metadata and images.\n\n```python\n\"met-museum\": {\n    \"command\": \"npx\",\n    \"args\": [\"-y\", \"metmuseum-mcp\"],\n    \"transport\": \"stdio\",\n}\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `met-museum` | Unique identifier for the server |\n| Command | `npx` | Node.js package runner |\n| Arguments | `[\"-y\", \"metmuseum-mcp\"]` | Flags and package name |\n| Transport | `stdio` | Standard input/output protocol |\n\n资料来源：[main.py:36-41](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Tool Integration\n\n### Tool Retrieval\n\nTools are retrieved asynchronously from all configured MCP servers using the `get_tools()` method. This aggregation happens at initialization time, making all tools available to the agent without manual registration.\n\n```python\ntools = await client.get_tools()\n```\n\n资料来源：[main.py:47](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Tool Selection Workflow\n\nThe ReAct agent autonomously selects the appropriate tool based on the user's query. The LLM reasoning engine analyzes the query and determines which MCP server's tools are relevant.\n\n```mermaid\ngraph TD\n    A[\"User Query\"] --> B[\"LLM Analyzes Query\"]\n    B --> C{\"Query Domain?\"}\n    C -->|Library/Code Docs| D[\"Select Context7 Tools\"]\n    C -->|Art/Museum Data| E[\"Select MetMuseum Tools\"]\n    D --> F[\"Execute Tool Call\"]\n    E --> F\n    F --> G[\"Return Result to LLM\"]\n    G --> H[\"Generate Natural Language Response\"]\n    H --> I[\"User Response + Context\"]\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Example Tool Selection Scenarios\n\n| User Query | Selected Server | Available Actions |\n|------------|-----------------|-------------------|\n| \"What is the LangChain documentation for agents?\" | Context7 | Documentation search |\n| \"Show me Van Gogh paintings in the Met Museum\" | MetMuseum | Artwork metadata retrieval |\n| \"Explain LangGraph state management\" | Context7 | Framework-specific docs |\n\n---\n\n## Agent Creation and Binding\n\n### ReAct Agent Construction\n\nThe agent is created using LangGraph's `create_react_agent` factory function, which binds the language model, tools, and checkpointer into a single executable agent instance.\n\n```python\nagent = create_react_agent(\n    model=openai_model,         # GPT-5 Nano reasoning engine\n    tools=tools,                # All tools from MCP servers\n    checkpointer=checkpointer   # Conversation memory\n)\n```\n\n资料来源：[main.py:49-53](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Parameter Specifications\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `model` | `ChatOpenAI` | GPT-5 Nano instance for reasoning |\n| `tools` | `List[BaseTool]` | Aggregated tools from all MCP servers |\n| `checkpointer` | `InMemorySaver` | Thread-based conversation persistence |\n\n---\n\n## Conversation Memory Management\n\n### Thread Configuration\n\nEach conversation session uses a unique `thread_id` to maintain context across multiple interactions. The checkpointer stores all messages in memory for the duration of the session.\n\n```python\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n资料来源：[main.py:55-56](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Memory Flow\n\n```mermaid\ngraph LR\n    A[\"User Message\"] --> B[\"Agent Processing\"]\n    B --> C[\"Tool Execution\"]\n    C --> D[\"Result Storage\"]\n    D --> E[\"InMemorySaver\"]\n    E --> F[\"Response to User\"]\n    F --> G[\"Next User Message\"]\n    G --> E\n```\n\n资料来源：[main.py:50-56](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Initialization Sequence\n\n### Async Startup Flow\n\nThe application follows a specific initialization sequence to ensure all components are properly configured before handling user queries.\n\n```mermaid\nsequenceDiagram\n    participant Main as main.py\n    participant Client as MultiServerMCPClient\n    participant LLM as ChatOpenAI\n    participant Agent as ReAct Agent\n    participant User as User\n    \n    Main->>Client: Initialize with server config\n    Main->>LLM: Create GPT-5 Nano instance\n    Main->>Client: await get_tools()\n    Client-->>Main: Return aggregated tools\n    Main->>Agent: Create with model + tools + checkpointer\n    Agent-->>Main: Agent ready\n    Main->>Agent: Send introduction message\n    Agent-->>User: Display capabilities\n    User->>Agent: Submit query\n    Agent-->>User: Return response\n```\n\n资料来源：[main.py:27-72](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Startup Steps\n\n| Step | Action | Code Reference |\n|------|--------|----------------|\n| 1 | Import dependencies | `main.py:13-18` |\n| 2 | Create MCP client | `main.py:29-42` |\n| 3 | Initialize LLM | `main.py:44-46` |\n| 4 | Retrieve tools | `main.py:47` |\n| 5 | Create checkpointer | `main.py:49` |\n| 6 | Configure thread | `main.py:55-56` |\n| 7 | Create agent | `main.py:51-53` |\n\n---\n\n## Dependencies\n\n### Required Python Packages\n\n| Package | Purpose | Import Statement |\n|---------|---------|------------------|\n| `langchain-mcp-adapters` | Multi-server MCP client | `from langchain_mcp_adapters.client import MultiServerMCPClient` |\n| `langgraph` | ReAct agent framework | `from langgraph.prebuilt import create_react_agent` |\n| `langgraph.checkpoint.memory` | Conversation memory | `from langgraph.checkpoint.memory import InMemorySaver` |\n| `langchain-openai` | OpenAI integration | `from langchain_openai import ChatOpenAI` |\n\n资料来源：[main.py:13-17](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### External Requirements\n\n| Requirement | Purpose | Version |\n|-------------|---------|---------|\n| Python | Runtime environment | 3.10+ |\n| Node.js | Required for npx command | Latest stable |\n| npx | Package runner for local MCP servers | Bundled with Node.js |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Error Handling and Edge Cases\n\n### Transport-Specific Considerations\n\n| Transport | Potential Issues | Mitigation |\n|-----------|------------------|------------|\n| `streamable_http` | Network connectivity, server availability | Timeout handling, retry logic |\n| `stdio` | Node.js installation, package availability | npx `-y` flag for auto-installation |\n| Both | Server timeout | Async/await with proper exception handling |\n\n资料来源：[main.py:36-41](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Security Considerations\n\n### API Key Management\n\nThe integration requires an OpenAI API key for the GPT-5 Nano model. The key should be set as an environment variable rather than hardcoded in the source.\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Transport Security\n\n| Transport | Security Model |\n|-----------|----------------|\n| HTTP | Relies on HTTPS/TLS for data-in-transit encryption |\n| STDIO | Local execution with user permissions |\n\n---\n\n## Extensibility\n\n### Adding New MCP Servers\n\nTo extend the integration with additional MCP servers:\n\n1. Add server configuration to the `MultiServerMCPClient` dictionary\n2. Specify the appropriate transport type (`streamable_http` or `stdio`)\n3. Provide required connection parameters\n4. Tools will be automatically aggregated on next `get_tools()` call\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {...},\n    \"met-museum\": {...},\n    \"new_server\": {\n        \"url\": \"https://new-server.endpoint.com/mcp\",\n        \"transport\": \"streamable_http\",\n    }\n})\n```\n\n资料来源：[main.py:29-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n<a id='page-transport-mechanisms'></a>\n\n## Transport Mechanisms\n\n### 相关页面\n\n相关主题：[MCP Server Integration](#page-mcp-servers), [System Architecture](#page-system-architecture)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# Transport Mechanisms\n\n## Overview\n\nTransport mechanisms are the communication protocols that enable the MCP AI Agent to connect with external MCP (Model Context Protocol) servers. This project implements a **multi-transport architecture** that supports simultaneous connections to both remote and local MCP servers, allowing the agent to access diverse tools and data sources through a unified interface.\n\nThe transport layer abstracts the underlying communication details, enabling the agent to interact with different server types using a consistent tool interface while the agent reasoning engine autonomously selects the appropriate transport based on query domain.\n\n资料来源：[main.py:1-70](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Architecture\n\n### Multi-Transport Client Design\n\nThe `MultiServerMCPClient` from `langchain-mcp-adapters` serves as the central transport orchestration component. It manages concurrent connections to multiple MCP servers using different transport protocols while exposing a unified `tools` interface to the agent.\n\n```mermaid\ngraph TD\n    A[LangGraph ReAct Agent] --> B[MultiServerMCPClient]\n    B --> C[HTTP Transport Layer]\n    B --> D[STDIO Transport Layer]\n    C --> E[Context7 Server<br/>Remote/Cloud]\n    D --> F[MetMuseum-MCP<br/>Local/npx]\n    \n    style C fill:#e1f5fe\n    style D fill:#fff3e0\n```\n\n资料来源：[main.py:41-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Supported Transport Types\n\n### STDIO Transport\n\nThe STDIO (Standard Input/Output) transport is designed for local MCP servers that run as child processes on the same machine. Communication occurs through stdin and stdout streams, making it ideal for servers that are invoked via command-line tools.\n\n#### Configuration Parameters\n\n| Parameter | Type | Description | Example |\n|-----------|------|-------------|---------|\n| `command` | string | Executable command to launch the server | `\"npx\"` |\n| `args` | array | Command-line arguments passed to the executable | `[\"-y\", \"metmuseum-mcp\"]` |\n| `transport` | string | Must be set to `\"stdio\"` | `\"stdio\"` |\n\n#### Use Case\n\nThe STDIO transport is used for the **MetMuseum-MCP** server, which is executed locally via `npx`. This approach allows the agent to access over 400,000+ artworks from the Metropolitan Museum of Art collection without requiring a separate server process.\n\n资料来源：[main.py:49-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### HTTP Transport (Streamable HTTP)\n\nThe HTTP transport enables communication with remote MCP servers over HTTP/HTTPS protocols. This transport type supports cloud-based or network-accessible MCP servers that expose REST-like endpoints.\n\n#### Configuration Parameters\n\n| Parameter | Type | Description | Example |\n|-----------|------|-------------|---------|\n| `url` | string | Full URL endpoint of the MCP server | `\"https://mcp.context7.com/mcp\"` |\n| `transport` | string | Must be set to `\"streamable_http\"` | `\"streamable_http\"` |\n\n#### Use Case\n\nThe HTTP transport is used for the **Context7** server, which provides LLM-optimized documentation search across major software frameworks and libraries. This remote server is accessed via the `streamable_http` protocol for efficient streaming responses.\n\n资料来源：[main.py:45-48](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Transport Configuration\n\n### Complete Configuration Structure\n\nThe MCP client is initialized with a dictionary mapping server names to their transport configurations:\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n### Server Comparison\n\n| Attribute | Context7 | MetMuseum-MCP |\n|-----------|----------|---------------|\n| Transport Type | HTTP | STDIO |\n| Location | Remote/Cloud | Local |\n| Invocation | Direct URL | npx command |\n| Data Domain | Library documentation | Artwork/Museum data |\n| Server Process | Hosted service | Spawned child process |\n\n资料来源：[main.py:41-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Tool Aggregation\n\nThe `MultiServerMCPClient.get_tools()` method retrieves all available tools from all configured MCP servers, regardless of their transport type. This aggregation enables the LangGraph ReAct agent to have a unified toolset while each tool maintains its underlying transport implementation.\n\n```python\ntools = await client.get_tools()\n```\n\nThe aggregated tools are then passed to the LangGraph agent:\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n资料来源：[main.py:56-68](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Transport Selection Workflow\n\nThe agent autonomously determines which transport/server to use based on the user's query. The selection occurs during the LLM reasoning phase of the ReAct agent loop.\n\n```mermaid\ngraph TD\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Query Domain Analysis}\n    C -->|Code/Library docs| D[HTTP Transport<br/>Context7]\n    C -->|Art/Museum| E[STDIO Transport<br/>MetMuseum]\n    D --> F[Execute Tool]\n    E --> F\n    F --> G[Return Result to LLM]\n    G --> H[Generate Response]\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Error Handling Considerations\n\nWhen working with multiple transport mechanisms, consider the following potential failure points:\n\n| Transport | Potential Issues | Mitigation |\n|-----------|------------------|------------|\n| STDIO | npx not installed, package not found | Ensure Node.js and npx are available |\n| STDIO | Process spawning failures | Check system permissions and PATH |\n| HTTP | Network connectivity issues | Verify internet access and URL |\n| HTTP | Server availability | Implement retry logic if needed |\n\n资料来源：[main.py:49-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Dependencies\n\nThe transport mechanism implementation requires the following packages:\n\n| Package | Purpose |\n|---------|---------|\n| `langchain-mcp-adapters` | Provides `MultiServerMCPClient` for multi-transport management |\n| `langgraph` | Agent framework with tool calling support |\n| `langchain-openai` | OpenAI model integration |\n\nInstallation command:\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\nnpm install -g npx\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Extending with Additional Transports\n\nTo add support for additional MCP servers with different transport types, extend the `MultiServerMCPClient` configuration dictionary:\n\n```python\nclient = MultiServerMCPClient({\n    # Existing servers...\n    \"new-server\": {\n        # For HTTP-based servers\n        \"url\": \"https://example.com/mcp\",\n        \"transport\": \"streamable_http\",\n        \n        # OR for STDIO-based servers\n        \"command\": \"python\",\n        \"args\": [\"-m\", \"my_mcp_server\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n资料来源：[main.py:41-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n<a id='page-installation'></a>\n\n## Installation Guide\n\n### 相关页面\n\n相关主题：[Configuration](#page-configuration)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Installation Guide\n\n## Overview\n\nThis guide provides complete instructions for setting up the mcp-ai-agent project locally. The mcp-ai-agent is a multi-server Model Context Protocol (MCP) client that connects to external MCP servers (Context7 and MetMuseum) to enable an AI agent with access to library documentation and museum collections.\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Prerequisites\n\nBefore installing the mcp-ai-agent, ensure your development environment meets the following requirements:\n\n| Requirement | Minimum Version | Purpose |\n|-------------|-----------------|---------|\n| Python | 3.10+ | Runtime environment |\n| pip | Latest | Python package management |\n| Node.js | Recent | Required for npx command |\n| npx | Available | Running MetMuseum MCP server |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Project Architecture\n\nThe installation involves configuring multiple components that work together:\n\n```mermaid\ngraph TD\n    A[User Environment] --> B[Python 3.10+]\n    A --> C[Node.js + npx]\n    B --> D[mcp-ai-agent]\n    C --> E[MetMuseum-MCP Server]\n    D --> F[langchain-mcp-adapters]\n    D --> G[LangGraph]\n    D --> H[langchain-openai]\n    F --> I[MultiServerMCPClient]\n    I --> E\n    I --> J[Context7 Server<br/>Remote HTTP]\n```\n\n## Installation Steps\n\n### Step 1: Install Dependencies\n\nInstall the required Python packages using pip:\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\n```\n\nInstall npx globally for the MetMuseum MCP server:\n\n```bash\nnpm install -g npx\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Step 2: Configure Environment Variables\n\nSet your OpenAI API key as an environment variable. This key is required for the agent to communicate with OpenAI's GPT-5 Nano model:\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n**Important:** Replace `your-api-key-here` with your actual OpenAI API key.\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Step 3: Verify Installation Structure\n\nThe project has a minimal structure consisting of two files:\n\n```\nmcp-ai-agent/\n├── main.py          # Complete multi-server MCP agent\n└── README.md\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Step 4: Run the Agent\n\nExecute the main script to start the agent:\n\n```bash\npython main.py\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## MCP Server Configuration\n\nThe agent automatically configures connections to two MCP servers during initialization:\n\n### MultiServerMCPClient Setup\n\nThe configuration in `main.py` establishes connections to both servers:\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n资料来源：[main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Server Configuration Reference\n\n| Server | Transport | Connection Type | Purpose |\n|--------|-----------|-----------------|---------|\n| Context7 | streamable_http | Remote/Cloud | LLM-optimized documentation search |\n| MetMuseum | stdio | Local (npx) | Metropolitan Museum artwork access |\n\n## Required Python Packages\n\n| Package | Version | Role |\n|---------|---------|------|\n| langchain-mcp-adapters | Latest | MCP client for multi-server connections |\n| langgraph | Latest | ReAct agent framework |\n| langchain-openai | Latest | OpenAI GPT model integration |\n\n资料来源：[main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Post-Installation Verification\n\nAfter installation, the agent will:\n\n1. Display an introduction message\n2. Show available tools from connected MCP servers\n3. Present an interactive menu\n\nExpected output:\n\n```\nAgent introduces itself and available tools...\n\nMenu:\n1. Ask the agent a question\n2. Quit\nEnter your choice (1 or 2):\n```\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| Missing OPENAI_API_KEY | Ensure the environment variable is set before running |\n| npx not found | Install Node.js or run `npm install -g npx` |\n| MCP server connection failure | Check internet connection for Context7; verify npx works locally |\n| Import errors | Reinstall Python packages with `pip install --upgrade` |\n\n### Verification Commands\n\nTest your installation by checking each component:\n\n```bash\n# Verify Python packages\npython -c \"import langchain_mcp_adapters; import langgraph; import langchain_openai\"\n\n# Verify npx is available\nnpx --version\n\n# Verify Python version\npython --version\n```\n\n## Project Dependencies Flow\n\n```mermaid\ngraph LR\n    A[main.py] --> B[langchain_mcp_adapters<br/>MultiServerMCPClient]\n    A --> C[langgraph<br/>create_react_agent]\n    A --> D[langchain_openai<br/>ChatOpenAI]\n    A --> E[langgraph.checkpoint.memory<br/>InMemorySaver]\n    B --> F[Context7 MCP]\n    B --> G[MetMuseum MCP]\n```\n\n资料来源：[main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Next Steps\n\nAfter successful installation, refer to the following:\n\n1. **Usage Guide** - How to interact with the agent\n2. **Architecture Overview** - Understanding the multi-server MCP client design\n3. **MCP Server Documentation** - Details on Context7 and MetMuseum capabilities\n\n## System Requirements Summary\n\n| Component | Specification |\n|-----------|---------------|\n| OS | Cross-platform (Windows, macOS, Linux) |\n| Memory | 4GB minimum recommended |\n| Disk Space | 500MB for dependencies |\n| Network | Required for Context7 server and OpenAI API access |\n\n---\n\n<a id='page-configuration'></a>\n\n## Configuration\n\n### 相关页面\n\n相关主题：[Installation Guide](#page-installation)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# Configuration\n\nThis document describes the configuration system for the mcp-ai-agent project, covering all configurable components including MCP servers, language models, memory systems, and agent behavior.\n\n## Overview\n\nThe mcp-ai-agent uses a multi-server Model Context Protocol (MCP) architecture that requires configuration for:\n\n- MCP server connections (transport protocols, endpoints)\n- Language model integration (OpenAI API)\n- Conversation memory persistence\n- Agent execution parameters\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## MCP Server Configuration\n\nThe agent connects to multiple MCP servers simultaneously using the `MultiServerMCPClient` from `langchain-mcp-adapters`. Each server defines its own transport protocol and connection parameters.\n\n资料来源：[main.py:26-40](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Configuration Structure\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n### Supported Transport Protocols\n\n| Transport | Use Case | Configuration Required |\n|-----------|----------|------------------------|\n| `streamable_http` | Remote/cloud servers | `url` endpoint |\n| `stdio` | Local/npx-based servers | `command` and `args` |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Context7 Server Configuration\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `context7` | Identifier for the MCP server |\n| URL | `https://mcp.context7.com/mcp` | Remote endpoint for library documentation |\n| Transport | `streamable_http` | HTTP-based streaming protocol |\n| Capabilities | LLM-optimized docs search across major frameworks | Provides access to code library documentation |\n\n资料来源：[main.py:28-30](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### MetMuseum Server Configuration\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `met-museum` | Identifier for the MCP server |\n| Command | `npx` | Node.js package runner |\n| Args | `[\"-y\", \"metmuseum-mcp\"]` | Auto-install and execute the museum MCP package |\n| Transport | `stdio` | Standard input/output communication |\n| Capabilities | Access to 400,000+ Metropolitan Museum artworks | Provides art collection metadata and images |\n\n资料来源：[main.py:31-35](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Language Model Configuration\n\nThe agent uses OpenAI's GPT-5 Nano model for reasoning and natural language generation.\n\n### OpenAI Model Initialization\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",\n)\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Model | `gpt-5-nano` | OpenAI's lightweight reasoning engine |\n| Integration | `langchain_openai.ChatOpenAI` | LangChain wrapper for OpenAI API |\n\n资料来源：[main.py:42-44](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### API Key Configuration\n\nThe OpenAI API key must be set as an environment variable before running the agent:\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Memory Configuration\n\nThe agent implements persistent conversation memory using LangGraph's `InMemorySaver` checkpointer.\n\n### Checkpointer Setup\n\n```python\ncheckpointer = InMemorySaver()\n```\n\n| Component | Class | Purpose |\n|-----------|-------|---------|\n| Memory | `InMemorySaver` | Stores conversation history in memory |\n| Persistence | Thread-based | Messages grouped by `thread_id` |\n\n资料来源：[main.py:47-48](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Thread Configuration\n\n```python\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Thread ID | `\"conversation_id\"` | Groups all messages in the current session |\n| Scope | Session-level | Maintains context across all agent interactions |\n\n资料来源：[main.py:50-51](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Agent Configuration\n\nThe ReAct (Reasoning + Acting) agent is created using LangGraph's `create_react_agent` factory function.\n\n### Agent Creation\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n| Parameter | Source | Description |\n|-----------|--------|-------------|\n| `model` | `ChatOpenAI` instance | GPT-5 Nano for reasoning |\n| `tools` | `MultiServerMCPClient.get_tools()` | All tools from both MCP servers |\n| `checkpointer` | `InMemorySaver` instance | Conversation memory |\n\n资料来源：[main.py:53-57](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## System Prompt Configuration\n\nThe agent's behavior is defined through a system message passed during the initial invocation.\n\n### Default System Message\n\n```python\n{\"role\": \"system\", \"content\": \"You are a smart, useful agent with tools to access code library documentation and the Met Museum collection.\"}\n```\n\n| Field | Value | Purpose |\n|-------|-------|---------|\n| Role | `system` | Defines agent persona |\n| Content | Agent description | Instructs agent about available capabilities |\n\n资料来源：[main.py:67](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Configuration Flow\n\n```mermaid\ngraph TD\n    A[Configuration Start] --> B[MCP Server Config]\n    B --> C[MultiServerMCPClient]\n    C --> D[Context7 HTTP]\n    C --> E[MetMuseum STDIO]\n    D --> F[Get Tools]\n    E --> F\n    F --> G[LLM Config]\n    G --> H[ChatOpenAI gpt-5-nano]\n    H --> I[Memory Config]\n    I --> J[InMemorySaver]\n    J --> K[Agent Config]\n    K --> L[create_react_agent]\n    L --> M[Ready for Invocation]\n```\n\n## Runtime Configuration\n\n### Asynchronous Execution\n\nThe application runs using Python's `asyncio` event loop:\n\n```python\nasync def main():\n    # All configuration and agent operations\n    pass\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Agent Invocation\n\nEach user interaction passes through the configured thread:\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config  # Contains thread_id for memory persistence\n)\n```\n\n资料来源：[main.py:80-87](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Configuration Dependencies\n\n```mermaid\ngraph LR\n    A[main.py] --> B[langchain_mcp_adapters.client]\n    A --> C[langgraph.prebuilt]\n    A --> D[langgraph.checkpoint.memory]\n    A --> E[langchain_openai]\n    B --> F[MultiServerMCPClient]\n    C --> G[create_react_agent]\n    D --> H[InMemorySaver]\n    E --> I[ChatOpenAI]\n```\n\n## Environment Requirements\n\n| Requirement | Version | Purpose |\n|-------------|---------|---------|\n| Python | 3.10+ | Runtime environment |\n| Node.js/npx | Latest | Required for MetMuseum STDIO server |\n| OpenAI API Key | Valid key | LLM access |\n\n### Required Python Packages\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\n```\n\n### Required npm Packages\n\n```bash\nnpm install -g npx\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Configuration Summary Table\n\n| Component | Class/Function | Key Parameter | Location |\n|-----------|----------------|---------------|----------|\n| MCP Client | `MultiServerMCPClient` | Transport definitions | main.py:26-40 |\n| Context7 | HTTP config | URL endpoint | main.py:28-30 |\n| MetMuseum | STDIO config | npx command | main.py:31-35 |\n| LLM | `ChatOpenAI` | model=\"gpt-5-nano\" | main.py:42-44 |\n| Memory | `InMemorySaver` | In-memory storage | main.py:47-48 |\n| Thread | Dict config | thread_id | main.py:50-51 |\n| Agent | `create_react_agent` | model + tools + checkpointer | main.py:53-57 |\n\n## See Also\n\n- [Installation Guide](README.md#-how-to-run) - Setup instructions\n- [Architecture Overview](README.md#-architecture) - System design\n- [MCP Servers](README.md#-integrated-mcp-servers) - Available tool providers\n\n---\n\n---\n\n## Doramagic 踩坑日志\n\n项目：LeelaissakAttota/mcp-ai-agent\n\n摘要：发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：身份坑 - 仓库名和安装名不一致。\n\n## 1. 身份坑 · 仓库名和安装名不一致\n\n- 严重度：medium\n- 证据强度：runtime_trace\n- 发现：仓库名 `mcp-ai-agent` 与安装入口 `metmuseum-mcp` 不完全一致。\n- 对用户的影响：用户照着仓库名搜索包或照着包名找仓库时容易走错入口。\n- 建议检查：在 npm/PyPI/GitHub 上确认包名映射和官方 README 说明。\n- 复现命令：`npx metmuseum-mcp`\n- 防护动作：页面必须同时展示 repo 名和真实安装入口，避免用户搜索错包。\n- 证据：identity.distribution | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | repo=mcp-ai-agent; install=metmuseum-mcp\n\n## 2. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | README/documentation is current enough for a first validation pass.\n\n## 3. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | last_activity_observed missing\n\n## 4. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n\n## 5. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n\n## 6. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | issue_or_pr_quality=unknown\n\n## 7. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | release_recency=unknown\n\n<!-- canonical_name: LeelaissakAttota/mcp-ai-agent; human_manual_source: deepwiki_human_wiki -->\n",
      "markdown_key": "mcp-ai-agent",
      "pages": "draft",
      "source_refs": [
        {
          "evidence_id": "github_repo:1158386431",
          "kind": "repo",
          "supports_claim_ids": [
            "claim_identity",
            "claim_distribution",
            "claim_capability"
          ],
          "url": "https://github.com/LeelaissakAttota/mcp-ai-agent"
        },
        {
          "evidence_id": "art_6aec6127b3d24e2bb6a472ea87d4ecf4",
          "kind": "docs",
          "supports_claim_ids": [
            "claim_identity",
            "claim_distribution",
            "claim_capability"
          ],
          "url": "https://github.com/LeelaissakAttota/mcp-ai-agent#readme"
        }
      ],
      "summary": "DeepWiki/Human Wiki 完整输出，末尾追加 Discovery Agent 踩坑日志。",
      "title": "mcp-ai-agent 说明书",
      "toc": [
        "https://github.com/LeelaissakAttota/mcp-ai-agent 项目说明书",
        "目录",
        "Project Introduction",
        "Overview",
        "Purpose and Scope",
        "Architecture",
        "Technology Stack",
        "Core Components",
        "Doramagic 踩坑日志"
      ]
    }
  },
  "quality_gate": {
    "blocking_gaps": [],
    "category_confidence": "medium",
    "compile_status": "ready_for_review",
    "five_assets_present": true,
    "install_sandbox_verified": true,
    "missing_evidence": [],
    "next_action": "publish to Doramagic.ai project surfaces",
    "prompt_preview_boundary_ok": true,
    "publish_status": "publishable",
    "quick_start_verified": true,
    "repo_clone_verified": true,
    "repo_commit": "c2ebba1e81ad6bd735ddefc8521f3e9cabf67a82",
    "repo_inspection_error": null,
    "repo_inspection_files": [
      "README.md"
    ],
    "repo_inspection_verified": true,
    "review_reasons": [
      "community_discussion_evidence_below_public_threshold"
    ],
    "tag_count_ok": true,
    "unsupported_claims": []
  },
  "schema_version": "0.1",
  "user_assets": {
    "ai_context_pack": {
      "asset_id": "ai_context_pack",
      "filename": "AI_CONTEXT_PACK.md",
      "markdown": "# mcp-ai-agent - Doramagic AI Context Pack\n\n> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。\n\n## 充分原则\n\n- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。\n- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。\n\n## 给宿主 AI 的使用方式\n\n你正在读取 Doramagic 为 mcp-ai-agent 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。\n\n## Claim 消费规则\n\n- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。\n- **事实最低状态**：`supported`\n- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。\n- `weak`：只能作为低置信度线索，必须要求用户继续核实。\n- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。\n- `unverified`：不得作为事实使用，应明确说证据不足。\n- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。\n\n## 它最适合谁\n\n- **想在安装前理解开源项目价值和边界的用户**：当前证据主要来自项目文档。 证据：`README.md` Claim：`clm_0002` supported 0.86\n\n## 它能做什么\n\n- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md` Claim：`clm_0001` supported 0.86\n\n## 怎么开始\n\n- `pip install langchain-mcp-adapters langgraph langchain-openai` 证据：`README.md` Claim：`clm_0003` supported 0.86\n- `npm install -g npx   # For MetMuseum STDIO server` 证据：`README.md` Claim：`clm_0004` supported 0.86\n\n## 继续前判断卡\n\n- **当前建议**：需要管理员/安全审批\n- **为什么**：继续前可能涉及密钥、账号、外部服务或敏感上下文，建议先经过管理员或安全审批。\n\n### 30 秒判断\n\n- **现在怎么做**：需要管理员/安全审批\n- **最小安全下一步**：先跑 Prompt Preview；若涉及凭证或企业环境，先审批再试装\n- **先别相信**：工具权限边界不能在安装前相信。\n- **继续会触碰**：命令执行、本地环境或项目文件、环境变量 / API Key\n\n### 现在可以相信\n\n- **适合人群线索：想在安装前理解开源项目价值和边界的用户**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0002` supported 0.86\n- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86\n- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`README.md` Claim：`clm_0003` supported 0.86\n\n### 现在还不能相信\n\n- **工具权限边界不能在安装前相信。**（unverified）：MCP/tool 类项目通常会触碰文件、网络、浏览器或外部 API，必须真实检查权限和日志。\n- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。\n- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。\n- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。\n- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。\n- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。\n- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。\n- **安装命令是否需要网络、权限或全局写入？**（unverified）：这影响企业环境和个人环境的安装风险。 证据：`README.md`\n\n### 继续会触碰什么\n\n- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`\n- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`README.md`\n- **环境变量 / API Key**：项目入口文档明确出现 API key、token、secret 或账号凭证配置。 原因：如果真实安装需要凭证，应先使用测试凭证并经过权限/合规判断。 证据：`README.md`\n- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。\n\n### 最小安全下一步\n\n- **先跑 Prompt Preview**：用安装前交互式试用判断工作方式是否匹配，不需要授权或改环境。（适用：任何项目都适用，尤其是输出质量未知时。）\n- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）\n- **不要使用真实生产凭证**：环境变量/API key 一旦进入宿主或工具链，可能产生账号和合规风险。（适用：出现 API、TOKEN、KEY、SECRET 等环境线索时。）\n- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）\n\n### 退出方式\n\n- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。\n- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。\n- **准备撤销测试 API key 或 token**：测试凭证泄露或误用时，可以快速止损。\n- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。\n\n## 哪些只能预览\n\n- 解释项目适合谁和能做什么\n- 基于项目文档演示典型对话流程\n- 帮助用户判断是否值得安装或继续研究\n\n## 哪些必须安装后验证\n\n- 真实安装 Skill、插件或 CLI\n- 执行脚本、修改本地文件或访问外部服务\n- 验证真实输出质量、性能和兼容性\n\n## 边界与风险判断卡\n\n- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0005` inferred 0.45\n- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md` Claim：`clm_0006` supported 0.86\n- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。\n- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。\n- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。\n\n## 开工前工作上下文\n\n### 加载顺序\n\n- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。\n- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。\n- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。\n- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。\n- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。\n\n### 任务路由\n\n- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86\n\n### 上下文规模\n\n- 文件总数：3\n- 重要文件覆盖：3/3\n- 证据索引条目：3\n- 角色 / Skill 条目：1\n\n### 证据不足时的处理\n\n- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。\n- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。\n- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。\n- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。\n\n## Prompt Recipes\n\n### 适配判断\n\n- 目标：判断这个项目是否适合用户当前任务。\n- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。\n\n```text\n请基于 mcp-ai-agent 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。\n```\n\n### 安装前体验\n\n- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。\n- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。\n\n```text\n请把 mcp-ai-agent 当作安装前体验资产，而不是已安装工具或真实运行环境。\n\n请严格输出四段：\n1. 先问我 3 个必要问题。\n2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。\n3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。\n4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。\n\n硬性边界：\n- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。\n- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。\n- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。\n- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。\n- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。\n- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。\n\n```\n\n### 角色 / Skill 选择\n\n- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。\n- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。\n\n```text\n请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。\n```\n\n### 风险预检\n\n- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。\n- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。\n\n```text\n请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。\n```\n\n### 宿主 AI 开工指令\n\n- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。\n- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。\n\n```text\n请基于 mcp-ai-agent 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。\n```\n\n\n## 角色 / Skill 索引\n\n- 共索引 1 个角色 / Skill / 项目文档条目。\n\n- **🤖 Multi-Server AI Agent with Model Context Protocol MCP**（project_doc）：🤖 Multi-Server AI Agent with Model Context Protocol MCP 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`\n\n## 证据索引\n\n- 共索引 3 条证据。\n\n- **🤖 Multi-Server AI Agent with Model Context Protocol MCP**（documentation）：🤖 Multi-Server AI Agent with Model Context Protocol MCP 证据：`README.md`\n- **Settings**（structured_config）：{ \"php.suggest.basic\": false, \"java.errors.incompleteClasspath.severity\": \"ignore\", \"security.workspace.trust.enabled\": true, \"security.workspace.trust.startupPrompt\": \"never\", \"security.workspace.trust.untrustedFiles\": \"open\", \"liveServer.settings.donotShowInfoMsg\": false, } 证据：`.theia/settings.json`\n- **Standard library imports**（source_file）：Standard library imports import asyncio Third-party imports for MCP Model Context Protocol and LangGraph from langchain mcp adapters.client import MultiServerMCPClient Connects to MCP servers from langgraph.prebuilt import create react agent Creates ReAct-style agents from langgraph.checkpoint.memory import InMemorySaver Provides conversation memory from langchain openai import ChatOpenAI OpenAI chat model integration 证据：`main.py`\n\n## 宿主 AI 必须遵守的规则\n\n- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`README.md`, `.theia/settings.json`, `main.py`\n- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`README.md`, `.theia/settings.json`, `main.py`\n\n## 用户开工前应该回答的问题\n\n- 你准备在哪个宿主 AI 或本地环境中使用它？\n- 你只是想先体验工作流，还是准备真实安装？\n- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？\n\n## 验收标准\n\n- 所有能力声明都能回指到 evidence_refs 中的文件路径。\n- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。\n- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。\n\n---\n\n## Doramagic Context Augmentation\n\n下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。\n\n## Human Manual 骨架\n\n使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。\n\n宿主 AI 硬性规则：\n- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。\n- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。\n- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。\n\n- **Project Introduction**：importance `high`\n  - source_paths: README.md, main.py\n- **Technology Stack**：importance `high`\n  - source_paths: README.md, main.py\n- **System Architecture**：importance `high`\n  - source_paths: README.md, main.py\n- **Agent Workflow**：importance `high`\n  - source_paths: main.py, README.md\n- **LangGraph ReAct Agent**：importance `high`\n  - source_paths: main.py\n- **Memory Management**：importance `high`\n  - source_paths: main.py\n- **MCP Server Integration**：importance `high`\n  - source_paths: main.py, README.md\n- **Transport Mechanisms**：importance `medium`\n  - source_paths: main.py\n\n## Repo Inspection Evidence / 源码检查证据\n\n- repo_clone_verified: true\n- repo_inspection_verified: true\n- repo_commit: `c2ebba1e81ad6bd735ddefc8521f3e9cabf67a82`\n- inspected_files: `README.md`\n\n宿主 AI 硬性规则：\n- 没有 repo_clone_verified=true 时，不得声称已经读过源码。\n- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。\n- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。\n\n## Doramagic Pitfall Constraints / 踩坑约束\n\n这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。\n\n### Constraint 1: 仓库名和安装名不一致\n\n- Trigger: 仓库名 `mcp-ai-agent` 与安装入口 `metmuseum-mcp` 不完全一致。\n- Host AI rule: 在 npm/PyPI/GitHub 上确认包名映射和官方 README 说明。\n- Why it matters: 用户照着仓库名搜索包或照着包名找仓库时容易走错入口。\n- Evidence: identity.distribution | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | repo=mcp-ai-agent; install=metmuseum-mcp\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 2: 能力判断依赖假设\n\n- Trigger: README/documentation is current enough for a first validation pass.\n- Host AI rule: 将假设转成下游验证清单。\n- Why it matters: 假设不成立时，用户拿不到承诺的能力。\n- Evidence: capability.assumptions | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | README/documentation is current enough for a first validation pass.\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 3: 维护活跃度未知\n\n- Trigger: 未记录 last_activity_observed。\n- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。\n- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- Evidence: evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | last_activity_observed missing\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 4: 下游验证发现风险项\n\n- Trigger: no_demo\n- Host AI rule: 进入安全/权限治理复核队列。\n- Why it matters: 下游已经要求复核，不能在页面中弱化。\n- Evidence: downstream_validation.risk_items | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 5: 存在评分风险\n\n- Trigger: no_demo\n- Host AI rule: 把风险写入边界卡，并确认是否需要人工复核。\n- Why it matters: 风险会影响是否适合普通用户安装。\n- Evidence: risks.scoring_risks | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 6: issue/PR 响应质量未知\n\n- Trigger: issue_or_pr_quality=unknown。\n- Host AI rule: 抽样最近 issue/PR，判断是否长期无人处理。\n- Why it matters: 用户无法判断遇到问题后是否有人维护。\n- Evidence: evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | issue_or_pr_quality=unknown\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n\n### Constraint 7: 发布节奏不明确\n\n- Trigger: release_recency=unknown。\n- Host AI rule: 确认最近 release/tag 和 README 安装命令是否一致。\n- Why it matters: 安装命令和文档可能落后于代码，用户踩坑概率升高。\n- Evidence: evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | release_recency=unknown\n- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。\n",
      "summary": "给宿主 AI 的上下文和工作边界。",
      "title": "AI Context Pack / 带给我的 AI"
    },
    "boundary_risk_card": {
      "asset_id": "boundary_risk_card",
      "filename": "BOUNDARY_RISK_CARD.md",
      "markdown": "# Boundary & Risk Card / 安装前决策卡\n\n项目：LeelaissakAttota/mcp-ai-agent\n\n## Doramagic 试用结论\n\n当前结论：可以进入发布前推荐检查；首次使用仍应从最小权限、临时目录和可回滚配置开始。\n\n## 用户现在可以做\n\n- 可以先阅读 Human Manual，理解项目目的和主要工作流。\n- 可以复制 Prompt Preview 做安装前体验；这只验证交互感，不代表真实运行。\n- 可以把官方 Quick Start 命令放到隔离环境中验证，不要直接进主力环境。\n\n## 现在不要做\n\n- 不要把 Prompt Preview 当成项目实际运行结果。\n- 不要把 metadata-only validation 当成沙箱安装验证。\n- 不要把未验证能力写成“已支持、已跑通、可放心安装”。\n- 不要在首次试用时交出生产数据、私人文件、真实密钥或主力配置目录。\n\n## 安装前检查\n\n- 宿主 AI 是否匹配：mcp_host\n- 官方安装入口状态：已发现官方入口\n- 是否在临时目录、临时宿主或容器中验证：必须是\n- 是否能回滚配置改动：必须能\n- 是否需要 API Key、网络访问、读写文件或修改宿主配置：未确认前按高风险处理\n- 是否记录了安装命令、实际输出和失败日志：必须记录\n\n## 当前阻塞项\n\n- review_required: community_discussion_evidence_below_public_threshold\n\n## 项目专属踩坑\n\n- 仓库名和安装名不一致（medium）：用户照着仓库名搜索包或照着包名找仓库时容易走错入口。 建议检查：在 npm/PyPI/GitHub 上确认包名映射和官方 README 说明。\n- 能力判断依赖假设（medium）：假设不成立时，用户拿不到承诺的能力。 建议检查：将假设转成下游验证清单。\n- 维护活跃度未知（medium）：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 下游验证发现风险项（medium）：下游已经要求复核，不能在页面中弱化。 建议检查：进入安全/权限治理复核队列。\n- 存在评分风险（medium）：风险会影响是否适合普通用户安装。 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n\n## 风险与权限提示\n\n- no_demo: medium\n\n## 证据缺口\n\n- 暂未发现结构化证据缺口。\n",
      "summary": "安装、权限、验证和推荐前风险。",
      "title": "Boundary & Risk Card / 边界与风险卡"
    },
    "human_manual": {
      "asset_id": "human_manual",
      "filename": "HUMAN_MANUAL.md",
      "markdown": "# https://github.com/LeelaissakAttota/mcp-ai-agent 项目说明书\n\n生成时间：2026-05-15 07:01:48 UTC\n\n## 目录\n\n- [Project Introduction](#page-project-introduction)\n- [Technology Stack](#page-tech-stack)\n- [System Architecture](#page-system-architecture)\n- [Agent Workflow](#page-agent-workflow)\n- [LangGraph ReAct Agent](#page-langgraph-react-agent)\n- [Memory Management](#page-memory-management)\n- [MCP Server Integration](#page-mcp-servers)\n- [Transport Mechanisms](#page-transport-mechanisms)\n- [Installation Guide](#page-installation)\n- [Configuration](#page-configuration)\n\n<a id='page-project-introduction'></a>\n\n## Project Introduction\n\n### 相关页面\n\n相关主题：[System Architecture](#page-system-architecture), [Technology Stack](#page-tech-stack)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Project Introduction\n\n## Overview\n\nThe **mcp-ai-agent** is a multi-server AI agent built using the Model Context Protocol (MCP) that serves as a universal interface for connecting to multiple MCP servers simultaneously. The agent leverages GPT-5 Nano for autonomous reasoning and tool selection, enabling users to query diverse domains—including software library documentation and museum collections—through a natural language interface.\n\nThe project demonstrates advanced agentic AI patterns including multi-transport protocol management (STDIO and HTTP), persistent conversation memory, and LangGraph-based ReAct agent architecture.\n\n## Purpose and Scope\n\nThe primary purpose of this project is to showcase a **\"Universal Interface\"** pattern—similar to USB-C for AI systems—capable of:\n\n- Connecting to multiple MCP servers concurrently across different transport protocols\n- Autonomously selecting appropriate tools based on user queries\n- Maintaining persistent conversation memory across interaction sessions\n- Providing a unified natural language interface for multi-domain queries\n\nThe scope encompasses integration with two distinct MCP servers:\n\n| Server | Transport Protocol | Domain |\n|--------|-------------------|--------|\n| Context7 | HTTP (streamable_http) | Software library documentation |\n| MetMuseum-MCP | STDIO (via npx) | Metropolitan Museum artwork collection |\n\n## Architecture\n\n### High-Level System Architecture\n\n```mermaid\ngraph TD\n    User[User CLI Interface] --> Agent[LangGraph ReAct Agent]\n    Agent --> Model[GPT-5 Nano]\n    Model --> ToolSel[Tool Selection]\n    ToolSel --> Context7[Context7 Server]\n    ToolSel --> MetMuseum[MetMuseum-MCP Server]\n    Context7 --> Docs[Library Documentation]\n    MetMuseum --> Artworks[400K+ Artworks]\n    Agent --> Memory[InMemorySaver]\n    Memory --> Thread[Thread-based Memory]\n    \n    subgraph Transport Layer\n        HTTP[HTTP Transport]:::http\n        STDIO[STDIO Transport]:::stdio\n    end\n    \n    classDef http fill:#90EE90\n    classDef stdio fill:#87CEEB\n    \n    Agent -.-> HTTP\n    Agent -.-> STDIO\n```\n\n### Component Architecture\n\n```mermaid\ngraph TD\n    subgraph Main Application\n        Main[main.py] --> Client[MultiServerMCPClient]\n        Client --> Context7Config[Context7 Config]\n        Client --> MetMuseumConfig[MetMuseum Config]\n        Client --> Tools[Available Tools]\n        Main --> Model[ChatOpenAI]\n        Main --> Agent[ReAct Agent]\n        Main --> Checkpointer[InMemorySaver]\n    end\n    \n    subgraph MCP Servers\n        Context7[Context7 Server] --> URL[https://mcp.context7.com/mcp]\n        MetMuseum[MetMuseum-MCP] --> NPX[npx metmuseum-mcp]\n    end\n    \n    Tools --> Agent\n    Model --> Agent\n    Checkpointer --> Agent\n```\n\n## Technology Stack\n\n| Component | Technology | Version |\n|-----------|------------|---------|\n| Language | Python | 3.10+ |\n| MCP Client | langchain-mcp-adapters | Latest |\n| Agent Framework | LangGraph | Latest |\n| Language Model | OpenAI GPT-5 Nano | - |\n| Memory | InMemorySaver | - |\n| Async Runtime | asyncio | Built-in |\n\n## Core Components\n\n### MultiServerMCPClient\n\nThe `MultiServerMCPClient` from `langchain_mcp_adapters` manages connections to multiple MCP servers simultaneously.\n\n**Configuration Structure:**\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n资料来源：[main.py:45-62]()\n\n### LangGraph ReAct Agent\n\nThe agent uses the ReAct (Reasoning + Acting) pattern implemented via `create_react_agent`:\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n**Agent Capabilities:**\n\n- Receives user queries and generates responses\n- Selects appropriate tools based on query context\n- Maintains conversation history across interactions\n- Returns structured responses with tool execution results\n\n### Persistent Memory System\n\nConversation memory is managed using `InMemorySaver` with thread-based configuration:\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n资料来源：[main.py:68-70]()\n\n## Agent Workflow\n\n```mermaid\ngraph LR\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Which Server?}\n    C -->|Library Docs| D[Context7 HTTP]\n    C -->|Museum Data| E[MetMuseum STDIO]\n    D --> F[Tool Execution]\n    E --> F\n    F --> G[Result Returned]\n    G --> H[LLM Response]\n    H --> I[Memory Updated]\n    I --> J[User Response]\n```\n\n**Workflow Steps:**\n\n| Step | Description |\n|------|-------------|\n| 1 | User submits natural language query |\n| 2 | GPT-5 Nano reasons about which MCP server to use |\n| 3 | Agent calls appropriate tool(s) on selected server |\n| 4 | Tool results are returned to the LLM |\n| 5 | LLM generates natural language response |\n| 6 | Response is stored in InMemorySaver with thread_id |\n| 7 | User receives response with conversation context preserved |\n\n## Integrated MCP Servers\n\n### Context7 Server\n\n| Property | Value |\n|----------|-------|\n| Transport | HTTP (streamable_http) |\n| URL | https://mcp.context7.com/mcp |\n| Purpose | LLM-optimized documentation search |\n| Domain | Software frameworks and libraries |\n\n### MetMuseum-MCP Server\n\n| Property | Value |\n|----------|-------|\n| Transport | STDIO |\n| Execution | npx metmuseum-mcp |\n| Purpose | Access museum artwork collection |\n| Domain | Metropolitan Museum of Art |\n| Collection Size | 400,000+ artworks |\n\n## Key Features\n\n### Multi-Server Architecture\n- Simultaneous connection to multiple MCP servers\n- Support for both HTTP and STDIO transport protocols\n- Automatic tool discovery and aggregation\n\n### Autonomous Tool Selection\nThe agent intelligently routes queries to appropriate servers:\n\n```\nUser: \"What is LangChain documentation for agents?\"\n→ Routes to Context7 → Returns docs\n\nUser: \"Show me Van Gogh paintings in the Met Museum\"\n→ Routes to MetMuseum → Returns artwork metadata\n```\n\n### Persistent Conversation Memory\n- Thread-based conversation management\n- Full conversation history preserved across turns\n- Context-aware responses using previous interactions\n\n### Asynchronous Operations\n- Full async/await implementation\n- Non-blocking I/O for MCP server communication\n- Efficient concurrent tool execution\n\n## Installation and Setup\n\n### Prerequisites\n\n| Requirement | Command |\n|-------------|---------|\n| Python | 3.10+ |\n| npm | For npx execution |\n\n### Dependencies\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\n```\n\n### Environment Configuration\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n## Project Structure\n\n```\nmcp-ai-agent/\n│\n├── main.py          # Complete multi-server MCP agent implementation\n└── README.md        # Project documentation\n```\n\n## Usage Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant MCP\n    participant Memory\n    \n    User->>CLI: Start application\n    CLI->>Agent: Initial introduction request\n    Agent->>MCP: Query available tools\n    MCP-->>Agent: Tool definitions\n    Agent-->>CLI: Introduction response\n    CLI-->>User: Display response\n    \n    User->>CLI: Ask question\n    CLI->>Agent: Forward query\n    Agent->>Memory: Check conversation history\n    Memory-->>Agent: Previous context\n    Agent->>MCP: Execute appropriate tool\n    MCP-->>Agent: Tool results\n    Agent-->>Memory: Store interaction\n    Agent-->>CLI: Response\n    CLI-->>User: Display result\n```\n\n## Conclusion\n\nThe mcp-ai-agent project demonstrates a production-ready implementation of multi-server MCP client architecture with autonomous tool selection. It serves as an educational reference for building agentic AI systems that can:\n\n- Connect to diverse MCP servers across different transport protocols\n- Maintain persistent conversation context\n- Leverage LLMs for intelligent tool routing\n- Provide unified natural language interfaces to complex data sources\n\n资料来源：[README.md:1-100]()\n\n---\n\n<a id='page-tech-stack'></a>\n\n## Technology Stack\n\n### 相关页面\n\n相关主题：[Project Introduction](#page-project-introduction), [LangGraph ReAct Agent](#page-langgraph-react-agent)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Technology Stack\n\n## Overview\n\nThe mcp-ai-agent project implements a multi-server MCP (Model Context Protocol) client architecture that connects to multiple external MCP servers simultaneously. The technology stack combines modern Python async programming with LangGraph's ReAct agent framework and OpenAI's language models to create an intelligent agent capable of autonomous tool selection across different domains.\n\n**Project Scope**: The agent serves as a \"Universal Interface\" for AI systems, connecting to MCP servers via different transport protocols while maintaining persistent conversation memory and enabling autonomous tool selection powered by GPT-5 Nano.\n\n资料来源：[README.md:1-20]()\n\n---\n\n## Core Components\n\n### Programming Language\n\n| Attribute | Value |\n|-----------|-------|\n| Language | Python |\n| Version | 3.10+ |\n| Paradigm | Async/Await, Object-Oriented |\n\n资料来源：[README.md:45-46]()\n\n### Agent Framework\n\nThe project utilizes **LangGraph ReAct** as its agent framework. LangGraph provides a declarative API for building stateful, multi-actor applications with LLMs.\n\n```python\nagent = create_react_agent(\n    model=openai_model,         # The language model to use\n    tools=tools,                # Available tools from MCP servers\n    checkpointer=checkpointer   # Memory system for conversation history\n)\n```\n\n资料来源：[main.py:65-70]()\n\n---\n\n## MCP Client Architecture\n\n### MultiServerMCPClient\n\nThe project uses `MultiServerMCPClient` from `langchain-mcp-adapters` to manage connections to multiple MCP servers simultaneously.\n\n```python\nclient = MultiServerMCPClient(\n    {\n        \"context7\": {\n            \"url\": \"https://mcp.context7.com/mcp\",\n            \"transport\": \"streamable_http\",\n        },\n        \"met-museum\": {\n            \"command\": \"npx\",\n            \"args\": [\"-y\", \"metmuseum-mcp\"],\n            \"transport\": \"stdio\",\n        }\n    }\n)\n```\n\n资料来源：[main.py:24-42]()\n\n### Transport Protocols\n\nThe architecture supports dual transport mechanisms:\n\n| Transport | Use Case | Server | Protocol |\n|------------|----------|--------|----------|\n| **streamable_http** | Remote/Cloud servers | Context7 | HTTP |\n| **stdio** | Local Node.js servers | MetMuseum-MCP | stdin/stdout |\n\n资料来源：[README.md:70-85]()\n\n---\n\n## Large Language Model Integration\n\n### OpenAI GPT-5 Nano\n\n| Parameter | Value |\n|-----------|-------|\n| Provider | OpenAI |\n| Model | gpt-5-nano |\n| Integration | langchain-openai |\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",\n)\n```\n\n资料来源：[main.py:47-50]()\n\nThe LLM powers the agent's reasoning capabilities, enabling autonomous tool selection and natural language understanding.\n\n---\n\n## Memory System\n\n### InMemorySaver\n\nThe project implements persistent conversation memory using LangGraph's `InMemorySaver`.\n\n```python\ncheckpointer = InMemorySaver()\n\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n| Feature | Implementation |\n|---------|----------------|\n| Type | In-memory checkpointing |\n| Scope | Thread-based conversation persistence |\n| Library | langgraph.checkpoint.memory |\n| Thread Identifier | Configurable `thread_id` |\n\n资料来源：[main.py:52-55]()\n\n---\n\n## MCP Server Integration\n\n### Context7 Server\n\n| Attribute | Value |\n|-----------|-------|\n| Type | Remote HTTP Server |\n| URL | https://mcp.context7.com/mcp |\n| Transport | streamable_http |\n| Purpose | LLM-optimized documentation search |\n\nContext7 provides access to documentation across major software frameworks and libraries, enabling the agent to answer code-related queries.\n\n资料来源：[README.md:78-80]()\n\n### MetMuseum-MCP Server\n\n| Attribute | Value |\n|-----------|-------|\n| Type | Local STDIO Server |\n| Command | npx |\n| Package | metmuseum-mcp |\n| Transport | stdio |\n| Purpose | Access to 400,000+ artworks |\n\nThe Met Museum MCP server is executed locally via npx and communicates through stdin/stdout, providing access to the Metropolitan Museum of Art collection.\n\n资料来源：[README.md:81-85]()\n\n---\n\n## Architecture Diagram\n\n```mermaid\ngraph TD\n    User[User CLI] --> Agent[LangGraph ReAct Agent]\n    Agent --> LLM[GPT-5 Nano]\n    Agent --> Tools[All MCP Tools]\n    \n    subgraph MCP_Clients\n        HTTP[HTTP Transport] --> Context7[Context7 Server]\n        STDIO[STDIO Transport] --> MetMuseum[MetMuseum-MCP]\n    end\n    \n    Tools --> MCP_Clients\n    LLM --> Decision[Tool Selection]\n    Decision --> MCP_Clients\n    \n    Agent --> Memory[InMemorySaver]\n    Memory --> Thread[conversation_id]\n    \n    subgraph External\n        Context7 --> Docs[Library Documentation]\n        MetMuseum --> Artworks[400K+ Artworks]\n    end\n```\n\n---\n\n## Workflow Diagram\n\n```mermaid\ngraph LR\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Which Server?}\n    C -->|Library/Code| D[Context7 HTTP]\n    C -->|Art/Museum| E[MetMuseum STDIO]\n    D --> F[Tool Execution]\n    E --> F\n    F --> G[Result to LLM]\n    G --> H[Natural Language Response]\n    H --> I[InMemorySaver]\n    I --> J[User Receives Response]\n```\n\n资料来源：[README.md:28-60]()\n\n---\n\n## Async Programming\n\n### Asyncio Integration\n\nThe project leverages Python's `asyncio` for concurrent operations:\n\n```python\nasync def main():\n    # Async operations for MCP client\n    client = MultiServerMCPClient({...})\n    tools = await client.get_tools()\n    \n    # Agent invocation\n    response = await agent.ainvoke(...)\n```\n\n| Component | Async Pattern |\n|-----------|---------------|\n| MCP Client | `await client.get_tools()` |\n| Agent Invocation | `await agent.ainvoke()` |\n| Entry Point | `asyncio.run(main())` |\n\n资料来源：[main.py:19-80]()\n\n---\n\n## Skills Demonstrated\n\nThe technology stack showcases the following competencies:\n\n| Skill | Implementation |\n|-------|----------------|\n| Multi-server MCP client architecture | MultiServerMCPClient |\n| STDIO + HTTP transport management | Dual protocol support |\n| LangGraph ReAct agent with tool calling | create_react_agent |\n| GPT-5 Nano integration | ChatOpenAI |\n| Persistent conversation memory | InMemorySaver |\n| Thread-based conversation management | thread_id config |\n| Async Python patterns | asyncio + await |\n\n资料来源：[README.md:62-75]()\n\n---\n\n## Dependencies\n\n| Package | Purpose |\n|---------|---------|\n| langchain-mcp-adapters | MultiServerMCPClient for MCP server connections |\n| langgraph | ReAct agent framework and InMemorySaver |\n| langchain-openai | OpenAI model integration |\n| npx | Node.js package runner (external) |\n\n资料来源：[README.md:88-91]()\n\n---\n\n## System Architecture Summary\n\n| Layer | Component | Technology |\n|-------|-----------|------------|\n| Interface | CLI | User input/output |\n| Agent | ReAct Agent | LangGraph |\n| Reasoning | LLM | OpenAI GPT-5 Nano |\n| Memory | Checkpointer | InMemorySaver |\n| Integration | MCP Client | langchain-mcp-adapters |\n| External Services | Documentation | Context7 (HTTP) |\n| External Services | Museum Data | MetMuseum (STDIO) |\n\n---\n\n<a id='page-system-architecture'></a>\n\n## System Architecture\n\n### 相关页面\n\n相关主题：[Agent Workflow](#page-agent-workflow), [Transport Mechanisms](#page-transport-mechanisms), [MCP Server Integration](#page-mcp-servers)\n\n<details>\n<summary>Relevant Source Files</summary>\n\nThe following source files were used to generate this page:\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# System Architecture\n\n## Overview\n\nThe mcp-ai-agent is a multi-server Model Context Protocol (MCP) client designed to act as a universal interface for AI agents. It simultaneously connects to multiple MCP servers across different transport protocols, providing persistent conversation memory and autonomous tool selection powered by GPT-5 Nano through a LangGraph ReAct agent implementation. 资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## High-Level Architecture\n\nThe system follows a layered architecture where the CLI interface communicates with a LangGraph ReAct agent that manages connections to multiple external MCP servers. The agent reasoning engine determines which server to query based on the user's domain, while the checkpointer maintains conversation state across interactions. 资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n```mermaid\ngraph TD\n    User[User CLI Interface]\n    Agent[LangGraph ReAct Agent]\n    MCPClient[MultiServerMCPClient]\n    Context7[Context7 Server]\n    MetMuseum[MetMuseum-MCP Server]\n    \n    User -->|\"User Query\"| Agent\n    Agent -->|\"Tool Execution\"| MCPClient\n    MCPClient -->|\"HTTP Transport\"| Context7\n    MCPClient -->|\"STDIO Transport\"| MetMuseum\n    Agent -->|\"Memory\"| InMemorySaver[InMemorySaver]\n    \n    subgraph \"Transport Layer\"\n        Context7\n        MetMuseum\n    end\n```\n\n## Core Components\n\n### MultiServerMCPClient\n\nThe MultiServerMCPClient from the `langchain-mcp-adapters` package handles simultaneous connections to multiple MCP servers using different transport protocols. This component abstracts the complexity of managing HTTP and STDIO connections, providing a unified interface for tool retrieval. 资料来源：[main.py:24](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n| Server | Transport Type | Purpose |\n|--------|---------------|---------|\n| Context7 | `streamable_http` | Remote cloud-based library documentation search |\n| MetMuseum-MCP | `stdio` | Local museum collection access via npx |\n\n### Configuration Parameters\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| `context7.url` | `https://mcp.context7.com/mcp` | Endpoint for Context7 MCP server |\n| `context7.transport` | `streamable_http` | HTTP-based communication protocol |\n| `met-museum.command` | `npx` | Node.js package runner |\n| `met-museum.args` | `[\"-y\", \"metmuseum-mcp\"]` | Auto-install and execute MetMuseum MCP |\n| `met-museum.transport` | `stdio` | Standard input/output protocol |\n\n资料来源：[main.py:28-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### LangGraph ReAct Agent\n\nThe agent is created using LangGraph's `create_react_agent` factory function, combining the OpenAI language model with retrieved MCP tools and a checkpointer for conversation persistence. The ReAct (Reasoning + Acting) pattern enables the agent to reason about which tools to invoke before executing them. 资料来源：[main.py:56-61](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\nagent = create_react_agent(\n    model=openai_model,         # GPT-5 Nano reasoning engine\n    tools=tools,                # Available tools from MCP servers\n    checkpointer=checkpointer   # Memory system for conversation history\n)\n```\n\n### Language Model Integration\n\nThe system uses OpenAI's GPT-5 Nano model through the `langchain_openai` package, configured with minimal parameters for cost-effective reasoning. 资料来源：[main.py:44-46](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",  # Using OpenAI's GPT-5 Nano model\n)\n```\n\n### Conversation Memory System\n\nThe InMemorySaver checkpointer provides thread-based conversation persistence. All messages within a session share the same `thread_id`, enabling the agent to maintain context across multiple user queries. 资料来源：[main.py:48-52](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n## Agent Workflow\n\n```mermaid\ngraph TD\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Which Server Has Info?}\n    C -->|\"Code/Library Docs\"| D[Context7 HTTP]\n    C -->|\"Art/Museum Data\"| E[MetMuseum STDIO]\n    D --> F[Tool Execution]\n    E --> F\n    F --> G[Result to LLM]\n    G --> H[LLM Generates Response]\n    H --> I[Store in InMemorySaver]\n    I --> J[User Receives Response]\n```\n\n### Workflow Steps\n\n1. **User Query**: The CLI receives a natural language question from the user\n2. **LLM Reasoning**: GPT-5 Nano analyzes the query to determine which MCP server contains relevant information\n3. **Tool Selection**: The agent autonomously selects the appropriate server based on domain classification\n4. **Tool Execution**: The selected MCP server is invoked via its transport protocol\n5. **Result Processing**: Tool results are returned to the LLM for natural language synthesis\n6. **Memory Storage**: The complete conversation exchange is persisted via InMemorySaver\n7. **Response Delivery**: The user receives the formatted response with preserved context\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Transport Protocols\n\n### HTTP Transport (Context7)\n\nThe Context7 server uses `streamable_http` transport for remote cloud communication. This transport is optimized for latency-sensitive operations and supports scalable server deployments. 资料来源：[main.py:29-31](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\n\"context7\": {\n    \"url\": \"https://mcp.context7.com/mcp\",\n    \"transport\": \"streamable_http\",\n}\n```\n\n### STDIO Transport (MetMuseum)\n\nThe MetMuseum MCP server uses `stdio` transport for local process communication. The server is launched via `npx` and communicates through standard input/output streams. 资料来源：[main.py:33-36](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\n\"met-museum\": {\n    \"command\": \"npx\",\n    \"args\": [\"-y\", \"metmuseum-mcp\"],\n    \"transport\": \"stdio\",\n}\n```\n\n## Async Architecture\n\nThe entire system is built on Python's `asyncio` framework, enabling concurrent handling of multiple MCP server connections and non-blocking I/O operations. The main entry point uses `asyncio.run()` to execute the async `main()` function. 资料来源：[main.py:1](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n```python\nimport asyncio\n\nasync def main():\n    # Async MCP client initialization\n    client = MultiServerMCPClient({...})\n    \n    # Async tool retrieval\n    tools = await client.get_tools()\n    \n    # Async agent invocation\n    response = await agent.ainvoke({\"messages\": query}, config=config)\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n## Interaction Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant MCPClient\n    participant Server\n    \n    User->>CLI: Enter question\n    CLI->>Agent: ainvoke(query)\n    Agent->>MCPClient: get_tools()\n    MCPClient->>Server: HTTP/STDIO Request\n    Server->>MCPClient: Tool Response\n    MCPClient->>Agent: Results\n    Agent->>Agent: Generate natural language\n    Agent->>CLI: Formatted response\n    CLI->>User: Display response\n```\n\n## Dependency Stack\n\n| Layer | Technology | Version | Purpose |\n|-------|-----------|---------|---------|\n| Language | Python | 3.10+ | Runtime environment |\n| MCP Client | langchain-mcp-adapters | Latest | Multi-server MCP connections |\n| Agent Framework | langgraph | Latest | ReAct agent orchestration |\n| LLM Integration | langchain-openai | Latest | OpenAI API wrapper |\n| Runtime | npx/Node.js | Latest | Local MCP server execution |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## System Initialization Sequence\n\n```python\n# 1. Create MCP client with server configurations\nclient = MultiServerMCPClient(servers)\n\n# 2. Initialize the language model\nopenai_model = ChatOpenAI(model=\"gpt-5-nano\")\n\n# 3. Retrieve all tools from connected servers\ntools = await client.get_tools()\n\n# 4. Set up conversation memory\ncheckpointer = InMemorySaver()\n\n# 5. Create configuration with thread ID\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n\n# 6. Build the ReAct agent\nagent = create_react_agent(model, tools, checkpointer)\n```\n\n资料来源：[main.py:23-61](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Autonomous Tool Selection\n\nThe agent demonstrates intelligent routing based on query domain classification:\n\n| Query Type | Target Server | Example |\n|------------|---------------|---------|\n| Documentation/Code | Context7 | \"What LangGraph tools are available?\" |\n| Art/Museum | MetMuseum | \"Show me Van Gogh paintings\" |\n\nThis autonomous selection is powered by GPT-5 Nano's reasoning capabilities, eliminating the need for explicit routing logic in the application code. 资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n<a id='page-agent-workflow'></a>\n\n## Agent Workflow\n\n### 相关页面\n\n相关主题：[System Architecture](#page-system-architecture), [LangGraph ReAct Agent](#page-langgraph-react-agent), [Memory Management](#page-memory-management)\n\n<details>\n<summary>Relevant Source Files</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# Agent Workflow\n\nThe **Agent Workflow** in this MCP AI agent project defines how a user query flows through the system—from initial reasoning by the language model to autonomous tool selection and execution across multiple MCP servers, ultimately producing a contextual response with persistent conversation memory.\n\n---\n\n## Overview\n\nThe agent functions as a **Universal Interface** built on the Model Context Protocol (MCP), connecting simultaneously to multiple MCP servers across different transport protocols. It combines **GPT-5 Nano reasoning** with **autonomous tool selection** and **persistent conversation memory** to deliver intelligent, domain-aware responses.\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## High-Level Architecture\n\n```mermaid\ngraph TD\n    User[User Query] --> CLI[CLI Interface]\n    CLI --> Agent[LangGraph ReAct Agent]\n    \n    Agent --> LLM[GPT-5 Nano<br/>Reasoning Engine]\n    LLM --> Decision{Which Server?}\n    \n    Decision -->|Library/Code Docs| Context7[Context7 Server<br/>HTTP Transport]\n    Decision -->|Art/Museum Data| MetMuseum[MetMuseum-MCP<br/>STDIO Transport]\n    \n    Context7 --> Tools1[Documentation Tools]\n    MetMuseum --> Tools2[Artwork Tools]\n    \n    Tools1 --> Result1[Result Returned]\n    Tools2 --> Result2[Result Returned]\n    \n    Result1 --> LLM\n    Result2 --> LLM\n    \n    LLM --> Response[Natural Language<br/>Response]\n    Response --> Memory[InMemorySaver<br/>thread_id]\n    Memory --> User\n    \n    style User fill:#e1f5fe\n    style Agent fill:#fff3e0\n    style LLM fill:#f3e5f5\n    style Memory fill:#e8f5e9\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Workflow Stages\n\n### 1. User Query Input\n\nThe workflow begins when a user submits a natural language query through the CLI interface. The agent presents a menu with two options:\n\n| Option | Action |\n|--------|--------|\n| `1` | Ask the agent a question |\n| `2` | Quit |\n\n资料来源：[main.py:44-48](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### 2. GPT-5 Nano Reasoning\n\nThe submitted query is passed to **GPT-5 Nano** via the `ChatOpenAI` model. The LLM performs reasoning to determine:\n\n- The intent of the user's question\n- Which domain the query belongs to\n- Which MCP server has the relevant information\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",\n)\n```\n\n资料来源：[main.py:60-62](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### 3. Autonomous Tool Selection\n\nBased on the reasoning, the agent autonomously selects the appropriate MCP server:\n\n```mermaid\ngraph LR\n    Query1[\"Query about code libraries<br/>e.g., 'LangGraph tools'\"] --> Decision1{Decision}\n    Query2[\"Query about artworks<br/>e.g., 'Van Gogh paintings'\"] --> Decision1\n    \n    Decision1 -->|Code/Docs| C7[Context7 Server<br/>streamable_http]\n    Decision1 -->|Museum Data| MM[MetMuseum-MCP<br/>stdio via npx]\n    \n    C7 --> ToolsC7[Documentation<br/>Search Tools]\n    MM --> ToolsMM[Artwork Metadata<br/>& Images Tools]\n```\n\n| Server | Transport | Use Case |\n|--------|-----------|----------|\n| **Context7** | `streamable_http` | Software framework documentation, library references |\n| **MetMuseum-MCP** | `stdio` | Museum artwork metadata, images, collections |\n\n资料来源：[main.py:38-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### 4. Tool Execution\n\nTools are retrieved from both MCP servers via `MultiServerMCPClient` and attached to the agent:\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n\ntools = await client.get_tools()\n```\n\n资料来源：[main.py:38-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### 5. Result Processing\n\nAfter tool execution, results are returned to the LLM, which generates a natural language response incorporating the retrieved data.\n\n### 6. Response Delivery\n\nThe final response is displayed to the user, and the conversation is stored in memory:\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config\n)\nprint(response['messages'][-1].content)\n```\n\n资料来源：[main.py:68-72](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Core Components\n\n### LangGraph ReAct Agent\n\nThe agent is created using `create_react_agent` from LangGraph, combining reasoning and acting capabilities:\n\n| Component | Purpose |\n|-----------|---------|\n| `model` | GPT-5 Nano for LLM reasoning |\n| `tools` | All tools from MCP servers |\n| `checkpointer` | InMemorySaver for memory |\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n资料来源：[main.py:64-68](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Persistent Conversation Memory\n\nThe `InMemorySaver` provides thread-based conversation persistence:\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n| Feature | Description |\n|---------|-------------|\n| Memory Type | In-memory (volatile) |\n| Persistence Scope | Thread-based via `thread_id` |\n| Use Case | Multi-turn conversations |\n\n资料来源：[main.py:63-65](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Multi-Server MCP Client\n\nThe `MultiServerMCPClient` manages connections to multiple servers simultaneously:\n\n| Server | Transport | Protocol |\n|--------|-----------|----------|\n| Context7 | Remote HTTP | `streamable_http` |\n| MetMuseum-MCP | Local STDIO | `npx` command |\n\n资料来源：[main.py:38-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Interaction Flow\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant Agent\n    participant LLM\n    participant Context7\n    participant MetMuseum\n    participant Memory\n\n    User->>Agent: Submit query\n    Agent->>LLM: Reason about query intent\n    LLM-->>Agent: Select appropriate server\n    \n    alt Code/Documentation Query\n        Agent->>Context7: Call documentation tools\n        Context7-->>Agent: Return documentation\n    else Museum Query\n        Agent->>MetMuseum: Call artwork tools\n        MetMuseum-->>Agent: Return artwork data\n    end\n    \n    Agent->>LLM: Generate response with context\n    LLM-->>Agent: Natural language response\n    Agent->>Memory: Store in thread\n    Agent-->>User: Display response\n    \n    Note over User,Memory: Full conversation history preserved\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## System Prompt Configuration\n\nThe agent's behavior is defined through a system message:\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": [\n        {\"role\": \"system\", \"content\": \"You are a smart, useful agent with tools to access code library documentation and the Met Museum collection.\"},\n        {\"role\": \"user\", \"content\": \"Give a brief introduction of what you do and the tools you can access.\"},\n    ]},\n    config=config\n)\n```\n\n| Message Type | Purpose |\n|--------------|---------|\n| `system` | Defines agent role and capabilities |\n| `user` | Initial introduction request |\n\n资料来源：[main.py:74-81](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Execution Model\n\nThe application uses Python's `asyncio` for asynchronous execution:\n\n```python\nasync def main():\n    # Async operations for MCP client\n    # Agent invocation with tools\n    pass\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n| Pattern | Usage |\n|---------|-------|\n| `async/await` | Non-blocking I/O for MCP servers |\n| `asyncio.run()` | Entry point for async execution |\n\n资料来源：[main.py:30-89](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Example Workflow Scenarios\n\n### Scenario 1: Documentation Query\n\n| Step | Action |\n|------|--------|\n| 1 | User asks: \"What LangGraph tools are available?\" |\n| 2 | LLM reasons → selects Context7 |\n| 3 | Context7 returns LangGraph documentation |\n| 4 | Agent generates response |\n| 5 | Response stored in memory |\n\n### Scenario 2: Museum Collection Query\n\n| Step | Action |\n|------|--------|\n| 1 | User asks: \"Show me Impressionist paintings from the Met\" |\n| 2 | LLM reasons → selects MetMuseum-MCP |\n| 3 | MetMuseum returns artwork metadata |\n| 4 | Agent generates response |\n| 5 | Response stored in memory |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Technology Stack Summary\n\n| Component | Technology | Role |\n|-----------|------------|------|\n| Language | Python 3.10+ | Runtime |\n| MCP Client | langchain-mcp-adapters | Server connectivity |\n| Agent Framework | LangGraph ReAct | Tool-augmented reasoning |\n| LLM | OpenAI GPT-5 Nano | Natural language understanding |\n| Memory | InMemorySaver | Conversation persistence |\n| Transport 1 | streamable_http | Remote server communication |\n| Transport 2 | stdio | Local server communication |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n<a id='page-langgraph-react-agent'></a>\n\n## LangGraph ReAct Agent\n\n### 相关页面\n\n相关主题：[Agent Workflow](#page-agent-workflow), [Memory Management](#page-memory-management), [MCP Server Integration](#page-mcp-servers)\n\n<details>\n<summary>Related Source Files</summary>\n\nThe following source files were used to generate this page:\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# LangGraph ReAct Agent\n\n## Overview\n\nThe LangGraph ReAct Agent is the core reasoning and decision-making engine in the `mcp-ai-agent` project. It combines the **ReAct** (Reasoning + Acting) pattern with LangGraph's stateful graph architecture to create an autonomous agent capable of selecting and executing tools from multiple MCP (Model Context Protocol) servers.\n\n**Key Responsibilities:**\n\n- Reasoning about user queries to determine which tools to invoke\n- Coordinating with multiple MCP servers across different transport protocols\n- Maintaining conversation history through persistent memory\n- Generating natural language responses based on tool execution results\n\n**资料来源：** [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Architecture\n\n### System Overview\n\nThe agent operates within a multi-server MCP client architecture that connects to both remote and local MCP servers:\n\n```mermaid\ngraph TD\n    User[User Query] --> CLI[CLI Interface]\n    CLI --> Agent[LangGraph ReAct Agent]\n    Agent --> MCPClient[MultiServerMCPClient]\n    MCPClient --> HTTP[HTTP Transport]\n    MCPClient --> STDIO[STDIO Transport]\n    HTTP --> Context7[Context7 Server]\n    STDIO --> MetMuseum[MetMuseum MCP Server]\n    Context7 --> Docs[Library Documentation]\n    MetMuseum --> Artworks[Met Museum Collection]\n    Agent <--> Memory[InMemorySaver]\n```\n\n**资料来源：** [README.md:1-80](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Agent Creation Pipeline\n\n```mermaid\ngraph LR\n    A[ChatOpenAI Model] --> B[create_react_agent]\n    C[MCP Tools] --> B\n    D[InMemorySaver] --> B\n    B --> E[ReAct Agent]\n```\n\n**资料来源：** [main.py:46-56](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Core Components\n\n### Component Configuration\n\n| Component | Class | Purpose |\n|-----------|-------|---------|\n| **MCP Client** | `MultiServerMCPClient` | Manages connections to multiple MCP servers |\n| **Agent** | `create_react_agent` | ReAct-style agent with tool-calling capabilities |\n| **Memory** | `InMemorySaver` | Persistent conversation history storage |\n| **LLM** | `ChatOpenAI` | Language model for reasoning and response generation |\n| **Checkpointer** | `InMemorySaver` | Thread-based conversation state persistence |\n\n**资料来源：** [main.py:17-21](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### MCP Server Configuration\n\n| Server | Transport | Type | Capabilities |\n|--------|-----------|------|--------------|\n| **context7** | `streamable_http` | Remote/HTTP | LLM-optimized documentation search |\n| **met-museum** | `stdio` | Local/STDIO | Metropolitan Museum artwork access |\n\n**资料来源：** [main.py:29-43](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Agent Initialization\n\n### Step 1: MCP Client Setup\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\nThe `MultiServerMCPClient` simultaneously manages:\n\n- **HTTP Transport**: Used for remote servers like Context7\n- **STDIO Transport**: Used for local servers like MetMuseum-MCP (via npx)\n\n**资料来源：** [main.py:29-43](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Step 2: Tool Retrieval\n\n```python\ntools = await client.get_tools()\n```\n\nAll tools from both MCP servers are aggregated into a single tool collection that the agent can invoke.\n\n**资料来源：** [main.py:48-49](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Step 3: Memory Checkpointer\n\n```python\ncheckpointer = InMemorySaver()\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\nThe `InMemorySaver` provides in-memory persistence for conversation threads, enabling the agent to maintain context across multiple interactions.\n\n**资料来源：** [main.py:51-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Step 4: Agent Creation\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\nThe agent is created using LangGraph's `create_react_agent` factory with the OpenAI model, aggregated tools, and memory checkpointer.\n\n**资料来源：** [main.py:56-60](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Workflow\n\n### Query Processing Flow\n\n```mermaid\ngraph TD\n    A[User Query] --> B{Parse Query}\n    B -->|Library/Code docs| C[Call Context7 Tools]\n    B -->|Art/Museum data| D[Call MetMuseum Tools]\n    C --> E[Tool Execution]\n    D --> E\n    E --> F[Result returned to LLM]\n    F --> G[Generate Natural Language Response]\n    G --> H[Store in InMemorySaver]\n    H --> I[Return Response to User]\n```\n\n**资料来源：** [README.md:35-50](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Autonomous Tool Selection\n\nThe agent independently decides which MCP server to query based on the user's query:\n\n| Query Type | Selected Server | Example |\n|------------|-----------------|---------|\n| Documentation | Context7 | \"What is the LangChain documentation for agents?\" |\n| Artwork | MetMuseum | \"Show me Van Gogh paintings in the Met Museum\" |\n\n**资料来源：** [README.md:70-82](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Message Handling\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant Memory\n    participant MCP_Servers\n\n    User->>CLI: Enter query\n    CLI->>Agent: ainvoke with query + config\n    Agent->>Memory: Check conversation history\n    Memory-->>Agent: Previous messages\n    Agent->>MCP_Servers: Select and call appropriate tool\n    MCP_Servers-->>Agent: Tool result\n    Agent->>Memory: Store updated conversation\n    Agent-->>CLI: Response with context\n    CLI-->>User: Display final response\n```\n\n**资料来源：** [main.py:64-90](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Configuration Reference\n\n### Model Configuration\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| `model` | `gpt-5-nano` | OpenAI GPT-5 Nano model for reasoning |\n\n**资料来源：** [main.py:45-46](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Conversation Configuration\n\n| Parameter | Key | Value | Description |\n|-----------|-----|-------|-------------|\n| `configurable` | `thread_id` | `\"conversation_id\"` | Groups all messages in a session |\n\n**资料来源：** [main.py:53-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### System Prompt\n\nThe agent is initialized with a system message defining its role:\n\n```\nYou are a smart, useful agent with tools to access code library documentation and the Met Museum collection.\n```\n\n**资料来源：** [main.py:68-69](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Usage Patterns\n\n### Initial Introduction\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": [\n        {\"role\": \"system\", \"content\": \"You are a smart, useful agent...\"},\n        {\"role\": \"user\", \"content\": \"Give a brief introduction...\"},\n    ]},\n    config=config\n)\nprint(response['messages'][-1].content)\n```\n\n**资料来源：** [main.py:65-75](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Query Invocation\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config\n)\nprint(response['messages'][-1].content)\n```\n\nThe response contains all messages; the final message (`[-1]`) holds the agent's natural language response.\n\n**资料来源：** [main.py:81-88](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Dependencies\n\n| Package | Purpose |\n|---------|---------|\n| `langchain-mcp-adapters` | MultiServerMCPClient for MCP server connections |\n| `langgraph` | create_react_agent, InMemorySaver |\n| `langchain-openai` | ChatOpenAI integration |\n\n**资料来源：** [main.py:17-21](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py), [README.md:87-92](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Key Features\n\n| Feature | Implementation | Benefit |\n|---------|---------------|---------|\n| Multi-transport support | Simultaneous HTTP + STDIO | Connect to diverse MCP servers |\n| Persistent memory | InMemorySaver with thread_id | Maintains conversation context |\n| Autonomous tool selection | GPT-5 Nano reasoning | LLM decides which server to query |\n| ReAct pattern | create_react_agent | Combines reasoning with tool execution |\n| Async architecture | asyncio + await | Non-blocking concurrent operations |\n\n**资料来源：** [README.md:95-107](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n<a id='page-memory-management'></a>\n\n## Memory Management\n\n### 相关页面\n\n相关主题：[LangGraph ReAct Agent](#page-langgraph-react-agent), [Agent Workflow](#page-agent-workflow)\n\n<details>\n<summary>Relevant Source Files</summary>\n\nThe following source files were used to generate this documentation:\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Memory Management\n\n## Overview\n\nThe mcp-ai-agent implements a **persistent conversation memory system** using LangGraph's checkpointing infrastructure. This system enables the AI agent to maintain context across multiple interaction turns within a single conversation session, ensuring coherent and contextually aware responses.\n\nMemory management is critical for multi-turn conversations where the agent needs to reference previous user queries, tool invocations, and generated responses to provide meaningful follow-up interactions.\n\n---\n\n## Architecture\n\n### System Components\n\n| Component | Type | Purpose | Source |\n|-----------|------|---------|--------|\n| `InMemorySaver` | Checkpointer | Stores conversation state in memory | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n| `thread_id` | Configuration Key | Groups messages into conversation threads | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n| `config` | Dictionary | Carries configurable parameters to agent | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n| `checkpointer` | Parameter | Attaches memory to ReAct agent | [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py) |\n\n### Memory Flow Architecture\n\n```mermaid\ngraph TD\n    A[User Query 1] --> B[Agent Invocation]\n    B --> C[InMemorySaver Checkpointer]\n    C --> D[Memory Storage]\n    D --> E[Response Generated]\n    \n    F[User Query 2] --> G[Agent Invocation with Config]\n    G --> C\n    C --> H[Retrieve Prior Conversation State]\n    H --> I[Full Context Available]\n    I --> J[Context-Aware Response]\n    \n    E --> D\n    J --> D\n```\n\n---\n\n## Core Components\n\n### InMemorySaver\n\nThe `InMemorySaver` class from `langgraph.checkpoint.memory` provides the foundational memory storage mechanism.\n\n```python\nfrom langgraph.checkpoint.memory import InMemorySaver\n\ncheckpointer = InMemorySaver()\n```\n\n**Characteristics:**\n\n| Property | Value |\n|----------|-------|\n| Storage Type | In-memory (volatile) |\n| Persistence | Session-scoped only |\n| Scope | Single Python process |\n| Serialization | Automatic by LangGraph |\n\n资料来源：[main.py:1-3](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Thread Configuration\n\nEach conversation is associated with a unique thread identifier, enabling isolation between different user sessions.\n\n```python\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n**Configuration Parameters:**\n\n| Parameter | Type | Default | Description |\n|-----------|------|---------|-------------|\n| `thread_id` | string | \"conversation_id\" | Unique identifier for the conversation thread |\n\n资料来源：[main.py:58-60](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Agent Integration\n\nThe checkpointer is attached to the ReAct agent during initialization, binding the memory system to the agent's lifecycle.\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n资料来源：[main.py:63-67](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Memory Lifecycle\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI\n    participant Agent\n    participant Checkpointer\n    participant LLM\n\n    User->>CLI: Enter query\n    CLI->>Agent: ainvoke with config + query\n    Agent->>Checkpointer: Load thread state\n    Checkpointer-->>Agent: Prior messages\n    Agent->>LLM: Full context + new query\n    LLM-->>Agent: Generated response\n    Agent->>Checkpointer: Save updated state\n    Agent-->>CLI: Response\n    CLI-->>User: Display result\n```\n\n### Initialization Phase\n\nDuring agent initialization, the checkpointer is configured:\n\n1. `InMemorySaver` instance is created\n2. Configuration dictionary is prepared with `thread_id`\n3. Agent is created with checkpointer attached\n\n资料来源：[main.py:52-67](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Query Processing Phase\n\nEach incoming query triggers the following memory operations:\n\n1. Agent receives query with configuration containing `thread_id`\n2. Checkpointer loads all prior messages from the thread\n3. Full conversation history is prepended to current query\n4. LLM generates response with complete context\n5. New messages are appended to thread state\n6. Updated state is persisted via checkpointer\n\n资料来源：[main.py:76-86](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Usage Pattern\n\n### Basic Implementation\n\n```python\n# Import the checkpointer\nfrom langgraph.checkpoint.memory import InMemorySaver\n\n# Create in-memory storage\ncheckpointer = InMemorySaver()\n\n# Define thread configuration\nconfig = {\"configurable\": {\"thread_id\": \"user_session_123\"}}\n\n# Attach to agent\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n\n# Query with memory preservation\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config\n)\n```\n\n### Multi-Turn Conversation Example\n\n```python\n# First turn - agent introduces itself\nresponse = await agent.ainvoke(\n    {\"messages\": [\n        {\"role\": \"system\", \"content\": \"You are a smart agent...\"},\n        {\"role\": \"user\", \"content\": \"Introduce yourself\"}\n    ]},\n    config=config\n)\n\n# Second turn - user asks follow-up question\nresponse = await agent.ainvoke(\n    {\"messages\": \"What tools can you use?\"},\n    config=config\n)\n# Agent remembers the introduction from turn 1\n```\n\n资料来源：[main.py:69-86](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Configuration Options\n\n### Thread Management\n\n| Option | Description | Use Case |\n|--------|-------------|----------|\n| Static `thread_id` | Fixed identifier for entire session | Single continuous conversation |\n| Dynamic `thread_id` | Generated per user/session | Multi-user applications |\n| Per-invocation `config` | Separate config each call | Complex state management |\n\n### Memory Configuration Structure\n\n```python\nconfig = {\n    \"configurable\": {\n        \"thread_id\": str,          # Required: conversation identifier\n        # Additional configurable fields can be added here\n    }\n}\n```\n\n---\n\n## State Storage Model\n\n### Persisted State Components\n\nThe checkpointer automatically stores:\n\n| State Component | Description | Example |\n|-----------------|-------------|---------|\n| Message History | All conversation messages | System, user, assistant, tool messages |\n| Tool Call Results | Responses from MCP tool invocations | Documentation search results, artwork data |\n| Agent Memory | Intermediate agent reasoning state | ReAct thought processes |\n\n### State Access Pattern\n\n```mermaid\ngraph LR\n    A[Query N] --> B[Load State: Messages 1 to N-1]\n    B --> C[LLM Processing]\n    C --> D[Generate Response]\n    D --> E[Save State: Messages 1 to N]\n    E --> F[Return to User]\n```\n\n---\n\n## Limitations\n\n| Limitation | Impact | Mitigation |\n|------------|--------|------------|\n| In-memory only | Data lost on process restart | Not suitable for production requiring persistence |\n| Single-process | Cannot scale across instances | Use database-backed checkpointers for distributed systems |\n| Memory-bound | Large conversations consume RAM | Implement conversation truncation for extended sessions |\n\n---\n\n## Integration with MCP Tools\n\nThe memory system works seamlessly with MCP server tool calls:\n\n```python\n# When user queries about library docs:\n# 1. Memory loads prior conversation\n# 2. Agent decides to call Context7 tools\n# 3. Tool results stored in conversation state\n# 4. Agent generates response referencing full history\n\n# When user queries about museum artworks:\n# 1. Memory loads prior conversation\n# 2. Agent decides to call MetMuseum tools\n# 3. Tool results stored in conversation state\n# 4. Agent generates contextually aware response\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Dependencies\n\n| Package | Version | Purpose |\n|---------|---------|---------|\n| `langgraph` | Latest | Core agent framework with checkpointing |\n| `langgraph.checkpoint.memory` | Included | InMemorySaver implementation |\n\n资料来源：[main.py:3](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Summary\n\nThe Memory Management system in mcp-ai-agent provides:\n\n- **Conversation persistence** via thread-based state storage\n- **Context preservation** across multiple interaction turns\n- **Seamless integration** with LangGraph ReAct agent architecture\n- **Automatic state management** through the checkpointer interface\n\nThis system enables the agent to maintain coherent, context-aware conversations while preserving the full history of tool invocations and responses within each session.\n\n---\n\n<a id='page-mcp-servers'></a>\n\n## MCP Server Integration\n\n### 相关页面\n\n相关主题：[Transport Mechanisms](#page-transport-mechanisms), [System Architecture](#page-system-architecture)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# MCP Server Integration\n\n## Overview\n\nThe MCP Server Integration module serves as the core connectivity layer that enables the AI agent to communicate with multiple external services simultaneously. This integration leverages the **Model Context Protocol (MCP)** to establish connections between the agent and various MCP-compliant servers, providing access to diverse data sources and capabilities through a unified interface.\n\nThe integration supports both **HTTP** and **STDIO** transport protocols, allowing the agent to connect to remote cloud-based servers and local Node.js-based MCP servers concurrently. This dual-transport architecture enables seamless access to documentation services, museum collections, and other specialized data providers without requiring the agent to manage multiple connection protocols manually.\n\n资料来源：[main.py:28-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Architecture\n\n### High-Level System Design\n\nThe MCP Server Integration follows a client-server architecture where the `MultiServerMCPClient` acts as a central hub managing multiple server connections. The client aggregates tools from all configured servers and exposes them to the LangGraph ReAct agent for autonomous tool selection based on user queries.\n\n```mermaid\ngraph TD\n    subgraph Agent[\"LangGraph ReAct Agent\"]\n        LLM[\"GPT-5 Nano<br/>Reasoning Engine\"]\n        Tools[\"Aggregated Tools\"]\n        Mem[\"InMemorySaver<br/>Conversation Memory\"]\n    end\n    \n    subgraph Client[\"MultiServerMCPClient\"]\n        HTTP[\"HTTP Transport<br/>Manager\"]\n        STDIO[\"STDIO Transport<br/>Manager\"]\n    end\n    \n    subgraph Servers[\"MCP Servers\"]\n        C7[\"Context7 Server<br/>(Remote HTTP)\"]\n        MET[\"MetMuseum-MCP<br/>(Local STDIO)\"]\n    end\n    \n    User[\"User Query\"]\n    Response[\"AI Response\"]\n    \n    User --> LLM\n    LLM --> Tools\n    Tools --> HTTP\n    Tools --> STDIO\n    HTTP --> C7\n    STDIO --> MET\n    C7 --> Response\n    MET --> Response\n    LLM --> Mem\n    \n    style Client fill:#e1f5fe\n    style Servers fill:#fff3e0\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Component Responsibilities\n\n| Component | Responsibility | Transport Type |\n|-----------|----------------|----------------|\n| `MultiServerMCPClient` | Manages concurrent server connections and tool aggregation | Both |\n| `create_react_agent` | Creates the ReAct agent with integrated tools | N/A |\n| `InMemorySaver` | Maintains conversation history per thread | N/A |\n| `ChatOpenAI` | Powers reasoning and natural language generation | N/A |\n\n资料来源：[main.py:35-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Server Configuration\n\n### Configuration Structure\n\nThe MCP server integration uses a dictionary-based configuration passed to `MultiServerMCPClient`. Each server entry requires a transport specification and associated connection parameters.\n\n```python\nclient = MultiServerMCPClient({\n    \"server_name\": {\n        \"transport\": \"transport_type\",\n        # Transport-specific parameters\n    }\n})\n```\n\n资料来源：[main.py:29-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Supported Transport Types\n\n| Transport | Use Case | Configuration Parameters |\n|-----------|----------|-------------------------|\n| `streamable_http` | Remote cloud servers | `url` (endpoint URL) |\n| `stdio` | Local Node.js servers | `command`, `args` (executable and arguments) |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Context7 Server Configuration\n\nThe Context7 server provides LLM-optimized documentation search capabilities across major software frameworks and libraries.\n\n```python\n\"context7\": {\n    \"url\": \"https://mcp.context7.com/mcp\",\n    \"transport\": \"streamable_http\",\n}\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `context7` | Unique identifier for the server |\n| URL | `https://mcp.context7.com/mcp` | Remote HTTP endpoint |\n| Transport | `streamable_http` | HTTP-based MCP protocol |\n\n资料来源：[main.py:31-34](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### MetMuseum-MCP Server Configuration\n\nThe MetMuseum server provides access to the Metropolitan Museum of Art collection, including artwork metadata and images.\n\n```python\n\"met-museum\": {\n    \"command\": \"npx\",\n    \"args\": [\"-y\", \"metmuseum-mcp\"],\n    \"transport\": \"stdio\",\n}\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `met-museum` | Unique identifier for the server |\n| Command | `npx` | Node.js package runner |\n| Arguments | `[\"-y\", \"metmuseum-mcp\"]` | Flags and package name |\n| Transport | `stdio` | Standard input/output protocol |\n\n资料来源：[main.py:36-41](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Tool Integration\n\n### Tool Retrieval\n\nTools are retrieved asynchronously from all configured MCP servers using the `get_tools()` method. This aggregation happens at initialization time, making all tools available to the agent without manual registration.\n\n```python\ntools = await client.get_tools()\n```\n\n资料来源：[main.py:47](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Tool Selection Workflow\n\nThe ReAct agent autonomously selects the appropriate tool based on the user's query. The LLM reasoning engine analyzes the query and determines which MCP server's tools are relevant.\n\n```mermaid\ngraph TD\n    A[\"User Query\"] --> B[\"LLM Analyzes Query\"]\n    B --> C{\"Query Domain?\"}\n    C -->|Library/Code Docs| D[\"Select Context7 Tools\"]\n    C -->|Art/Museum Data| E[\"Select MetMuseum Tools\"]\n    D --> F[\"Execute Tool Call\"]\n    E --> F\n    F --> G[\"Return Result to LLM\"]\n    G --> H[\"Generate Natural Language Response\"]\n    H --> I[\"User Response + Context\"]\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Example Tool Selection Scenarios\n\n| User Query | Selected Server | Available Actions |\n|------------|-----------------|-------------------|\n| \"What is the LangChain documentation for agents?\" | Context7 | Documentation search |\n| \"Show me Van Gogh paintings in the Met Museum\" | MetMuseum | Artwork metadata retrieval |\n| \"Explain LangGraph state management\" | Context7 | Framework-specific docs |\n\n---\n\n## Agent Creation and Binding\n\n### ReAct Agent Construction\n\nThe agent is created using LangGraph's `create_react_agent` factory function, which binds the language model, tools, and checkpointer into a single executable agent instance.\n\n```python\nagent = create_react_agent(\n    model=openai_model,         # GPT-5 Nano reasoning engine\n    tools=tools,                # All tools from MCP servers\n    checkpointer=checkpointer   # Conversation memory\n)\n```\n\n资料来源：[main.py:49-53](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Parameter Specifications\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `model` | `ChatOpenAI` | GPT-5 Nano instance for reasoning |\n| `tools` | `List[BaseTool]` | Aggregated tools from all MCP servers |\n| `checkpointer` | `InMemorySaver` | Thread-based conversation persistence |\n\n---\n\n## Conversation Memory Management\n\n### Thread Configuration\n\nEach conversation session uses a unique `thread_id` to maintain context across multiple interactions. The checkpointer stores all messages in memory for the duration of the session.\n\n```python\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n资料来源：[main.py:55-56](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Memory Flow\n\n```mermaid\ngraph LR\n    A[\"User Message\"] --> B[\"Agent Processing\"]\n    B --> C[\"Tool Execution\"]\n    C --> D[\"Result Storage\"]\n    D --> E[\"InMemorySaver\"]\n    E --> F[\"Response to User\"]\n    F --> G[\"Next User Message\"]\n    G --> E\n```\n\n资料来源：[main.py:50-56](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Initialization Sequence\n\n### Async Startup Flow\n\nThe application follows a specific initialization sequence to ensure all components are properly configured before handling user queries.\n\n```mermaid\nsequenceDiagram\n    participant Main as main.py\n    participant Client as MultiServerMCPClient\n    participant LLM as ChatOpenAI\n    participant Agent as ReAct Agent\n    participant User as User\n    \n    Main->>Client: Initialize with server config\n    Main->>LLM: Create GPT-5 Nano instance\n    Main->>Client: await get_tools()\n    Client-->>Main: Return aggregated tools\n    Main->>Agent: Create with model + tools + checkpointer\n    Agent-->>Main: Agent ready\n    Main->>Agent: Send introduction message\n    Agent-->>User: Display capabilities\n    User->>Agent: Submit query\n    Agent-->>User: Return response\n```\n\n资料来源：[main.py:27-72](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Startup Steps\n\n| Step | Action | Code Reference |\n|------|--------|----------------|\n| 1 | Import dependencies | `main.py:13-18` |\n| 2 | Create MCP client | `main.py:29-42` |\n| 3 | Initialize LLM | `main.py:44-46` |\n| 4 | Retrieve tools | `main.py:47` |\n| 5 | Create checkpointer | `main.py:49` |\n| 6 | Configure thread | `main.py:55-56` |\n| 7 | Create agent | `main.py:51-53` |\n\n---\n\n## Dependencies\n\n### Required Python Packages\n\n| Package | Purpose | Import Statement |\n|---------|---------|------------------|\n| `langchain-mcp-adapters` | Multi-server MCP client | `from langchain_mcp_adapters.client import MultiServerMCPClient` |\n| `langgraph` | ReAct agent framework | `from langgraph.prebuilt import create_react_agent` |\n| `langgraph.checkpoint.memory` | Conversation memory | `from langgraph.checkpoint.memory import InMemorySaver` |\n| `langchain-openai` | OpenAI integration | `from langchain_openai import ChatOpenAI` |\n\n资料来源：[main.py:13-17](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### External Requirements\n\n| Requirement | Purpose | Version |\n|-------------|---------|---------|\n| Python | Runtime environment | 3.10+ |\n| Node.js | Required for npx command | Latest stable |\n| npx | Package runner for local MCP servers | Bundled with Node.js |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n---\n\n## Error Handling and Edge Cases\n\n### Transport-Specific Considerations\n\n| Transport | Potential Issues | Mitigation |\n|-----------|------------------|------------|\n| `streamable_http` | Network connectivity, server availability | Timeout handling, retry logic |\n| `stdio` | Node.js installation, package availability | npx `-y` flag for auto-installation |\n| Both | Server timeout | Async/await with proper exception handling |\n\n资料来源：[main.py:36-41](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n## Security Considerations\n\n### API Key Management\n\nThe integration requires an OpenAI API key for the GPT-5 Nano model. The key should be set as an environment variable rather than hardcoded in the source.\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Transport Security\n\n| Transport | Security Model |\n|-----------|----------------|\n| HTTP | Relies on HTTPS/TLS for data-in-transit encryption |\n| STDIO | Local execution with user permissions |\n\n---\n\n## Extensibility\n\n### Adding New MCP Servers\n\nTo extend the integration with additional MCP servers:\n\n1. Add server configuration to the `MultiServerMCPClient` dictionary\n2. Specify the appropriate transport type (`streamable_http` or `stdio`)\n3. Provide required connection parameters\n4. Tools will be automatically aggregated on next `get_tools()` call\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {...},\n    \"met-museum\": {...},\n    \"new_server\": {\n        \"url\": \"https://new-server.endpoint.com/mcp\",\n        \"transport\": \"streamable_http\",\n    }\n})\n```\n\n资料来源：[main.py:29-42](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n<a id='page-transport-mechanisms'></a>\n\n## Transport Mechanisms\n\n### 相关页面\n\n相关主题：[MCP Server Integration](#page-mcp-servers), [System Architecture](#page-system-architecture)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# Transport Mechanisms\n\n## Overview\n\nTransport mechanisms are the communication protocols that enable the MCP AI Agent to connect with external MCP (Model Context Protocol) servers. This project implements a **multi-transport architecture** that supports simultaneous connections to both remote and local MCP servers, allowing the agent to access diverse tools and data sources through a unified interface.\n\nThe transport layer abstracts the underlying communication details, enabling the agent to interact with different server types using a consistent tool interface while the agent reasoning engine autonomously selects the appropriate transport based on query domain.\n\n资料来源：[main.py:1-70](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Architecture\n\n### Multi-Transport Client Design\n\nThe `MultiServerMCPClient` from `langchain-mcp-adapters` serves as the central transport orchestration component. It manages concurrent connections to multiple MCP servers using different transport protocols while exposing a unified `tools` interface to the agent.\n\n```mermaid\ngraph TD\n    A[LangGraph ReAct Agent] --> B[MultiServerMCPClient]\n    B --> C[HTTP Transport Layer]\n    B --> D[STDIO Transport Layer]\n    C --> E[Context7 Server<br/>Remote/Cloud]\n    D --> F[MetMuseum-MCP<br/>Local/npx]\n    \n    style C fill:#e1f5fe\n    style D fill:#fff3e0\n```\n\n资料来源：[main.py:41-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Supported Transport Types\n\n### STDIO Transport\n\nThe STDIO (Standard Input/Output) transport is designed for local MCP servers that run as child processes on the same machine. Communication occurs through stdin and stdout streams, making it ideal for servers that are invoked via command-line tools.\n\n#### Configuration Parameters\n\n| Parameter | Type | Description | Example |\n|-----------|------|-------------|---------|\n| `command` | string | Executable command to launch the server | `\"npx\"` |\n| `args` | array | Command-line arguments passed to the executable | `[\"-y\", \"metmuseum-mcp\"]` |\n| `transport` | string | Must be set to `\"stdio\"` | `\"stdio\"` |\n\n#### Use Case\n\nThe STDIO transport is used for the **MetMuseum-MCP** server, which is executed locally via `npx`. This approach allows the agent to access over 400,000+ artworks from the Metropolitan Museum of Art collection without requiring a separate server process.\n\n资料来源：[main.py:49-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### HTTP Transport (Streamable HTTP)\n\nThe HTTP transport enables communication with remote MCP servers over HTTP/HTTPS protocols. This transport type supports cloud-based or network-accessible MCP servers that expose REST-like endpoints.\n\n#### Configuration Parameters\n\n| Parameter | Type | Description | Example |\n|-----------|------|-------------|---------|\n| `url` | string | Full URL endpoint of the MCP server | `\"https://mcp.context7.com/mcp\"` |\n| `transport` | string | Must be set to `\"streamable_http\"` | `\"streamable_http\"` |\n\n#### Use Case\n\nThe HTTP transport is used for the **Context7** server, which provides LLM-optimized documentation search across major software frameworks and libraries. This remote server is accessed via the `streamable_http` protocol for efficient streaming responses.\n\n资料来源：[main.py:45-48](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Transport Configuration\n\n### Complete Configuration Structure\n\nThe MCP client is initialized with a dictionary mapping server names to their transport configurations:\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n### Server Comparison\n\n| Attribute | Context7 | MetMuseum-MCP |\n|-----------|----------|---------------|\n| Transport Type | HTTP | STDIO |\n| Location | Remote/Cloud | Local |\n| Invocation | Direct URL | npx command |\n| Data Domain | Library documentation | Artwork/Museum data |\n| Server Process | Hosted service | Spawned child process |\n\n资料来源：[main.py:41-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Tool Aggregation\n\nThe `MultiServerMCPClient.get_tools()` method retrieves all available tools from all configured MCP servers, regardless of their transport type. This aggregation enables the LangGraph ReAct agent to have a unified toolset while each tool maintains its underlying transport implementation.\n\n```python\ntools = await client.get_tools()\n```\n\nThe aggregated tools are then passed to the LangGraph agent:\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n资料来源：[main.py:56-68](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Transport Selection Workflow\n\nThe agent autonomously determines which transport/server to use based on the user's query. The selection occurs during the LLM reasoning phase of the ReAct agent loop.\n\n```mermaid\ngraph TD\n    A[User Query] --> B[GPT-5 Nano Reasoning]\n    B --> C{Query Domain Analysis}\n    C -->|Code/Library docs| D[HTTP Transport<br/>Context7]\n    C -->|Art/Museum| E[STDIO Transport<br/>MetMuseum]\n    D --> F[Execute Tool]\n    E --> F\n    F --> G[Return Result to LLM]\n    G --> H[Generate Response]\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Error Handling Considerations\n\nWhen working with multiple transport mechanisms, consider the following potential failure points:\n\n| Transport | Potential Issues | Mitigation |\n|-----------|------------------|------------|\n| STDIO | npx not installed, package not found | Ensure Node.js and npx are available |\n| STDIO | Process spawning failures | Check system permissions and PATH |\n| HTTP | Network connectivity issues | Verify internet access and URL |\n| HTTP | Server availability | Implement retry logic if needed |\n\n资料来源：[main.py:49-54](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Dependencies\n\nThe transport mechanism implementation requires the following packages:\n\n| Package | Purpose |\n|---------|---------|\n| `langchain-mcp-adapters` | Provides `MultiServerMCPClient` for multi-transport management |\n| `langgraph` | Agent framework with tool calling support |\n| `langchain-openai` | OpenAI model integration |\n\nInstallation command:\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\nnpm install -g npx\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Extending with Additional Transports\n\nTo add support for additional MCP servers with different transport types, extend the `MultiServerMCPClient` configuration dictionary:\n\n```python\nclient = MultiServerMCPClient({\n    # Existing servers...\n    \"new-server\": {\n        # For HTTP-based servers\n        \"url\": \"https://example.com/mcp\",\n        \"transport\": \"streamable_http\",\n        \n        # OR for STDIO-based servers\n        \"command\": \"python\",\n        \"args\": [\"-m\", \"my_mcp_server\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n资料来源：[main.py:41-55](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n---\n\n<a id='page-installation'></a>\n\n## Installation Guide\n\n### 相关页面\n\n相关主题：[Configuration](#page-configuration)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n</details>\n\n# Installation Guide\n\n## Overview\n\nThis guide provides complete instructions for setting up the mcp-ai-agent project locally. The mcp-ai-agent is a multi-server Model Context Protocol (MCP) client that connects to external MCP servers (Context7 and MetMuseum) to enable an AI agent with access to library documentation and museum collections.\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Prerequisites\n\nBefore installing the mcp-ai-agent, ensure your development environment meets the following requirements:\n\n| Requirement | Minimum Version | Purpose |\n|-------------|-----------------|---------|\n| Python | 3.10+ | Runtime environment |\n| pip | Latest | Python package management |\n| Node.js | Recent | Required for npx command |\n| npx | Available | Running MetMuseum MCP server |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Project Architecture\n\nThe installation involves configuring multiple components that work together:\n\n```mermaid\ngraph TD\n    A[User Environment] --> B[Python 3.10+]\n    A --> C[Node.js + npx]\n    B --> D[mcp-ai-agent]\n    C --> E[MetMuseum-MCP Server]\n    D --> F[langchain-mcp-adapters]\n    D --> G[LangGraph]\n    D --> H[langchain-openai]\n    F --> I[MultiServerMCPClient]\n    I --> E\n    I --> J[Context7 Server<br/>Remote HTTP]\n```\n\n## Installation Steps\n\n### Step 1: Install Dependencies\n\nInstall the required Python packages using pip:\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\n```\n\nInstall npx globally for the MetMuseum MCP server:\n\n```bash\nnpm install -g npx\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Step 2: Configure Environment Variables\n\nSet your OpenAI API key as an environment variable. This key is required for the agent to communicate with OpenAI's GPT-5 Nano model:\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n**Important:** Replace `your-api-key-here` with your actual OpenAI API key.\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Step 3: Verify Installation Structure\n\nThe project has a minimal structure consisting of two files:\n\n```\nmcp-ai-agent/\n├── main.py          # Complete multi-server MCP agent\n└── README.md\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Step 4: Run the Agent\n\nExecute the main script to start the agent:\n\n```bash\npython main.py\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## MCP Server Configuration\n\nThe agent automatically configures connections to two MCP servers during initialization:\n\n### MultiServerMCPClient Setup\n\nThe configuration in `main.py` establishes connections to both servers:\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n资料来源：[main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Server Configuration Reference\n\n| Server | Transport | Connection Type | Purpose |\n|--------|-----------|-----------------|---------|\n| Context7 | streamable_http | Remote/Cloud | LLM-optimized documentation search |\n| MetMuseum | stdio | Local (npx) | Metropolitan Museum artwork access |\n\n## Required Python Packages\n\n| Package | Version | Role |\n|---------|---------|------|\n| langchain-mcp-adapters | Latest | MCP client for multi-server connections |\n| langgraph | Latest | ReAct agent framework |\n| langchain-openai | Latest | OpenAI GPT model integration |\n\n资料来源：[main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Post-Installation Verification\n\nAfter installation, the agent will:\n\n1. Display an introduction message\n2. Show available tools from connected MCP servers\n3. Present an interactive menu\n\nExpected output:\n\n```\nAgent introduces itself and available tools...\n\nMenu:\n1. Ask the agent a question\n2. Quit\nEnter your choice (1 or 2):\n```\n\n## Troubleshooting\n\n### Common Issues\n\n| Issue | Solution |\n|-------|----------|\n| Missing OPENAI_API_KEY | Ensure the environment variable is set before running |\n| npx not found | Install Node.js or run `npm install -g npx` |\n| MCP server connection failure | Check internet connection for Context7; verify npx works locally |\n| Import errors | Reinstall Python packages with `pip install --upgrade` |\n\n### Verification Commands\n\nTest your installation by checking each component:\n\n```bash\n# Verify Python packages\npython -c \"import langchain_mcp_adapters; import langgraph; import langchain_openai\"\n\n# Verify npx is available\nnpx --version\n\n# Verify Python version\npython --version\n```\n\n## Project Dependencies Flow\n\n```mermaid\ngraph LR\n    A[main.py] --> B[langchain_mcp_adapters<br/>MultiServerMCPClient]\n    A --> C[langgraph<br/>create_react_agent]\n    A --> D[langchain_openai<br/>ChatOpenAI]\n    A --> E[langgraph.checkpoint.memory<br/>InMemorySaver]\n    B --> F[Context7 MCP]\n    B --> G[MetMuseum MCP]\n```\n\n资料来源：[main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Next Steps\n\nAfter successful installation, refer to the following:\n\n1. **Usage Guide** - How to interact with the agent\n2. **Architecture Overview** - Understanding the multi-server MCP client design\n3. **MCP Server Documentation** - Details on Context7 and MetMuseum capabilities\n\n## System Requirements Summary\n\n| Component | Specification |\n|-----------|---------------|\n| OS | Cross-platform (Windows, macOS, Linux) |\n| Memory | 4GB minimum recommended |\n| Disk Space | 500MB for dependencies |\n| Network | Required for Context7 server and OpenAI API access |\n\n---\n\n<a id='page-configuration'></a>\n\n## Configuration\n\n### 相关页面\n\n相关主题：[Installation Guide](#page-installation)\n\n<details>\n<summary>相关源码文件</summary>\n\n以下源码文件用于生成本页说明：\n\n- [main.py](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n- [README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n</details>\n\n# Configuration\n\nThis document describes the configuration system for the mcp-ai-agent project, covering all configurable components including MCP servers, language models, memory systems, and agent behavior.\n\n## Overview\n\nThe mcp-ai-agent uses a multi-server Model Context Protocol (MCP) architecture that requires configuration for:\n\n- MCP server connections (transport protocols, endpoints)\n- Language model integration (OpenAI API)\n- Conversation memory persistence\n- Agent execution parameters\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## MCP Server Configuration\n\nThe agent connects to multiple MCP servers simultaneously using the `MultiServerMCPClient` from `langchain-mcp-adapters`. Each server defines its own transport protocol and connection parameters.\n\n资料来源：[main.py:26-40](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Configuration Structure\n\n```python\nclient = MultiServerMCPClient({\n    \"context7\": {\n        \"url\": \"https://mcp.context7.com/mcp\",\n        \"transport\": \"streamable_http\",\n    },\n    \"met-museum\": {\n        \"command\": \"npx\",\n        \"args\": [\"-y\", \"metmuseum-mcp\"],\n        \"transport\": \"stdio\",\n    }\n})\n```\n\n### Supported Transport Protocols\n\n| Transport | Use Case | Configuration Required |\n|-----------|----------|------------------------|\n| `streamable_http` | Remote/cloud servers | `url` endpoint |\n| `stdio` | Local/npx-based servers | `command` and `args` |\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n### Context7 Server Configuration\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `context7` | Identifier for the MCP server |\n| URL | `https://mcp.context7.com/mcp` | Remote endpoint for library documentation |\n| Transport | `streamable_http` | HTTP-based streaming protocol |\n| Capabilities | LLM-optimized docs search across major frameworks | Provides access to code library documentation |\n\n资料来源：[main.py:28-30](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### MetMuseum Server Configuration\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Server Name | `met-museum` | Identifier for the MCP server |\n| Command | `npx` | Node.js package runner |\n| Args | `[\"-y\", \"metmuseum-mcp\"]` | Auto-install and execute the museum MCP package |\n| Transport | `stdio` | Standard input/output communication |\n| Capabilities | Access to 400,000+ Metropolitan Museum artworks | Provides art collection metadata and images |\n\n资料来源：[main.py:31-35](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Language Model Configuration\n\nThe agent uses OpenAI's GPT-5 Nano model for reasoning and natural language generation.\n\n### OpenAI Model Initialization\n\n```python\nopenai_model = ChatOpenAI(\n    model=\"gpt-5-nano\",\n)\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Model | `gpt-5-nano` | OpenAI's lightweight reasoning engine |\n| Integration | `langchain_openai.ChatOpenAI` | LangChain wrapper for OpenAI API |\n\n资料来源：[main.py:42-44](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### API Key Configuration\n\nThe OpenAI API key must be set as an environment variable before running the agent:\n\n```bash\nexport OPENAI_API_KEY=\"your-api-key-here\"\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Memory Configuration\n\nThe agent implements persistent conversation memory using LangGraph's `InMemorySaver` checkpointer.\n\n### Checkpointer Setup\n\n```python\ncheckpointer = InMemorySaver()\n```\n\n| Component | Class | Purpose |\n|-----------|-------|---------|\n| Memory | `InMemorySaver` | Stores conversation history in memory |\n| Persistence | Thread-based | Messages grouped by `thread_id` |\n\n资料来源：[main.py:47-48](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n### Thread Configuration\n\n```python\nconfig = {\"configurable\": {\"thread_id\": \"conversation_id\"}}\n```\n\n| Parameter | Value | Description |\n|-----------|-------|-------------|\n| Thread ID | `\"conversation_id\"` | Groups all messages in the current session |\n| Scope | Session-level | Maintains context across all agent interactions |\n\n资料来源：[main.py:50-51](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Agent Configuration\n\nThe ReAct (Reasoning + Acting) agent is created using LangGraph's `create_react_agent` factory function.\n\n### Agent Creation\n\n```python\nagent = create_react_agent(\n    model=openai_model,\n    tools=tools,\n    checkpointer=checkpointer\n)\n```\n\n| Parameter | Source | Description |\n|-----------|--------|-------------|\n| `model` | `ChatOpenAI` instance | GPT-5 Nano for reasoning |\n| `tools` | `MultiServerMCPClient.get_tools()` | All tools from both MCP servers |\n| `checkpointer` | `InMemorySaver` instance | Conversation memory |\n\n资料来源：[main.py:53-57](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## System Prompt Configuration\n\nThe agent's behavior is defined through a system message passed during the initial invocation.\n\n### Default System Message\n\n```python\n{\"role\": \"system\", \"content\": \"You are a smart, useful agent with tools to access code library documentation and the Met Museum collection.\"}\n```\n\n| Field | Value | Purpose |\n|-------|-------|---------|\n| Role | `system` | Defines agent persona |\n| Content | Agent description | Instructs agent about available capabilities |\n\n资料来源：[main.py:67](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Configuration Flow\n\n```mermaid\ngraph TD\n    A[Configuration Start] --> B[MCP Server Config]\n    B --> C[MultiServerMCPClient]\n    C --> D[Context7 HTTP]\n    C --> E[MetMuseum STDIO]\n    D --> F[Get Tools]\n    E --> F\n    F --> G[LLM Config]\n    G --> H[ChatOpenAI gpt-5-nano]\n    H --> I[Memory Config]\n    I --> J[InMemorySaver]\n    J --> K[Agent Config]\n    K --> L[create_react_agent]\n    L --> M[Ready for Invocation]\n```\n\n## Runtime Configuration\n\n### Asynchronous Execution\n\nThe application runs using Python's `asyncio` event loop:\n\n```python\nasync def main():\n    # All configuration and agent operations\n    pass\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n```\n\n### Agent Invocation\n\nEach user interaction passes through the configured thread:\n\n```python\nresponse = await agent.ainvoke(\n    {\"messages\": query},\n    config=config  # Contains thread_id for memory persistence\n)\n```\n\n资料来源：[main.py:80-87](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/main.py)\n\n## Configuration Dependencies\n\n```mermaid\ngraph LR\n    A[main.py] --> B[langchain_mcp_adapters.client]\n    A --> C[langgraph.prebuilt]\n    A --> D[langgraph.checkpoint.memory]\n    A --> E[langchain_openai]\n    B --> F[MultiServerMCPClient]\n    C --> G[create_react_agent]\n    D --> H[InMemorySaver]\n    E --> I[ChatOpenAI]\n```\n\n## Environment Requirements\n\n| Requirement | Version | Purpose |\n|-------------|---------|---------|\n| Python | 3.10+ | Runtime environment |\n| Node.js/npx | Latest | Required for MetMuseum STDIO server |\n| OpenAI API Key | Valid key | LLM access |\n\n### Required Python Packages\n\n```bash\npip install langchain-mcp-adapters langgraph langchain-openai\n```\n\n### Required npm Packages\n\n```bash\nnpm install -g npx\n```\n\n资料来源：[README.md](https://github.com/LeelaissakAttota/mcp-ai-agent/blob/main/README.md)\n\n## Configuration Summary Table\n\n| Component | Class/Function | Key Parameter | Location |\n|-----------|----------------|---------------|----------|\n| MCP Client | `MultiServerMCPClient` | Transport definitions | main.py:26-40 |\n| Context7 | HTTP config | URL endpoint | main.py:28-30 |\n| MetMuseum | STDIO config | npx command | main.py:31-35 |\n| LLM | `ChatOpenAI` | model=\"gpt-5-nano\" | main.py:42-44 |\n| Memory | `InMemorySaver` | In-memory storage | main.py:47-48 |\n| Thread | Dict config | thread_id | main.py:50-51 |\n| Agent | `create_react_agent` | model + tools + checkpointer | main.py:53-57 |\n\n## See Also\n\n- [Installation Guide](README.md#-how-to-run) - Setup instructions\n- [Architecture Overview](README.md#-architecture) - System design\n- [MCP Servers](README.md#-integrated-mcp-servers) - Available tool providers\n\n---\n\n---\n\n## Doramagic 踩坑日志\n\n项目：LeelaissakAttota/mcp-ai-agent\n\n摘要：发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：身份坑 - 仓库名和安装名不一致。\n\n## 1. 身份坑 · 仓库名和安装名不一致\n\n- 严重度：medium\n- 证据强度：runtime_trace\n- 发现：仓库名 `mcp-ai-agent` 与安装入口 `metmuseum-mcp` 不完全一致。\n- 对用户的影响：用户照着仓库名搜索包或照着包名找仓库时容易走错入口。\n- 建议检查：在 npm/PyPI/GitHub 上确认包名映射和官方 README 说明。\n- 复现命令：`npx metmuseum-mcp`\n- 防护动作：页面必须同时展示 repo 名和真实安装入口，避免用户搜索错包。\n- 证据：identity.distribution | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | repo=mcp-ai-agent; install=metmuseum-mcp\n\n## 2. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | README/documentation is current enough for a first validation pass.\n\n## 3. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | last_activity_observed missing\n\n## 4. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n\n## 5. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n\n## 6. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | issue_or_pr_quality=unknown\n\n## 7. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | release_recency=unknown\n\n<!-- canonical_name: LeelaissakAttota/mcp-ai-agent; human_manual_source: deepwiki_human_wiki -->\n",
      "summary": "DeepWiki/Human Wiki 完整输出，末尾追加 Discovery Agent 踩坑日志。",
      "title": "Human Manual / 人类版说明书"
    },
    "pitfall_log": {
      "asset_id": "pitfall_log",
      "filename": "PITFALL_LOG.md",
      "markdown": "# Pitfall Log / 踩坑日志\n\n项目：LeelaissakAttota/mcp-ai-agent\n\n摘要：发现 7 个潜在踩坑项，其中 0 个为 high/blocking；最高优先级：身份坑 - 仓库名和安装名不一致。\n\n## 1. 身份坑 · 仓库名和安装名不一致\n\n- 严重度：medium\n- 证据强度：runtime_trace\n- 发现：仓库名 `mcp-ai-agent` 与安装入口 `metmuseum-mcp` 不完全一致。\n- 对用户的影响：用户照着仓库名搜索包或照着包名找仓库时容易走错入口。\n- 建议检查：在 npm/PyPI/GitHub 上确认包名映射和官方 README 说明。\n- 复现命令：`npx metmuseum-mcp`\n- 防护动作：页面必须同时展示 repo 名和真实安装入口，避免用户搜索错包。\n- 证据：identity.distribution | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | repo=mcp-ai-agent; install=metmuseum-mcp\n\n## 2. 能力坑 · 能力判断依赖假设\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：README/documentation is current enough for a first validation pass.\n- 对用户的影响：假设不成立时，用户拿不到承诺的能力。\n- 建议检查：将假设转成下游验证清单。\n- 防护动作：假设必须转成验证项；没有验证结果前不能写成事实。\n- 证据：capability.assumptions | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | README/documentation is current enough for a first validation pass.\n\n## 3. 维护坑 · 维护活跃度未知\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：未记录 last_activity_observed。\n- 对用户的影响：新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。\n- 建议检查：补 GitHub 最近 commit、release、issue/PR 响应信号。\n- 防护动作：维护活跃度未知时，推荐强度不能标为高信任。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | last_activity_observed missing\n\n## 4. 安全/权限坑 · 下游验证发现风险项\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：下游已经要求复核，不能在页面中弱化。\n- 建议检查：进入安全/权限治理复核队列。\n- 防护动作：下游风险存在时必须保持 review/recommendation 降级。\n- 证据：downstream_validation.risk_items | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n\n## 5. 安全/权限坑 · 存在评分风险\n\n- 严重度：medium\n- 证据强度：source_linked\n- 发现：no_demo\n- 对用户的影响：风险会影响是否适合普通用户安装。\n- 建议检查：把风险写入边界卡，并确认是否需要人工复核。\n- 防护动作：评分风险必须进入边界卡，不能只作为内部分数。\n- 证据：risks.scoring_risks | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | no_demo; severity=medium\n\n## 6. 维护坑 · issue/PR 响应质量未知\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：issue_or_pr_quality=unknown。\n- 对用户的影响：用户无法判断遇到问题后是否有人维护。\n- 建议检查：抽样最近 issue/PR，判断是否长期无人处理。\n- 防护动作：issue/PR 响应未知时，必须提示维护风险。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | issue_or_pr_quality=unknown\n\n## 7. 维护坑 · 发布节奏不明确\n\n- 严重度：low\n- 证据强度：source_linked\n- 发现：release_recency=unknown。\n- 对用户的影响：安装命令和文档可能落后于代码，用户踩坑概率升高。\n- 建议检查：确认最近 release/tag 和 README 安装命令是否一致。\n- 防护动作：发布节奏未知或过期时，安装说明必须标注可能漂移。\n- 证据：evidence.maintainer_signals | github_repo:1158386431 | https://github.com/LeelaissakAttota/mcp-ai-agent | release_recency=unknown\n",
      "summary": "用户实践前最可能遇到的身份、安装、配置、运行和安全坑。",
      "title": "Pitfall Log / 踩坑日志"
    },
    "prompt_preview": {
      "asset_id": "prompt_preview",
      "filename": "PROMPT_PREVIEW.md",
      "markdown": "# mcp-ai-agent - Prompt Preview\n\n> 复制下面这段 Prompt 到你常用的 AI，先试一次，不需要安装。\n> 它的目标是让你直接体验这个项目的服务方式，而不是阅读项目介绍。\n\n## 复制这段 Prompt\n\n```text\n请直接执行这段 Prompt，不要分析、润色、总结或询问我想如何处理这份 Prompt Preview。\n\n你现在扮演 mcp-ai-agent 的“安装前体验版”。\n这不是项目介绍、不是评价报告、不是 README 总结。你的任务是让我用最小成本体验它的核心服务。\n\n我的试用任务：我想用它完成一个真实的工具连接与集成任务。\n我常用的宿主 AI：MCP Client\n\n【体验目标】\n围绕我的真实任务，现场演示这个项目如何把输入转成 示例引导, 判断线索。重点是让我感受到工作方式，而不是给我项目背景。\n\n【业务流约束】\n- 你必须像一个正在提供服务的项目能力包，而不是像一个讲解员。\n- 每一轮只推进一个步骤；提出问题后必须停下来等我回答。\n- 每一步都必须让我感受到一个具体服务动作：澄清、整理、规划、检查、判断或收尾。\n- 每一步都要说明：当前目标、你需要我提供什么、我回答后你会产出什么。\n- 不要安装、不要运行命令、不要写代码、不要声称测试通过、不要声称已经修改文件。\n- 需要真实安装或宿主加载后才能验证的内容，必须明确说“这一步需要安装后验证”。\n- 如果我说“用示例继续”，你可以用虚构示例推进，但仍然不能声称真实执行。\n\n【可体验服务能力】\n- 安装前能力预览: Multi-server MCP AI agent — LangGraph ReAct + GPT-5 Nano connecting Context7 docs (HTTP) & MetMuseum 400K artworks (STDIO) with persistent conversation memory 输入：用户任务, 当前 AI 对话上下文；输出：示例引导, 判断线索。\n\n【必须安装后才可验证的能力】\n- 命令行启动或安装流程: 项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 输入：终端环境, 包管理器, 项目依赖；输出：安装结果, 列表/更新/运行结果。\n\n【核心服务流】\n请严格按这个顺序带我体验。不要一次性输出完整流程：\n1. page-project-introduction：Project Introduction。围绕“Project Introduction”模拟一次用户任务，不展示安装或运行结果。\n2. page-tech-stack：Technology Stack。围绕“Technology Stack”模拟一次用户任务，不展示安装或运行结果。\n3. page-system-architecture：System Architecture。围绕“System Architecture”模拟一次用户任务，不展示安装或运行结果。\n4. page-agent-workflow：Agent Workflow。围绕“Agent Workflow”模拟一次用户任务，不展示安装或运行结果。\n5. page-langgraph-react-agent：LangGraph ReAct Agent。围绕“LangGraph ReAct Agent”模拟一次用户任务，不展示安装或运行结果。\n\n【核心能力体验剧本】\n每一步都必须按“输入 -> 服务动作 -> 中间产物”执行。不要只说流程名：\n1. page-project-introduction\n输入：用户提供的“Project Introduction”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n2. page-tech-stack\n输入：用户提供的“Technology Stack”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n3. page-system-architecture\n输入：用户提供的“System Architecture”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n4. page-agent-workflow\n输入：用户提供的“Agent Workflow”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n5. page-langgraph-react-agent\n输入：用户提供的“LangGraph ReAct Agent”相关信息。\n服务动作：模拟项目在这一步的核心判断和整理方式。\n中间产物：一个可检查的小结果。\n\n【项目服务规则】\n这些规则决定你如何服务用户。不要解释规则本身，而要在每一步执行时遵守：\n- 先确认用户任务、输入材料和成功标准，再模拟项目能力。\n- 每一步都必须形成可检查的小产物，并等待用户确认后再继续。\n- 凡是需要安装、调用工具或访问外部服务的能力，都必须标记为安装后验证。\n\n【每一步的服务约束】\n- Step 1 / page-project-introduction：Step 1 必须围绕“Project Introduction”形成一个小中间产物，并等待用户确认。\n- Step 2 / page-tech-stack：Step 2 必须围绕“Technology Stack”形成一个小中间产物，并等待用户确认。\n- Step 3 / page-system-architecture：Step 3 必须围绕“System Architecture”形成一个小中间产物，并等待用户确认。\n- Step 4 / page-agent-workflow：Step 4 必须围绕“Agent Workflow”形成一个小中间产物，并等待用户确认。\n- Step 5 / page-langgraph-react-agent：Step 5 必须围绕“LangGraph ReAct Agent”形成一个小中间产物，并等待用户确认。\n\n【边界与风险】\n- 不要声称已经安装、运行、调用 API、读写本地文件或完成真实任务。\n- 安装前预览只能展示工作方式，不能证明兼容性、性能或输出质量。\n- 涉及安装、插件加载、工具调用或外部服务的能力必须安装后验证。\n\n【可追溯依据】\n这些路径只用于你内部校验或在我追问“依据是什么”时简要引用。不要在首次回复主动展开：\n- https://github.com/LeelaissakAttota/mcp-ai-agent\n- https://github.com/LeelaissakAttota/mcp-ai-agent#readme\n- README.md\n- main.py\n\n【首次问题规则】\n- 首次三问必须先确认用户目标、成功标准和边界，不要提前进入工具、安装或实现细节。\n- 如果后续需要技术条件、文件路径或运行环境，必须等用户确认目标后再追问。\n\n首次回复必须只输出下面 4 个部分：\n1. 体验开始：用 1 句话说明你将带我体验 mcp-ai-agent 的核心服务。\n2. 当前步骤：明确进入 Step 1，并说明这一步要解决什么。\n3. 你会如何服务我：说明你会先改变我完成任务的哪个动作。\n4. 只问我 3 个问题，然后停下等待回答。\n\n首次回复禁止输出：后续完整流程、证据清单、安装命令、项目评价、营销文案、已经安装或运行的说法。\n\nStep 1 / brainstorming 的二轮协议：\n- 我回答首次三问后，你仍然停留在 Step 1 / brainstorming，不要进入 Step 2。\n- 第二次回复必须产出 6 个部分：澄清后的任务定义、成功标准、边界条件、\n  2-3 个可选方案、每个方案的权衡、推荐方案。\n- 第二次回复最后必须问我是否确认推荐方案；只有我明确确认后，才能进入下一步。\n- 第二次回复禁止输出 git worktree、代码计划、测试文件、命令或真实执行结果。\n\n后续对话规则：\n- 我回答后，你先完成当前步骤的中间产物并等待确认；只有我确认后，才能进入下一步。\n- 每一步都要生成一个小的中间产物，例如澄清后的目标、计划草案、测试意图、验证清单或继续/停止判断。\n- 所有演示都写成“我会建议/我会引导/这一步会形成”，不要写成已经真实执行。\n- 不要声称已经测试通过、文件已修改、命令已运行或结果已产生。\n- 如果某个能力必须安装后验证，请直接说“这一步需要安装后验证”。\n- 如果证据不足，请明确说“证据不足”，不要补事实。\n```\n",
      "summary": "不安装项目也能感受能力节奏的安全试用 Prompt。",
      "title": "Prompt Preview / 安装前试用 Prompt"
    },
    "quick_start": {
      "asset_id": "quick_start",
      "filename": "QUICK_START.md",
      "markdown": "# Quick Start / 官方入口\n\n项目：LeelaissakAttota/mcp-ai-agent\n\n## 官方安装入口\n\n### Node.js / npx · 官方安装入口\n\n```bash\nnpx metmuseum-mcp\n```\n\n来源：https://github.com/LeelaissakAttota/mcp-ai-agent#readme\n\n## 来源\n\n- repo: https://github.com/LeelaissakAttota/mcp-ai-agent\n- docs: https://github.com/LeelaissakAttota/mcp-ai-agent#readme\n",
      "summary": "从项目官方 README 或安装文档提取的开工入口。",
      "title": "Quick Start / 官方入口"
    }
  },
  "validation_id": "dval_f6686d472c4548ada16c6e08363cb8f5"
}
