Skip to main content

MCP 概览

快速链接

概览

模型上下文协议是一个开放协议,标准化了应用程序为 LLM 提供上下文的方式。将 MCP 想象成 AI 应用程序的 USB-C 端口;它提供了将 AI 模型连接到不同数据源和工具的标准化方式。MCP 服务器充当大语言模型(LLM)(如 Claude)与外部工具或数据源之间的中介。它们是向 LLM 公开功能的小程序,使它们能够通过 MCP 与外部世界交互。MCP 服务器本质上就像 LLM 可以使用的 API。

MCP diagram showing how MCP servers connect LLMs to external tools and data sources

Key Concepts

MCP servers define a set of "tools," which are functions the LLM can execute. These tools offer a wide range of capabilities.

Here's how MCP works:

  • MCP hosts discover the capabilities of connected servers and load their tools, prompts, and resources.
  • Resources provide consistent access to read-only data, akin to file paths or database queries.
  • Security is ensured as servers isolate credentials and sensitive data. Interactions require explicit user approval.

Use Cases

The potential of MCP servers is vast. They can be used for a variety of purposes.

Here are some concrete examples of how MCP servers can be used:

  • Web Services and API Integration:
    • Monitor GitHub repositories for new issues
    • Post updates to Twitter based on specific triggers
    • Retrieve real-time weather data for location-based services
  • Browser Automation:
    • Automate web application testing
    • Scrape e-commerce sites for price comparisons
    • Generate screenshots for website monitoring
  • Database Queries:
    • Generate weekly sales reports
    • Analyze customer behavior patterns
    • Create real-time dashboards for business metrics
  • Project and Task Management:
    • Automate Jira ticket creation based on code commits
    • Generate weekly progress reports
    • Create task dependencies based on project requirements
  • Codebase Documentation:
    • Generate API documentation from code comments
    • Create architecture diagrams from code structure
    • Maintain up-to-date README files

Getting Started

Caret does not come with any pre-installed MCP servers. You'll need to find and install them separately.

Choose the right approach for your needs:

  • Community Repositories: Check for community-maintained lists of MCP servers on GitHub. See Adding MCP Servers from Github
  • Caret Marketplace: Install one from Caret's MCP Marketplace
  • Ask Caret: You can ask Caret to help you find or create MCP servers
  • Build Your Own: Create custom MCP servers using the MCP SDK
  • Customize Existing Servers: Modify existing servers to fit your specific requirements

Integration with Caret

Caret simplifies the building and use of MCP servers through its AI capabilities.

Building MCP Servers

  • Natural language understanding: Instruct Caret in natural language to build an MCP server by describing its functionalities. Caret will interpret your instructions and generate the necessary code.
  • Cloning and building servers: Caret can clone existing MCP server repositories from GitHub and build them automatically.
  • Configuration and dependency management: Caret handles configuration files, environment variables, and dependencies.
  • Troubleshooting and debugging: Caret helps identify and resolve errors during development.

Using MCP Servers

  • Tool execution: Caret seamlessly integrates with MCP servers, allowing you to execute their defined tools.
  • Context-aware interactions: Caret can intelligently suggest using relevant tools based on conversation context.
  • Dynamic integrations: Combine multiple MCP server capabilities for complex tasks. For example, Caret could use a GitHub server to get data and a Notion server to create a formatted report.

Security Considerations

When working with MCP servers, it's important to follow security best practices:

  • Authentication: Always use secure authentication methods for API access
  • Environment Variables: Store sensitive information in environment variables
  • Access Control: Limit server access to authorized users only
  • Data Validation: Validate all inputs to prevent injection attacks
  • Logging: Implement secure logging practices without exposing sensitive data

Resources

There are various resources available for finding and learning about MCP servers.

Here are some links to resources for finding and learning about MCP servers: