Token导航 LogoToken导航TokenDH.com
Run Existing MCP Servers logo
AI代理stdio官方级别未说明来源级核验

Run Existing MCP Servers

MCP Server

一个演示如何通过STDIO和Streamable HTTP协议连接Python应用到MCP服务器的项目,主要用于实时获取库文档以支持AI编码助手。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
Jupyter NotebookHTTP传输AI代理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

LeelaissakAttota

提供方

LeelaissakAttota

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install fastmcp

详细介绍

🌐 运行现有MCP服务器:STDIO和HTTP协议

Language Framework Protocol Transport Server Focus Status

______________________________________________________________________

📌 项目概述

这个项目是 深入了解MCP传输协议 — 演示如何将Python应用程序连接到现实世界的MCP服务器 两者都使用 工作室流式HTTP 传输层。

使用 Context7 MCP服务器,该项目显示了LLM如何检索 库的最新编码文档,如 fastmcp, pandas, 和 scikit-learn --使AI编码助手真正成为最新的。

域名: 代理AI——MCP传输协议\ 语言: Python 3.12+\ MCP服务器: Context7(LLM的实时库文档)\ 运输: STDIO (npx)+可流式传输HTTP

______________________________________________________________________

🏗️ 建筑

┌──────────────────────────────────────────────────────┐
│         Python Client / Jupyter Notebook             │
│                                                      │
│  from fastmcp import Client                          │
│  from fastmcp.client.transports import               │
│       StdioTransport, StreamableHttpTransport        │
└──────────┬─────────────────────────┬────────────────┘
           │                         │
    STDIO Transport          HTTP Transport
    (Local subprocess)       (Remote cloud)
           │                         │
    ┌──────▼──────┐         ┌────────▼────────┐
    │  npx runs   │         │  Context7 Cloud  │
    │  Context7   │         │  MCP Server      │
    │  on your    │         │  mcp.context7.   │
    │  machine    │         │  com/mcp         │
    └─────────────┘         └─────────────────┘
           │                         │
    Both expose identical MCP tools:
    ├── resolve-library-id   → Find library ID
    └── query-docs           → Get LLM-ready docs

______________________________________________________________________

📂 项目结构

Run-Existing-MCP-Servers/
│
├── Run Existing MCP Servers.ipynb   # Complete Jupyter lab notebook
└── README.md

______________________________________________________________________

🛠️ 技术栈

组件技术
语言Python 3.12+
MCP客户端FastMCP客户端
STDIO传输标准传输(npx @upstash/context7-mcp)
HTTP传输流式HttpTransport
外部服务器Context7 MCP服务器
笔记本Jupyter
async异步+异步/等待

______________________________________________________________________

🔌 传输协议详解

1.️⃣ STDIO运输(本地)

一切都在你的机器上运行:

stdio_transport = StdioTransport(
    command="npx",
    args=["-y", "@upstash/context7-mcp"]
)
stdio_client = Client(stdio_transport)
Your Python Code ←→ [StdioTransport] ←→ Context7 Server (your machine)
   (Client)              (Bridge)          (npx subprocess)

它是如何工作的:

  • npx 临时下载并运行Context7 MCP服务器
  • StdioTransport 桥接Python↔ 通过STDIN/STDOUT连接服务器
  • 一切都是本地的,不需要网络

______________________________________________________________________

2.️⃣ 流式HTTP传输(远程)

连接到云托管的MCP服务器:

http_transport = StreamableHttpTransport(
    url="https://mcp.context7.com/mcp"
)
http_client = Client(http_transport)
Your Python Code ←→ [StreamableHttpTransport] ←→ Context7 Cloud Server
   (Client)                 (Bridge)              (mcp.context7.com)

______________________________________________________________________

🔧 Context7 MCP工具

工具输入输出
resolve-library-idlibraryName: str, query: strContext7库ID(例如。 /pandas-dev/pandas)
query-docslibraryId: str, query: strLLM优化文档、代码示例、API参考文献

工具调用模式

# Step 1 — Find library ID
async with stdio_client as client:
    response = await client.call_tool("resolve-library-id", {
        "libraryName": "fastmcp",
        "query": "I want to create a new MCP server"
    })
library_id = response.content[0].text

# Step 2 — Get documentation
async with stdio_client as client:
    docs = await client.call_tool("query-docs", {
        "libraryId": library_id,
        "query": "How to create tools in FastMCP"
    })

______________________________________________________________________

📚 这个实验室涵盖了什么

主题详细信息
STDIO概念STDIN、STDOUT、STDERR——理论+实例
StdioTransport通过npx将MCP服务器作为子流程启动
StreamableHttpTransport连接到远程云MCP服务器
FastMCP客户端异步上下文管理器模式
list_tools()从服务器发现可用工具
call_tool()使用参数执行工具
工具检查访问 .name, .description, .inputSchema
Context7工作流解析库id→ 查询文档模式
查询库fastmcp、pandas、scikit-learn
异步模式async with, await,非阻塞请求

______________________________________________________________________

⚙️ 如何跑步

步骤1——安装依赖项:

pip install fastmcp
npm install -g npx   # For STDIO transport

步骤2——打开Jupyter笔记本:

jupyter notebook "Run Existing MCP Servers.ipynb"

步骤3——按顺序运行单元格:

  • STDIO部分→ 通过本地子进程连接
  • HTTP部分→ 通过云端点连接
  • 工具列表→ 请参阅可用的Context7工具
  • 工具调用→ 获取实时图书馆文档

______________________________________________________________________

🔑 关键概念——相同的接口,不同的传输

# STDIO — local process
async with Client(StdioTransport("npx", ["-y", "@upstash/context7-mcp"])) as client:
    tools = await client.list_tools()   # Identical API!

# HTTP — remote cloud
async with Client(StreamableHttpTransport("https://mcp.context7.com/mcp")) as client:
    tools = await client.list_tools()   # Same API!

一旦连接,无论传输方式如何,MCP接口都是相同的!

______________________________________________________________________

🎓 技能展示

  • MCP传输协议比较——STDIO与HTTP
  • 具有异步上下文管理器模式的FastMCP客户端
  • StdioTransport——基于子流程的MCP服务器启动
  • StreamableHttpTransport——远程云MCP连接
  • 工具发现 list_tools()
  • 工具执行 call_tool() +参数
  • 工具模式检查(名称、描述、inputSchema)
  • Context7两步文档工作流程
  • 面向LLM的实时图书馆文献检索
  • STDIO基础——STDIN、STDOUT、STDERR
  • 异步Python——异步、等待、非阻塞I/O
  • 基于Jupyter笔记本的MCP开发

______________________________________________________________________

📜 认证

认证发卡机构平台
IBM数据科学专业证书IBMCoursera
IBM生成人工智能专业证书IBMCoursera
IBM RAG和代理人工智能专业证书IBMCoursera

______________________________________________________________________

🤝 与我联系

![LinkedIn](https://www.linkedin.com/in/leela-a) ![Gmail](mailto:attotaleelaissak@gmail.com) ](https://github.com/Leelaissakattaota)

目录标签

目录标签

Jupyter NotebookHTTP传输AI代理混合部署MCP协议Python应用STDIO传输AI编码助手

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP