Model Context Protocol (MCP)

MCP其他

提供方 PouyaEsmaeili

其他 未标注 会话登录 社区 / 第三方 ClaudeCursorCodexZed

Model Context Protocol (MCP)

一句话选型结论

按资料字段整理

Model Context Protocol (MCP) 属于其他类 MCP 服务器,传输方式未标注,会话登录,可直接接入 Claude、Cursor、Codex 等,没有现成安装命令,需按官方文档接入。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类其他 传输方式未标注 鉴权会话登录 部署方式未标注
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

其他
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

mcpai agentmcp server

安装与配置

未标注 会话登录
上游未给出传输方式
  1. 1
    准备运行环境

    按官方文档确认运行环境(常见为 Node.js 或 Python),装好后再执行安装命令。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
接入外部数据

把外部系统的数据接进对话。

自动化重复操作

把固定步骤交给模型跑。

补充工具能力

给模型补上它原本没有的能力。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 已适配 Claude、Cursor、Codex,换客户端不用重新研究配置。

先想清楚的地方

  • 没有现成安装命令,需要按官方文档自己填启动命令和参数。
  • 使用前要准备好会话登录对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在其他场景里让模型直接调用外部能力的人。
  • 已经在用 Claude、Cursor 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Model Context Protocol (MCP)当前 未标注 未标注 未标注 无 未标注
gemini-cli 未标注 stdio · 本地进程 本地部署 有 2026-04-13
ext-apps 未标注 stdio · 本地进程 本地部署 有 2026-04-19
northcinder 未标注 stdio · 本地进程 本地部署 有 2026-08-23
fastctx 未标注 stdio · 本地进程 本地部署 有 2026-08-23
quickstart-resources 未标注 stdio · 本地进程 本地部署 有 2026-04-12

服务器档案

其他
字段来自项目仓库与公开索引,中文说明由本站标注
提供方PouyaEsmaeili上游标注的维护方 PouyaEsmaeili
分类其他本站按上游分类展示
连接方式未标注上游未给出传输方式
鉴权方式会话登录远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · python本地安装时用到的包标识与运行时
部署类型未标注上游给出的部署形态
最近核验未标注上游最后核验时间

详细介绍

9.8 KB
来自项目仓库与上游目录的原文,未做删改

Model Context Protocol (MCP)

Model Context Protocol (MCP) is a protocol designed to establish a communication channel between large language models (LLMs) and external tools or data sources. It follows a client-server architecture and uses JSON-RPC 2.0 for messaging.
Although MCP was introduced only a few months ago by Anthropic, it has quickly gained significant attention in the AI community.
In the sections below, I’ll explain the MCP specification and provide some Python examples.


MCP Server

An MCP server provides three key capabilities to the client:

Capability Description
Tool A function or service that performs logic (e.g., a calculator), triggers side effects (e.g., modifies the environment), or is CPU-bound.
Resource Any type of data such as images, files, etc.
Prompt A prompt template that can be used by the client.

An MCP server can be implemented using either FastMCP or Low-Level APIs.
It supports communication via SSE over HTTP (Server-Sent Events) or stdin.
Use stdin for local communication and SSE for network-based communication.
Type of communication is called Transport Layer in MCP specification.

FastMCP

Suppose we want to implement an MCP server for an English teaching application based on a LLM.
This MCP server will provide an assessment quiz (Resource), a triage function to determine the learner's level (Tool), and a prompt template (Prompt).```python
from mcp.server.fastmcp import FastMCP

You can customize important parameters by passing them to FastMCP.

In this example, all key parameters are set to their default values,

but you can modify them according to your needs.

sse_url = http://0.0.0.0:8000/sse

mcp = FastMCP(
name="MCPServer",
debug=True,
host="0.0.0.0",
port=8000,
sse_path="/sse",
message_path="/messages/",
log_level="DEBUG",
)

@mcp.resource(
uri="https://quiz.xyz",
name="GetQuiz",
description="Provides a link to an online English level assessment quiz.",
)
def get_quiz() -> str:
return "Link to online quiz: https://quiz.xyz"

@mcp.tool(
name="FindLevel",
description="Determines the student's English level based on their quiz score.",
)
def find_level(grade: int) -> str:
if grade < 50:
return "Beginner"
if grade < 75:
return "Intermediate"
return "Expert"

@mcp.prompt(
name="GetPrompt",
description="Generates a prompt to ask an LLM to teach English based on the student's level.",
)
def get_prompt(name: str, level: str) -> str:
return f"Teach {name} English based on this level: {level}."


There are different ways to serve FastMCP over SSE: `sse_app`, `run_sse_async` or `run`.
In the first approach, you use a ASGI framework (e.x. Starlette).
The second approach utilizes Python&#x27;s asyncio.
And the third approach is a mcp&#x27;s instance built-in function which utilizes `run_sse_async` under the hood.```python
from starlette.applications import Starlette
from starlette.routing import Mount
import uvicorn

if __name__ == &quot;__main__&quot;:
    app = Starlette(debug=True, routes=[
        Mount(&quot;/&quot;, mcp.sse_app()),
    ])
    uvicorn.run(app)
``````python
import asyncio

async def main():
    await mcp.run_sse_async()

if __name__ == &quot;__main__&quot;:
    asyncio.run(main())
``````python
# Pass transport=stdio for stdio server
if __name__ == &quot;__main__&quot;:
    mcp.run(transport=&quot;sse&quot;)

Low Level APIs

Implementing a server using low level APIs takes much time.
You have to instantiate Server class and implement a bunch of methods to list and call all the capabilities.
There is a detailed guide on how to do this in mcp python-sdk's official repo here.


MCP Client

Based on how server is exposed there two ways to implement client: sdio-client and sse-client.

SSE Client

Set transport to sse in fastmcp-server.py.```python
import asyncio
import logging
from typing import Union
from urllib.parse import urlparse

from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream

import mcp.types as types
from mcp.client.session import ClientSession
from mcp.client.sse import sse_client
from mcp.shared.session import RequestResponder

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("client")

async def message_handler(
message: Union[
RequestResponder[types.ServerRequest, types.ClientResult],
types.ServerNotification,
Exception,
],
) -> None:
if isinstance(message, Exception):
logger.error("Error: %s", message)
return
logger.info("Received message from server: %s", message)

async def run_session(
read_stream: MemoryObjectReceiveStream,
write_stream: MemoryObjectSendStream,
) -> None:
async with ClientSession(
read_stream,
write_stream,
message_handler=message_handler,
) as session:
initialize_response = await session.initialize()
logger.info(f"Initialized response: {initialize_response}")
tools = await session.list_tools()
tools = tools.tools
logger.info(f"List of tools: {[tool.name for tool in tools]}")
response = await session.call_tool("FindLevel", {"grade": 86})
logger.info(f"Find level response: {response}")

async def main(command_or_url: str) -> None:
if urlparse(command_or_url).scheme in ("http", "https"):
async with sse_client(command_or_url) as streams:
await run_session(*streams)

if name == "main":
sse_url = "http://0.0.0.0:8000/sse" # change url
asyncio.run(main(sse_url))


**Stdio Client**

You have to pass server script to run stdio client (set transport to `stdio` in `fastmcp-server.py`):```commandline
python stdio.py fastmcp-server.py
``````python
import asyncio
import sys
import logging
from contextlib import AsyncExitStack
from typing import Optional

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(&quot;client&quot;)

class MCPClient:
    def __init__(self) -&gt; None:
        self.session: Optional[ClientSession] = None
        self.exit_stack = AsyncExitStack()

    async def connect_to_server(self, server_script_path: str) -&gt; None:
        if not server_script_path.endswith(&quot;.py&quot;):
            raise ValueError(&quot;Server script must be a .py file&quot;)

        server_params = StdioServerParameters(
            command=&quot;python&quot;,
            args=[server_script_path],
            env=None,
        )

        stdio_transport = await self.exit_stack.enter_async_context(
            stdio_client(server_params)
        )
        self.stdio, self.write = stdio_transport

        self.session = await self.exit_stack.enter_async_context(
            ClientSession(self.stdio, self.write)
        )
        initialize_response = await self.session.initialize()
        logger.info(f&quot;Initialized response: {initialize_response}&quot;)

    async def list_tools(self) -&gt; None:
        if not self.session:
            raise RuntimeError(&quot;Session is not initialized.&quot;)
        response = await self.session.list_tools()
        tools = response.tools
        logger.info(f&quot;List of tools: {[tool.name for tool in tools]}&quot;)

    async def find_level(self, grade: int) -&gt; None:
        response = await self.session.call_tool(&quot;FindLevel&quot;, {&quot;grade&quot;: grade})
        logger.info(f&quot;Find level response: {response}&quot;)

    async def cleanup(self) -&gt; None:
        await self.exit_stack.aclose()

