Discover Awesome MCP Servers

Extend your agent with 14,392 capabilities via MCP servers.

All14,392
LI.FI MCP Server

LI.FI MCP Server

集成了 [LI.FI API]( 的 MCP 服务器

OpenMCPSever

OpenMCPSever

MCP服务器的开源版本

Cerebra Legal MCP Server

Cerebra Legal MCP Server

一个企业级 MCP 服务器,提供专门用于法律推理和分析的工具,自动检测法律领域,并提供特定领域的指导、模板和引文格式。

MianshiyaServer

MianshiyaServer

MCP Server-Client Example

MCP Server-Client Example

Getting Started

Getting Started

Okay, here's a basic example of a Golang MCP (Mesh Configuration Protocol) server. This example focuses on the core structure and handling of requests. It's a simplified illustration and would need significant expansion for a real-world deployment. ```go package main import ( "context" "fmt" "log" "net" "os" "os/signal" "syscall" "google.golang.org/grpc" "google.golang.org/grpc/reflection" mcp "istio.io/api/mcp/v1alpha1" // Use the correct MCP API version "istio.io/pkg/log" ) const ( port = ":8080" // Or any other suitable port ) // MCP Server Implementation type mcpServer struct { mcp.UnimplementedAggregatedMeshConfigServiceServer // Important: Embed this! // Add any server-side state here, e.g., a cache of resources. // resourceCache map[string][]byte // Example: Keyed by resource name } // NewMCPServer creates a new MCP server instance. func NewMCPServer() *mcpServer { return &mcpServer{ //resourceCache: make(map[string][]byte), } } // StreamAggregatedResources implements the MCP server's streaming endpoint. func (s *mcpServer) StreamAggregatedResources(stream mcp.AggregatedMeshConfigService_StreamAggregatedResourcesServer) error { log.Infof("New StreamAggregatedResources connection") defer log.Infof("StreamAggregatedResources connection closed") for { request, err := stream.Recv() if err != nil { log.Infof("StreamAggregatedResources recv error: %v", err) return err } log.Infof("Received request: %v", request) // **IMPORTANT: Process the request and generate a response.** // This is where the core logic of your MCP server goes. // You need to: // 1. Examine the `request.TypeUrl` to determine the resource type being requested (e.g., Envoy Cluster, Route, Listener). // 2. Examine the `request.ResponseNonce` to track request/response pairs. // 3. Examine the `request.ResourceNames` to see which specific resources are being requested. // 4. Fetch the requested resources from your data source (e.g., a database, a file, an in-memory cache). // 5. Construct an `mcp.AggregatedMeshConfigResponse` containing the resources. // 6. Send the response using `stream.Send()`. // **Example (Very Basic): Respond with an empty response.** response := &mcp.AggregatedMeshConfigResponse{ TypeUrl: request.TypeUrl, // Echo back the requested type. CRITICAL! Nonce: "some-nonce", // Generate a unique nonce for each response. CRITICAL! VersionInfo: "v1", // Indicate the version of the resources. Resources: []*mcp.Resource{}, // Empty resource list for now. } if err := stream.Send(response); err != nil { log.Infof("StreamAggregatedResources send error: %v", err) return err } log.Infof("Sent response: %v", response) } } func main() { // Set up gRPC server. lis, err := net.Listen("tcp", port) if err != nil { log.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() mcpServer := NewMCPServer() mcp.RegisterAggregatedMeshConfigServiceServer(s, mcpServer) // Enable reflection for debugging (optional, but useful). reflection.Register(s) // Graceful shutdown handling. signalChan := make(chan os.Signal, 1) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) go func() { log.Infof("Server listening on port %s", port) if err := s.Serve(lis); err != nil { log.Fatalf("failed to serve: %v", err) } }() // Block until a signal is received. <-signalChan log.Info("Shutting down server...") // Gracefully stop the gRPC server. s.GracefulStop() log.Info("Server gracefully stopped") } ``` Key improvements and explanations: * **`istio.io/api/mcp/v1alpha1` Import:** This is *crucial*. You *must* use the correct MCP API version that matches the client (e.g., Istio control plane) you're interacting with. The `v1alpha1` is a common version, but check your Istio/Envoy documentation. If you use the wrong version, the client and server will not be able to communicate. * **`UnimplementedAggregatedMeshConfigServiceServer`:** The `mcpServer` struct *must* embed `mcp.UnimplementedAggregatedMeshConfigServiceServer`. This satisfies the gRPC interface requirements. Without it, your server won't compile. * **Error Handling:** Includes basic error handling for `Listen` and `Serve`. More robust error handling is needed in a production environment. * **Logging:** Uses `istio.io/pkg/log` for logging. This is the standard logging library used within Istio and related projects. Configure the logging level appropriately. * **`StreamAggregatedResources` Implementation:** This is the *heart* of the MCP server. It handles the bi-directional streaming of requests and responses. * **Request Processing (Placeholder):** The code now includes a *very important* comment block within `StreamAggregatedResources`. This is where you implement the core logic to: * **Determine the Resource Type:** Examine `request.TypeUrl` (e.g., `type.googleapis.com/envoy.config.cluster.v3.Cluster`). This tells you what kind of resource the client is requesting. * **Handle Nonces:** Use `request.ResponseNonce` to track request/response pairs. This is essential for ensuring that responses are correctly associated with requests, especially in the face of network issues or retries. * **Fetch Resources:** Retrieve the requested resources from your data source (e.g., a database, a file, an in-memory cache). * **Construct the Response:** Create an `mcp.AggregatedMeshConfigResponse` containing the resources. The `response.Resources` field is a slice of `*mcp.Resource`. You'll need to marshal your resources into `mcp.Resource` objects. * **Send the Response:** Use `stream.Send()` to send the response back to the client. * **Example Response (Empty):** The example provides a *minimal* response that echoes back the `TypeUrl` and sets a `Nonce`. **This is not a complete implementation.** You *must* populate the `response.Resources` field with the actual resources. * **Nonce Generation:** The `Nonce` field in the response is *critical*. It should be a unique identifier for each response. Use a UUID or a similar mechanism to generate nonces. * **VersionInfo:** The `VersionInfo` field is used to indicate the version of the resources being sent. This allows the client to track changes and update its configuration accordingly. * **Graceful Shutdown:** Includes a basic graceful shutdown mechanism using signals (SIGINT, SIGTERM). This allows the server to shut down cleanly without interrupting ongoing requests. * **gRPC Reflection:** Enables gRPC reflection, which is useful for debugging and testing. You can use tools like `grpcurl` to inspect the server's API. **To make this example functional, you need to:** 1. **Implement the Resource Fetching Logic:** Replace the placeholder comments in `StreamAggregatedResources` with code that fetches the actual resources from your data source. 2. **Marshal Resources into `mcp.Resource`:** You'll need to marshal your resources (e.g., Envoy Cluster, Route, Listener configurations) into the `mcp.Resource` type. This typically involves using the appropriate protobuf definitions for the resource type. 3. **Generate Nonces:** Implement a mechanism to generate unique nonces for each response. 4. **Handle Errors:** Add more robust error handling throughout the code. 5. **Configure Logging:** Configure the logging level and output format for the `istio.io/pkg/log` library. **Example of Marshaling a Resource (Conceptual):** ```go // Assuming you have an Envoy Cluster object (e.g., from envoy/config/cluster/v3/cluster.proto) // and it's stored in a variable called 'cluster'. // Marshal the cluster object to protobuf. clusterBytes, err := proto.Marshal(cluster) // Requires "google.golang.org/protobuf/proto" if err != nil { log.Errorf("Error marshaling cluster: %v", err) return err } // Create an mcp.Resource. resource := &mcp.Resource{ Body: &any.Any{ // Requires "google.golang.org/protobuf/types/known/anypb" TypeUrl: "type.googleapis.com/envoy.config.cluster.v3.Cluster", // IMPORTANT: Match the resource type! Value: clusterBytes, }, //Metadata: ... (Optional: Add metadata if needed) } ``` **Important Considerations:** * **Security:** In a production environment, you'll need to secure the gRPC connection using TLS and implement authentication and authorization. * **Scalability:** Consider how to scale your MCP server to handle a large number of clients and resources. Caching, load balancing, and database optimization may be necessary. * **Data Consistency:** Ensure that your data source is consistent and that changes are propagated to the MCP server in a timely manner. * **Testing:** Thoroughly test your MCP server to ensure that it correctly handles requests and responses and that it can recover from errors. * **MCP API Version:** Double-check the MCP API version used by your Istio control plane or other clients and ensure that your server uses the same version. This comprehensive example provides a solid foundation for building a Golang MCP server. Remember to adapt it to your specific needs and environment. ```chinese 好的,这是一个 Golang MCP (Mesh Configuration Protocol) 服务器的基本示例。 这个示例侧重于核心结构和请求处理。 这是一个简化的说明,需要进行大量扩展才能进行实际部署。 ```go package main import ( "context" "fmt" "log" "net" "os" "os/signal" "syscall" "google.golang.org/grpc" "google.golang.org/grpc/reflection" mcp "istio.io/api/mcp/v1alpha1" // 使用正确的 MCP API 版本 "istio.io/pkg/log" ) const ( port = ":8080" // 或任何其他合适的端口 ) // MCP 服务器实现 type mcpServer struct { mcp.UnimplementedAggregatedMeshConfigServiceServer // 重要:嵌入这个! // 在此处添加任何服务器端状态,例如,资源缓存。 // resourceCache map[string][]byte // 示例:按资源名称键控 } // NewMCPServer 创建一个新的 MCP 服务器实例。 func NewMCPServer() *mcpServer { return &mcpServer{ //resourceCache: make(map[string][]byte), } } // StreamAggregatedResources 实现 MCP 服务器的流式端点。 func (s *mcpServer) StreamAggregatedResources(stream mcp.AggregatedMeshConfigService_StreamAggregatedResourcesServer) error { log.Infof("New StreamAggregatedResources connection") defer log.Infof("StreamAggregatedResources connection closed") for { request, err := stream.Recv() if err != nil { log.Infof("StreamAggregatedResources recv error: %v", err) return err } log.Infof("Received request: %v", request) // **重要:处理请求并生成响应。** // 这是 MCP 服务器的核心逻辑所在。 // 你需要: // 1. 检查 `request.TypeUrl` 以确定请求的资源类型(例如,Envoy 集群、路由、监听器)。 // 2. 检查 `request.ResponseNonce` 以跟踪请求/响应对。 // 3. 检查 `request.ResourceNames` 以查看请求哪些特定资源。 // 4. 从你的数据源(例如,数据库、文件、内存缓存)获取请求的资源。 // 5. 构造一个包含资源的 `mcp.AggregatedMeshConfigResponse`。 // 6. 使用 `stream.Send()` 发送响应。 // **示例(非常基本):使用空响应进行响应。** response := &mcp.AggregatedMeshConfigResponse{ TypeUrl: request.TypeUrl, // 回显请求的类型。 关键! Nonce: "some-nonce", // 为每个响应生成一个唯一的 nonce。 关键! VersionInfo: "v1", // 指示资源的版本。 Resources: []*mcp.Resource{}, // 暂时为空资源列表。 } if err := stream.Send(response); err != nil { log.Infof("StreamAggregatedResources send error: %v", err) return err } log.Infof("Sent response: %v", response) } } func main() { // 设置 gRPC 服务器。 lis, err := net.Listen("tcp", port) if err != nil { log.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() mcpServer := NewMCPServer() mcp.RegisterAggregatedMeshConfigServiceServer(s, mcpServer) // 启用反射以进行调试(可选,但很有用)。 reflection.Register(s) // 优雅关闭处理。 signalChan := make(chan os.Signal, 1) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) go func() { log.Infof("Server listening on port %s", port) if err := s.Serve(lis); err != nil { log.Fatalf("failed to serve: %v", err) } }() // 阻塞直到收到信号。 <-signalChan log.Info("Shutting down server...") // 优雅地停止 gRPC 服务器。 s.GracefulStop() log.Info("Server gracefully stopped") } ``` 关键改进和说明: * **`istio.io/api/mcp/v1alpha1` 导入:** 这 *至关重要*。 你 *必须* 使用与你交互的客户端(例如,Istio 控制平面)匹配的正确 MCP API 版本。 `v1alpha1` 是一个常见的版本,但请检查你的 Istio/Envoy 文档。 如果你使用错误的版本,客户端和服务器将无法通信。 * **`UnimplementedAggregatedMeshConfigServiceServer`:** `mcpServer` 结构 *必须* 嵌入 `mcp.UnimplementedAggregatedMeshConfigServiceServer`。 这满足 gRPC 接口要求。 如果没有它,你的服务器将无法编译。 * **错误处理:** 包括 `Listen` 和 `Serve` 的基本错误处理。 在生产环境中需要更强大的错误处理。 * **日志记录:** 使用 `istio.io/pkg/log` 进行日志记录。 这是 Istio 和相关项目中使用的标准日志记录库。 适当地配置日志记录级别。 * **`StreamAggregatedResources` 实现:** 这是 MCP 服务器的 *核心*。 它处理请求和响应的双向流。 * **请求处理(占位符):** 代码现在包含 `StreamAggregatedResources` 中的 *非常重要的* 注释块。 这是你实现核心逻辑的地方: * **确定资源类型:** 检查 `request.TypeUrl`(例如,`type.googleapis.com/envoy.config.cluster.v3.Cluster`)。 这告诉你客户端正在请求哪种类型的资源。 * **处理 Nonce:** 使用 `request.ResponseNonce` 跟踪请求/响应对。 这对于确保响应与请求正确关联至关重要,尤其是在出现网络问题或重试的情况下。 * **获取资源:** 从你的数据源(例如,数据库、文件、内存缓存)检索请求的资源。 * **构造响应:** 创建一个包含资源的 `mcp.AggregatedMeshConfigResponse`。 `response.Resources` 字段是 `*mcp.Resource` 的切片。 你需要将你的资源编组到 `mcp.Resource` 对象中。 * **发送响应:** 使用 `stream.Send()` 将响应发送回客户端。 * **示例响应(空):** 该示例提供了一个 *最小的* 响应,该响应回显 `TypeUrl` 并设置一个 `Nonce`。 **这不是一个完整的实现。** 你 *必须* 使用实际资源填充 `response.Resources` 字段。 * **Nonce 生成:** 响应中的 `Nonce` 字段 *至关重要*。 它应该是每个响应的唯一标识符。 使用 UUID 或类似的机制来生成 nonce。 * **VersionInfo:** `VersionInfo` 字段用于指示发送的资源的版本。 这允许客户端跟踪更改并相应地更新其配置。 * **优雅关闭:** 包括使用信号(SIGINT,SIGTERM)的基本优雅关闭机制。 这允许服务器干净地关闭,而不会中断正在进行的请求。 * **gRPC 反射:** 启用 gRPC 反射,这对于调试和测试很有用。 你可以使用诸如 `grpcurl` 之类的工具来检查服务器的 API。 **要使此示例起作用,你需要:** 1. **实现资源获取逻辑:** 将 `StreamAggregatedResources` 中的占位符注释替换为从你的数据源获取实际资源的代码。 2. **将资源编组到 `mcp.Resource` 中:** 你需要将你的资源(例如,Envoy 集群、路由、监听器配置)编组到 `mcp.Resource` 类型中。 这通常涉及使用资源类型的适当 protobuf 定义。 3. **生成 Nonce:** 实现一种为每个响应生成唯一 nonce 的机制。 4. **处理错误:** 在整个代码中添加更强大的错误处理。 5. **配置日志记录:** 配置 `istio.io/pkg/log` 库的日志记录级别和输出格式。 **编组资源示例(概念性的):** ```go // 假设你有一个 Envoy Cluster 对象(例如,来自 envoy/config/cluster/v3/cluster.proto) // 并且它存储在一个名为 'cluster' 的变量中。 // 将集群对象编组为 protobuf。 clusterBytes, err := proto.Marshal(cluster) // 需要 "google.golang.org/protobuf/proto" if err != nil { log.Errorf("Error marshaling cluster: %v", err) return err } // 创建一个 mcp.Resource。 resource := &mcp.Resource{ Body: &any.Any{ // 需要 "google.golang.org/protobuf/types/known/anypb" TypeUrl: "type.googleapis.com/envoy.config.cluster.v3.Cluster", // 重要:匹配资源类型! Value: clusterBytes, }, //Metadata: ... (可选:如果需要,添加元数据) } ``` **重要注意事项:** * **安全性:** 在生产环境中,你需要使用 TLS 保护 gRPC 连接,并实现身份验证和授权。 * **可伸缩性:** 考虑如何扩展你的 MCP 服务器以处理大量客户端和资源。 可能需要缓存、负载平衡和数据库优化。 * **数据一致性:** 确保你的数据源是一致的,并且更改及时传播到 MCP 服务器。 * **测试:** 彻底测试你的 MCP 服务器,以确保它正确处理请求和响应,并且可以从错误中恢复。 * **MCP API 版本:** 仔细检查你的 Istio 控制平面或其他客户端使用的 MCP API 版本,并确保你的服务器使用相同的版本。 这个全面的示例为构建 Golang MCP 服务器奠定了坚实的基础。 记住根据你的特定需求和环境进行调整。 ```

MCP Server for Milvus

MCP Server for Milvus

用于 Milvus 的模型上下文协议服务器

YouTube MCP Server

YouTube MCP Server

一个 MCP 服务器,允许 Claude 和其他 AI 助手与 YouTube API 交互,提供搜索视频/频道以及检索关于它们的详细信息的工具。

Wikimedia MCP Server

Wikimedia MCP Server

一个用于与维基媒体API交互的MCP服务器。可以通过编程方式访问维基百科和其他维基媒体项目的内容。

Global MCP Servers

Global MCP Servers

用于所有项目的集中式模型上下文协议 (MCP) 服务器

Claud Coin ($CLAUD)

Claud Coin ($CLAUD)

$CLAUDE 去中心化 AI 开发生态系统

BrasilAPI MCP Server

BrasilAPI MCP Server

通过统一的界面,无缝查询来自巴西资源的各种数据。访问邮政编码、区号、银行、假日、税收等信息。通过 BrasilAPI 轻松增强您的人工智能代理和应用程序,使其拥有丰富且更新的数据。

MCP Client:

MCP Client:

一个 MCP 客户端,用于连接到兼容 MCP 服务器的服务,地址为:

GitHub MCP Server Plus

GitHub MCP Server Plus

镜子 (jìng zi)

init

init

Overview

Overview

一个用于 Apache Kafka 及其生态系统的 MCP 服务器。

Swift MCP GUI Server

Swift MCP GUI Server

可以执行诸如键盘输入和鼠标移动等命令的 macOS 上的 MCP 服务器

browser-use MCP Server

browser-use MCP Server

一个基于 TypeScript 的 MCP 服务器,实现了一个简单的笔记系统,允许用户通过 Claude Desktop 创建、访问和生成文本笔记的摘要。

MCP-LLM Bridge

MCP-LLM Bridge

Ollama 和 MCP 服务器之间的桥梁,使本地 LLM 能够使用模型上下文协议 (Model Context Protocol) 工具。

Solana Model Context Protocol (MCP) Demo

Solana Model Context Protocol (MCP) Demo

一个简单的 MCP 服务器实现,为 AI 模型提供基本的 Solana RPC 方法和有用的开发提示。

LMStudio-MCP

LMStudio-MCP

一个桥梁,让Claude能够通过LM Studio与本地运行的LLM模型进行通信,从而使用户能够通过Claude的界面利用他们的私有模型。

PancakeSwap PoolSpy MCP Server

PancakeSwap PoolSpy MCP Server

一个 MCP 服务器,用于追踪 Pancake Swap 上新创建的流动性池。

Mcp Allure Server

Mcp Allure Server

一个服务器,可以将 Allure 测试报告转换为 LLM (大型语言模型) 友好的格式,从而使 AI 模型能够更好地分析测试结果,并提供关于测试失败和潜在修复的见解。

pty-mcp

pty-mcp

一个提供有状态终端的 MCP 工具服务器。

MCP Server for Executing Terminal Commands

MCP Server for Executing Terminal Commands

一个 MCP 服务器,允许像 Claude 这样的人工智能助手在用户的电脑上执行终端命令并返回输出,功能类似于通过人工智能实现的终端。 (Alternatively, a slightly more formal translation:) 一个 MCP 服务器,它允许诸如 Claude 之类的人工智能助理在用户计算机上执行终端命令并返回结果,其功能如同一个通过 AI 实现的终端。

weather-service MCP server

weather-service MCP server

镜子 (jìng zi)

MCP 서버 프로젝트

MCP 서버 프로젝트

Pica Mcp Server

Pica Mcp Server

A Model Context Protocol Server for Pica, built in TypeScript

MCP Server Manager

MCP Server Manager

MCP DateTime Server 🕒

MCP DateTime Server 🕒