最近,MCP(Model Context Protocol) 在 AI 和开发者社区中引起了广泛关注,它为大型语言模型(LLM) 提供了一种标准化的方式来与外部工具和服务交互,比如数据库(Redis)、GitHub 仓库、HTTP API 等。
本帖将记录 MCP 的安装、配置及常见使用方法,帮助开发者快速上手。
什么是 MCP?
你可以把 MCP(Model Context Protocol) 想象成AI 的“万能适配器”,它让 AI 能够与外部世界对话,就像你的电脑需要驱动程序来连接键盘、鼠标、打印机一样,MCP 就是 AI 连接 GitHub、Redis、数据库、API 等工具的**“驱动程序”**。
💡 形象比喻:
如果 AI 是一个聪明但“封闭”的人,它能读懂你给它的指令,但无法自己去上网搜索、访问数据库或者管理 GitHub 仓库。
MCP 就像是“扩展器”或者“翻译官”,它让 AI 可以:
直接访问 GitHub 仓库,管理代码。
操作 Redis 服务器,存取数据。
调用 HTTP API,与外部服务通信。
甚至访问本地文件,读取或修改内容。
简而言之,MCP 让 AI 具备了“动手能力”,让它不仅仅是个回答问题的助手,还能真正地执行任务!
一、 先要安装node.js
1. 访问官网https://nodejs.org/en 下载node.js 是先决条件
置环境变量
在path中配置:
PS C:\Users\thore> node -v
v22.14.0
PS C:\Users\thore> npx -v
npx : 无法加载文件 D:\soft\nodejs\npx.ps1。未对文件 D:\soft\nodejs\npx.ps1 进行数字签名。无法在当前系统上运行该脚本。…
永久修改执行策略:
PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
PS C:\WINDOWS\system32> npx -v
10.9.2
二、 在Cursor里的配置
1. 切换版本
通过设置到Beta,将现有的standard版本切换到Early Access版本
2. 检查版本是否更新
在”Help”中找到“Check for Updates”中检查新的版本
将cursor升级到最新的版本。
3. 选择创建MCP
“设置”->“MCP”找到创建MCP的界面
4. MCP文件的作用域
它是由文件来创建不同作用域的文件:
当前项目下创建MCP,那么将会在这个项目中使用,如果选择蓝色按钮将会在用户下创建MCP文件,这样的设置将是全局的。
三、 创建MCP文件的步骤
1. 在项目中创建一个MCP
1) 根目录下创建一个目录.cursor文件夹
2) 在.cursor文件夹内创建mcp.json文件
A. 查看官方的一些推荐MCP库
官方网址:https://github.com/modelcontextprotocol/servers
2. 创建GitHub MCP Server
1) Github创建一个自己的token
3. 创建Mcp文件
“github.com/modelcontextprotocol/servers/tree/main/src/github”: {
“command”: “cmd”,
“args”: [
“/c”,
“npx”,
“-y”,
“GITHUB_PERSONAL_ACCESS_TOKEN”,
“@modelcontextprotocol/server-github”
],
“env”: {
“GITHUB_PERSONAL_ACCESS_TOKEN”: “<YOUR_TOKEN>”
},
“disabled”: false,
“autoApprove”: []
}
}
}
注意:GITHUB_PERSONAL_ACCESS_TOKEN要填入自己github的token
保存,运行甚至让cursor尝试运行,就会有下面结果:
证明创建成功!
四、
1. GitHub MCP 功能 & 在 Cursor 上的使用方法
GitHub MCP 让 AI 能够与 GitHub 仓库交互,它提供了一系列 API,允许你直接在 Cursor 编辑器中管理 GitHub 代码仓库,比如列出仓库、读取文件、提交更改等。以下是它的主要功能以及如何在 Cursor 里使用。
2. 🌟 GitHub MCP 提供的功能
功能 | 说明 | 示例 |
---|---|---|
列出仓库 | 获取 GitHub 用户的所有仓库 | listRepos |
获取仓库信息 | 获取特定仓库的详细信息 | getRepoInfo |
列出仓库文件 | 获取指定仓库的文件列表 | listFiles |
读取文件内容 | 读取 GitHub 上的文件 | readFile |
创建/更新文件 | 在 GitHub 上创建或修改文件 | writeFile |
删除文件 | 从仓库中删除文件 | deleteFile |
列出分支 | 获取仓库的所有分支 | listBranches |
创建分支 | 从指定分支创建新分支 | createBranch |
创建 | Pull Request 提交代码变更并创建 PR | createPullRequest |
列出 | Issues 获取仓库的所有 Issue | listIssues |
创建 | Issue 在仓库中创建新的 Issue | createIssue |
发表评论 | 在 Issue 或 PR 上发表评论 | addComment |
- 🚀在 Cursor 里使用 GitHub MCP结合 AI 使用 MCP
打开 Cursor,在根目录下找到 mcp.json 文件,并添加以下内容:
AI: “帮我列出 GitHub 上的仓库。”
从测试结果来看:
MCP 服务器确实在运行(显示 “GitHub MCP Server running on stdio”)
我们成功获取到了您的 GitHub 仓库信息:
您有一个名为 “NebulaVerseAI” 的仓库
仓库 URL 是 https://github.com/Samuel521199/NebulaVerseAI
但是,我们也发现了一些问题:
MCP 客户端包(@modelcontextprotocol/client-github)不存在于 npm 注册表中
直接通过 HTTP 请求与服务器通信也遇到了一些问题
建议:
继续使用服务器端命令来获取 GitHub 信息
如果需要更多功能,我们可以:
查找正确的客户端包
或者直接使用 GitHub API
五、 参考其他各种功能的服务器
These servers aim to demonstrate MCP features and the TypeScript and Python SDKs.
• AWS KB Retrieval - Retrieval from AWS Knowledge Base using Bedrock Agent Runtime
• Brave Search - Web and local search using Brave’s Search API
• EverArt - AI image generation using various models
• Everything - Reference / test server with prompts, resources, and tools
• Fetch - Web content fetching and conversion for efficient LLM usage
• Filesystem - Secure file operations with configurable access controls
• Git - Tools to read, search, and manipulate Git repositories
• GitHub - Repository management, file operations, and GitHub API integration
• GitLab - GitLab API, enabling project management
• Google Drive - File access and search capabilities for Google Drive
• Google Maps - Location services, directions, and place details
• Memory - Knowledge graph-based persistent memory system
• PostgreSQL - Read-only database access with schema inspection
• Puppeteer - Browser automation and web scraping
• Redis - Interact with Redis key-value stores
• Sentry - Retrieving and analyzing issues from Sentry.io
• Sequential Thinking - Dynamic and reflective problem-solving through thought sequences
• Slack - Channel management and messaging capabilities
• Sqlite - Database interaction and business intelligence capabilities
• Time - Time and timezone conversion capabilities
六、 其他类的第三方服务
🎖️ Official Integrations
Official integrations are maintained by companies building production ready MCP servers for their platforms.
• 21st.dev Magic - Create crafted UI components inspired by the best 21st.dev design engineers.
• Adfin - The only platform you need to get paid - all payments in one place, invoicing and accounting reconciliations with Adfin.
• AgentQL - Enable AI agents to get structured data from unstructured web with AgentQL.
• AgentRPC - Connect to any function, any language, across network boundaries using AgentRPC.
• Aiven - Navigate your Aiven projects and interact with the PostgreSQL®, Apache Kafka®, ClickHouse® and OpenSearch® services
• Apify - Actors MCP Server: Use 3,000+ pre-built cloud tools to extract data from websites, e-commerce, social media, search engines, maps, and more
• APIMatic MCP - APIMatic MCP Server is used to validate OpenAPI specifications using APIMatic. The server processes OpenAPI files and returns validation summaries by leveraging APIMatic’s API.
• Audiense Insights - Marketing insights and audience analysis from Audiense reports, covering demographic, cultural, influencer, and content engagement analysis.
• Axiom - Query and analyze your Axiom logs, traces, and all other event data in natural language
• Bankless Onchain - Query Onchain data, like ERC20 tokens, transaction history, smart contract state.
• BICScan - Risk score / asset holdings of EVM blockchain address (EOA, CA, ENS) and even domain names.
• Box - Interact with the Intelligent Content Management platform through Box AI.
• Browserbase - Automate browser interactions in the cloud (e.g. web navigation, data extraction, form filling, and more)
• Chargebee - MCP Server that connects AI agents to Chargebee platform.
• Chroma - Embeddings, vector search, document storage, and full-text search with the open-source AI application database
• Chronulus AI - Predict anything with Chronulus AI forecasting and prediction agents.
• ClickHouse - Query your ClickHouse database server.
• Cloudflare - Deploy, configure & interrogate your resources on the Cloudflare developer platform (e.g. Workers/KV/R2/D1)
• Comet Opik - Query and analyze your Opik logs, traces, prompts and all other telemtry data from your LLMs in natural language.
• Convex - Introspect and query your apps deployed to Convex.
• Dart - Interact with task, doc, and project data in Dart, an AI-native project management tool
• DevHub - Manage and utilize website content within the DevHub CMS platform
• E2B - Run code in secure sandboxes hosted by E2B
• EduBase - Interact with EduBase, a comprehensive e-learning platform with advanced quizzing, exam management, and content organization capabilities
• eSignatures - Contract and template management for drafting, reviewing, and sending binding contracts.
• Exa - Search Engine made for AIs by Exa
• Fewsats - Enable AI Agents to purchase anything in a secure way using Fewsats
• Fibery - Perform queries and entity operations in your Fibery workspace.
• Financial Datasets - Stock market API made for AI agents
• Firecrawl - Extract web data with Firecrawl
• Fireproof - Immutable ledger database with live synchronization
• Gitee - Gitee API integration, repository, issue, and pull request management, and more.
• gotoHuman - Human-in-the-loop platform - Allow AI agents and automations to send requests for approval to your gotoHuman inbox.
• Grafana - Search dashboards, investigate incidents and query datasources in your Grafana instance
• Graphlit - Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a searchable Graphlit project.
• GreptimeDB - Provides AI assistants with a secure and structured way to explore and analyze data in GreptimeDB.
• Hologres - Connect to a Hologres instance, get table metadata, query and analyze data.
• Hyperbrowser - Hyperbrowser is the next-generation platform empowering AI agents and enabling effortless, scalable browser automation.
• IBM wxflows - Tool platform by IBM to build, test and deploy tools for any data source
• ForeverVM - Run Python in a code sandbox.
• Inbox Zero - AI personal assistant for email Inbox Zero
• Inkeep - RAG Search over your content powered by Inkeep
• Integration App - Interact with any other SaaS applications on behalf of your customers.
• JetBrains – Work on your code with JetBrains IDEs
• Kagi Search - Search the web using Kagi’s search API
• Keboola - Build robust data workflows, integrations, and analytics on a single intuitive platform.
• Logfire - Provides access to OpenTelemetry traces and metrics through Logfire.
• Langfuse Prompt Management - Open-source tool for collaborative editing, versioning, evaluating, and releasing prompts.
• Lingo.dev - Make your AI agent speak every language on the planet, using Lingo.dev Localization Engine.
• Mailgun - Interact with Mailgun API.
• Make - Turn your Make scenarios into callable tools for AI assistants.
• Meilisearch - Interact & query with Meilisearch (Full-text & semantic search API)
• Metoro - Query and interact with kubernetes environments monitored by Metoro
• Milvus - Search, Query and interact with data in your Milvus Vector Database.
• MotherDuck - Query and analyze data with MotherDuck and local DuckDB
• Needle - Production-ready RAG out of the box to search and retrieve data from your own documents.
• Neo4j - Neo4j graph database server (schema + read/write-cypher) and separate graph database backed memory
• Neon - Interact with the Neon serverless Postgres platform
• OceanBase - MCP Server for OceanBase database and its tools
• Octagon - Deliver real-time investment research with extensive private and public market data.
• Oxylabs - Scrape websites with Oxylabs Web API, supporting dynamic rendering and parsing for structured data extraction.
• Perplexity - An MCP server that connects to Perplexity’s Sonar API, enabling real-time web-wide research in conversational AI.
• Qdrant - Implement semantic memory layer on top of the Qdrant vector search engine
• Ramp - Interact with Ramp’s Developer API to run analysis on your spend and gain insights leveraging LLMs
• Raygun - Interact with your crash reporting and real using monitoring data on your Raygun account
• Rember - Create spaced repetition flashcards in Rember to remember anything you learn in your chats
• Riza - Arbitrary code execution and tool-use platform for LLMs by Riza
• Search1API - One API for Search, Crawling, and Sitemaps
• ScreenshotOne - Render website screenshots with ScreenshotOne
• Semgrep - Enable AI agents to secure code with Semgrep.
• SingleStore - Interact with the SingleStore database platform
• StarRocks - Interact with StarRocks
• Stripe - Interact with Stripe API
• Tavily - Search engine for AI agents (search + extract) powered by Tavily
• Thirdweb - Read/write to over 2k blockchains, enabling data querying, contract analysis/deployment, and transaction execution, powered by Thirdweb
• Tinybird - Interact with Tinybird serverless ClickHouse platform
• UnifAI - Dynamically search and call tools using UnifAI Network
• Unstructured - Set up and interact with your unstructured data processing workflows in Unstructured Platform
• Vectorize - Vectorize MCP server for advanced retrieval, Private Deep Research, Anything-to-Markdown file extraction and text chunking.
• Verodat - Interact with Verodat AI Ready Data platform
• VeyraX - Single tool to control all 100+ API integrations, and UI components
• Xero - Interact with the accounting data in your business using our official MCP server
• Zapier - Connect your AI Agents to 8,000 apps instantly.
• ZenML - Interact with your MLOps and LLMOps pipelines through your ZenML MCP server