async def main() -&gt; None:
    if len(sys.argv) &lt; 2:
        print(&quot;Usage: python client.py &lt;path_to_server_script&gt;&quot;)
        sys.exit(1)

    client = MCPClient()
    try:
        await client.connect_to_server(sys.argv[1])
        await client.list_tools()
        await client.find_level(86)
    except Exception as exc:
        print(&quot;Error:&quot;, exc)
    finally:
        await client.cleanup()

if __name__ == &quot;__main__&quot;:
    asyncio.run(main())

Protocol Specification

Three type of messages are exchanged between client and server.
All messages are formatted using JSON-RPC 2.0 to enable remote procedure calls.

  • Request: A request that expects a response (JSONRPCRequest).
  • Response: A successful (non-error) response to a request (JSONRPCResponse).
  • Notification: A notification which does not expect a response (JSONRPCNotification).

Standard JSON-RPC error codes:

  • PARSE_ERROR = -32700
  • INVALID_REQUEST = -32600
  • METHOD_NOT_FOUND = -32601
  • INVALID_PARAMS = -32602
  • INTERNAL_ERROR = -32603

Initialization

Client should initialize a successful connection with the server before messaging.
1. The client sends initialization request (InitializeRequest).
2. The server responds with its protocol version and capabilities (InitializeResult).
3. The client sends an initialized notification to acknowledge (InitializedNotification).
4. Connection is established.

Discovery

Client can:
- List Tools: ListToolsRequest/ ListToolsResult
- List Resources: ListResourcesRequest/ ListResourcesResult
- List Prompts: ListPromptsRequest/ ListPromptsResult

Invocation

Client can:

  • Call a tool: CallToolRequest/ CallToolResult
  • Get a prompt: GetPromptRequest/ GetPromptResult
  • Read a resource: ReadResourceRequest /ReadResourceResult

Gradio + MCP

Exposing an MCP server for your Gradio app is simple and seamless—one of my favorite MCP integrations.

  1. Install Gradio with the MCP extra:bash pip install &quot;gradio[mcp]&quot;
  2. Launch your app withmcp_server=True.
  3. The MCP server address will be displayed in the console. You can access MCP documentation at the bottom of your app page.
  • For full details, check out the Gradio MCP server guide.
  • Try my demo Space on Hugging Face.

References

  1. Introducing the Model Context Protocol
  2. MCP Python SDK/ Github
  3. Model Context Protocol/ Github
  4. Model Context Protocol Documentation
  5. MCP Course on Hugging Face

常见问题

7 问
答案由本站依据条目字段整理,不引用上游原文
Model Context Protocol (MCP) 怎么安装?

资料没有给出安装命令,请到官方仓库或文档按说明接入;这类条目多数是生态应用,或尚未发布可安装包。

Model Context Protocol (MCP) 怎么在 Claude、Cursor、Codex 里配置?

它的传输方式未标注,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Model Context Protocol (MCP) 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Model Context Protocol (MCP) 需要 API Key 吗?

资料标注需要会话登录认证,使用前准备好对应凭据,并按最小权限配置。

Model Context Protocol (MCP) 支持哪些客户端?

资料标注支持 Claude、Cursor、Codex、Zed;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Model Context Protocol (MCP) 能提供哪些能力?

资料显示能力标签包括 mcp、ai agent、mcp server、mcp client。具体工具清单以官方文档为准。

Model Context Protocol (MCP) 需要什么运行环境?

运行时为 python。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 未标注。