跳至主要内容

[note] Model Context Protocol(MCP)

MCP 其實就很像是 Slack 裡安裝的 Apps、Chrome 裡面 Extensions 的概念。只要支援 MCP 的 client,都可以把對應的 MCP Servers 安裝進去。

概念

MCP 的重點是規範 App 如何提供 Context 給 LLM 或 AI Assistants。

MCP Servers Marketplace

Gradio MCP

如果是使用 Gradio MCP,並且放在 huggingface 的 private space 上,在 Cursor 中的 mcp server 的設定檔要這樣寫:

{
"mcpServers": {
"gradio": {
"command": "npx",
"args": [
"mcp-remote",
"https://pjchender-mcp-sentiment.hf.space/gradio_api/mcp/sse",
"--transport",
"sse-only",
"--header",
"Authorization:${HF_AUTH_HEADER}"
],
"env": {
"HF_AUTH_HEADER": "Bearer hf_xxxx"
}
}
}
}

常見問題

ENOENT

官方文件雖然在 command 的地方寫可以自己用 uvxnpx,但會出現 ENOENT 的錯誤(#37#40),表示找不到該 command file,需要使用 which uvx 找到該 command 的路徑後,貼入該絕對路徑:

{
"mcpServers": {
"fetch": {
"command": "/Users/aaron.pj.chen/.local/bin/uvx",
"args": [
"mcp-server-fetch"
]
}
}
}