发现优秀的 MCP 服务器
通过 MCP 服务器扩展您的代理能力,拥有 13,799 个能力。
zPlanner v1.4.0
Bazel MCP Server
一个 MCP 服务器,提供常见的 Bazel 操作,例如构建、测试和依赖分析。
Git MCP Server
镜子 (jìng zi)
JSR-MCP Server
一个模型上下文协议 (MCP) 服务器,提供对 JSR (JavaScript Registry) 模块文档的访问。
Smithery Registry MCP Server
用于与 Smithery Registry API 交互的 MCP 服务器
mcpjam-spotify
MCPJam 团队构建的 Spotify 的 MCP 服务器
Medium MCP API Server
用于 Medium API 的微服务通信协议 (MCP) 服务器,用于发布内容和管理用户帐户。 Or, a slightly more formal translation: 用于 Medium API 的微服务通信协议 (MCP) 服务器,旨在发布内容和管理用户账户。
mcp-mananger-desktop
未完成:一个 MCP 服务器,用于搜索、安装、卸载你的 Claude 应用(或更多)的所有 MCP 服务器或服务。
Mcp_proxy_pydantic_agent
好的,以下是将 MCP 服务器暴露给 Pydantic Agents 的一个例子: **英文:** Here's an example of exposing MCP (Model Control Plane) servers to Pydantic Agents: **Conceptual Overview:** 1. **MCP Server:** Imagine you have an MCP server that manages machine learning models. It might provide endpoints for: * Listing available models. * Getting model metadata (e.g., input/output schema). * Making predictions using a specific model. 2. **Pydantic Agent:** You want to create a Pydantic Agent that can interact with this MCP server. The agent should be able to: * Discover available models. * Choose the appropriate model for a given task. * Call the model with the correct input format. * Process the model's output. 3. **Pydantic Models for MCP Interaction:** You'll define Pydantic models to represent the data structures used when communicating with the MCP server. This includes: * A model for representing a model's metadata (name, description, input schema, output schema). * A model for representing the input to a model. * A model for representing the output from a model. 4. **Agent Tools:** You'll create agent tools that use these Pydantic models to interact with the MCP server. These tools will handle the HTTP requests to the MCP server and parse the responses into Pydantic objects. **Simplified Example (using Python and `requests` library):** ```python from pydantic import BaseModel, Field from typing import List, Dict, Any import requests # 1. Pydantic Models for MCP Data class ModelMetadata(BaseModel): name: str = Field(..., description="The name of the model.") description: str = Field(..., description="A description of the model.") input_schema: Dict[str, Any] = Field(..., description="The input schema of the model.") output_schema: Dict[str, Any] = Field(..., description="The output schema of the model.") class ModelInput(BaseModel): data: Dict[str, Any] = Field(..., description="The input data for the model.") class ModelOutput(BaseModel): result: Any = Field(..., description="The output from the model.") # 2. Agent Tools for MCP Interaction class MCPClient: def __init__(self, mcp_server_url: str): self.mcp_server_url = mcp_server_url def list_models(self) -> List[ModelMetadata]: """Lists all available models on the MCP server.""" response = requests.get(f"{self.mcp_server_url}/models") response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx) model_data = response.json() return [ModelMetadata(**model) for model in model_data] def get_model_metadata(self, model_name: str) -> ModelMetadata: """Gets the metadata for a specific model.""" response = requests.get(f"{self.mcp_server_url}/models/{model_name}") response.raise_for_status() model_data = response.json() return ModelMetadata(**model_data) def predict(self, model_name: str, input_data: ModelInput) -> ModelOutput: """Makes a prediction using the specified model.""" response = requests.post(f"{self.mcp_server_url}/models/{model_name}/predict", json=input_data.dict()) response.raise_for_status() output_data = response.json() return ModelOutput(**output_data) # 3. Example Usage (Conceptual - needs integration with a Pydantic Agent framework) # Assuming you have a Pydantic Agent framework set up (e.g., using LangChain) # Initialize the MCP client mcp_client = MCPClient(mcp_server_url="http://your-mcp-server.com") # Example: List available models available_models = mcp_client.list_models() print("Available Models:", available_models) # Example: Get metadata for a specific model if available_models: first_model_name = available_models[0].name model_metadata = mcp_client.get_model_metadata(first_model_name) print("Model Metadata:", model_metadata) # Example: Make a prediction input_data = ModelInput(data={"feature1": 1.0, "feature2": 2.0}) # Replace with actual input data prediction = mcp_client.predict(first_model_name, input_data) print("Prediction:", prediction) # In a real Pydantic Agent setup, you would: # 1. Define tools that wrap the MCPClient methods. # 2. Use the Pydantic models to define the input and output types of the tools. # 3. Register these tools with your Pydantic Agent. # 4. The agent can then use these tools to interact with the MCP server based on the user's instructions. ``` **Explanation:** * **Pydantic Models:** `ModelMetadata`, `ModelInput`, and `ModelOutput` define the structure of the data exchanged with the MCP server. The `Field` annotations provide descriptions that can be used by the agent framework for tool selection and parameter validation. * **MCPClient:** This class encapsulates the logic for interacting with the MCP server. It uses the `requests` library to make HTTP requests and parses the responses into Pydantic objects. * **Example Usage:** This section shows how you would use the `MCPClient` to interact with the MCP server. It's a simplified example and would need to be integrated with a Pydantic Agent framework like LangChain. * **Important Considerations for Pydantic Agents:** * **Tool Definition:** You would need to define tools that wrap the `MCPClient` methods. Each tool would have a name, description, and input/output types defined using Pydantic models. * **Agent Integration:** You would register these tools with your Pydantic Agent framework. The agent would then be able to use these tools to interact with the MCP server based on the user's instructions. * **Error Handling:** The `response.raise_for_status()` method is used for basic error handling. You might need to add more sophisticated error handling to your agent. * **Authentication:** If your MCP server requires authentication, you would need to add authentication logic to the `MCPClient`. **中文:** 以下是将 MCP (模型控制平面) 服务器暴露给 Pydantic Agents 的一个例子: **概念概述:** 1. **MCP 服务器:** 假设你有一个 MCP 服务器,用于管理机器学习模型。它可能提供以下端点: * 列出可用的模型。 * 获取模型元数据(例如,输入/输出模式)。 * 使用特定模型进行预测。 2. **Pydantic Agent:** 你想创建一个可以与此 MCP 服务器交互的 Pydantic Agent。该 Agent 应该能够: * 发现可用的模型。 * 为给定的任务选择合适的模型。 * 使用正确的输入格式调用模型。 * 处理模型的输出。 3. **用于 MCP 交互的 Pydantic 模型:** 你将定义 Pydantic 模型来表示与 MCP 服务器通信时使用的数据结构。 这包括: * 一个用于表示模型元数据的模型(名称、描述、输入模式、输出模式)。 * 一个用于表示模型输入的模型。 * 一个用于表示模型输出的模型。 4. **Agent 工具:** 你将创建 Agent 工具,这些工具使用这些 Pydantic 模型与 MCP 服务器交互。 这些工具将处理到 MCP 服务器的 HTTP 请求,并将响应解析为 Pydantic 对象。 **简化示例 (使用 Python 和 `requests` 库):** ```python from pydantic import BaseModel, Field from typing import List, Dict, Any import requests # 1. 用于 MCP 数据的 Pydantic 模型 class ModelMetadata(BaseModel): name: str = Field(..., description="模型的名称。") description: str = Field(..., description="模型的描述。") input_schema: Dict[str, Any] = Field(..., description="模型的输入模式。") output_schema: Dict[str, Any] = Field(..., description="模型的输出模式。") class ModelInput(BaseModel): data: Dict[str, Any] = Field(..., description="模型的输入数据。") class ModelOutput(BaseModel): result: Any = Field(..., description="模型的输出。") # 2. 用于 MCP 交互的 Agent 工具 class MCPClient: def __init__(self, mcp_server_url: str): self.mcp_server_url = mcp_server_url def list_models(self) -> List[ModelMetadata]: """列出 MCP 服务器上所有可用的模型。""" response = requests.get(f"{self.mcp_server_url}/models") response.raise_for_status() # 为错误的响应(4xx 或 5xx)引发 HTTPError model_data = response.json() return [ModelMetadata(**model) for model in model_data] def get_model_metadata(self, model_name: str) -> ModelMetadata: """获取特定模型的元数据。""" response = requests.get(f"{self.mcp_server_url}/models/{model_name}") response.raise_for_status() model_data = response.json() return ModelMetadata(**model_data) def predict(self, model_name: str, input_data: ModelInput) -> ModelOutput: """使用指定的模型进行预测。""" response = requests.post(f"{self.mcp_server_url}/models/{model_name}/predict", json=input_data.dict()) response.raise_for_status() output_data = response.json() return ModelOutput(**output_data) # 3. 示例用法 (概念性的 - 需要与 Pydantic Agent 框架集成) # 假设你已经设置了一个 Pydantic Agent 框架(例如,使用 LangChain) # 初始化 MCP 客户端 mcp_client = MCPClient(mcp_server_url="http://your-mcp-server.com") # 示例:列出可用的模型 available_models = mcp_client.list_models() print("可用的模型:", available_models) # 示例:获取特定模型的元数据 if available_models: first_model_name = available_models[0].name model_metadata = mcp_client.get_model_metadata(first_model_name) print("模型元数据:", model_metadata) # 示例:进行预测 input_data = ModelInput(data={"feature1": 1.0, "feature2": 2.0}) # 替换为实际的输入数据 prediction = mcp_client.predict(first_model_name, input_data) print("预测:", prediction) # 在实际的 Pydantic Agent 设置中,你需要: # 1. 定义包装 MCPClient 方法的工具。 # 2. 使用 Pydantic 模型定义工具的输入和输出类型。 # 3. 将这些工具注册到你的 Pydantic Agent。 # 4. 然后,Agent 可以使用这些工具根据用户的指令与 MCP 服务器交互。 ``` **解释:** * **Pydantic 模型:** `ModelMetadata`、`ModelInput` 和 `ModelOutput` 定义了与 MCP 服务器交换的数据的结构。 `Field` 注释提供了描述,Agent 框架可以使用这些描述进行工具选择和参数验证。 * **MCPClient:** 此类封装了与 MCP 服务器交互的逻辑。 它使用 `requests` 库发出 HTTP 请求并将响应解析为 Pydantic 对象。 * **示例用法:** 本节展示了如何使用 `MCPClient` 与 MCP 服务器交互。 这是一个简化的示例,需要与像 LangChain 这样的 Pydantic Agent 框架集成。 * **Pydantic Agents 的重要注意事项:** * **工具定义:** 你需要定义包装 `MCPClient` 方法的工具。 每个工具都将具有一个名称、描述以及使用 Pydantic 模型定义的输入/输出类型。 * **Agent 集成:** 你需要将这些工具注册到你的 Pydantic Agent 框架。 然后,Agent 将能够使用这些工具根据用户的指令与 MCP 服务器交互。 * **错误处理:** `response.raise_for_status()` 方法用于基本的错误处理。 你可能需要在你的 Agent 中添加更复杂的错误处理。 * **身份验证:** 如果你的 MCP 服务器需要身份验证,你需要将身份验证逻辑添加到 `MCPClient`。 This translation aims to be accurate and maintain the technical nuances of the original English text. It also provides explanations to help understand the code and concepts.
MCP Client Example ☀️
Okay, here's a basic example of a Python client and server using the `mcp` library (assuming you meant the Minecraft Protocol, and you're looking for a simplified example, not a full Minecraft server implementation). This example focuses on establishing a connection and sending/receiving simple data. **Important Considerations:** * **`mcp` Library:** There isn't a standard Python library called `mcp`. If you're referring to the Minecraft Protocol, you'll likely need to use a library like `mcstatus` or `nbt` for more complex interactions. This example uses standard sockets for a simplified demonstration. * **Minecraft Protocol Complexity:** The actual Minecraft protocol is *very* complex. This example is a *highly* simplified illustration and won't actually connect to a real Minecraft server or handle the full protocol. * **Error Handling:** This example lacks robust error handling for brevity. In a real application, you'd need to handle exceptions (e.g., connection refused, socket errors, timeouts) properly. * **Security:** This example is for demonstration purposes only and is not secure. Do not use it in a production environment without proper security measures. **Simplified Example (Sockets):** **Server (server.py):** ```python import socket HOST = '127.0.0.1' # Standard loopback interface address (localhost) PORT = 65432 # Port to listen on (non-privileged ports are > 1023) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() print(f"Server listening on {HOST}:{PORT}") conn, addr = s.accept() with conn: print(f"Connected by {addr}") while True: data = conn.recv(1024) if not data: break decoded_data = data.decode('utf-8') print(f"Received: {decoded_data}") response = f"Server received: {decoded_data}".encode('utf-8') conn.sendall(response) ``` **Client (client.py):** ```python import socket HOST = '127.0.0.1' # The server's hostname or IP address PORT = 65432 # The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) message = "Hello, Server!" s.sendall(message.encode('utf-8')) data = s.recv(1024) print(f"Received: {data.decode('utf-8')}") ``` **How to Run:** 1. **Save:** Save the code as `server.py` and `client.py`. 2. **Run the Server:** Open a terminal or command prompt and run `python server.py`. The server will start listening for connections. 3. **Run the Client:** Open another terminal or command prompt and run `python client.py`. The client will connect to the server, send a message, and receive a response. **Explanation:** * **Server:** * Creates a socket, binds it to an address and port, and listens for incoming connections. * `s.accept()` blocks until a client connects. * `conn.recv(1024)` receives data from the client (up to 1024 bytes at a time). * `conn.sendall()` sends data back to the client. * **Client:** * Creates a socket and connects to the server's address and port. * `s.sendall()` sends data to the server. * `s.recv(1024)` receives data from the server. * `decode('utf-8')` converts the received bytes to a string. * `encode('utf-8')` converts the string to bytes for sending. **To connect to a real Minecraft server (which is much more complex):** You'll need a library that handles the Minecraft protocol. Here's a basic example using `mcstatus`: ```python from mcstatus import JavaServer server = JavaServer.lookup("example.com:25565") # Replace with your server address status = server.status() print(f"The server has {status.players.online} players online") ``` **Chinese Translation of the Simplified Example's Comments:** **Server (server.py):** ```python import socket HOST = '127.0.0.1' # 标准的回环接口地址 (localhost) - Standard loopback interface address (localhost) PORT = 65432 # 监听的端口 (非特权端口大于 1023) - Port to listen on (non-privileged ports are > 1023) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) s.listen() print(f"服务器监听在 {HOST}:{PORT}") # Server listening on {HOST}:{PORT} conn, addr = s.accept() with conn: print(f"连接来自 {addr}") # Connected by {addr} while True: data = conn.recv(1024) if not data: break decoded_data = data.decode('utf-8') print(f"接收到: {decoded_data}") # Received: {decoded_data} response = f"服务器接收到: {decoded_data}".encode('utf-8') # Server received: {decoded_data} conn.sendall(response) ``` **Client (client.py):** ```python import socket HOST = '127.0.0.1' # 服务器的主机名或 IP 地址 - The server's hostname or IP address PORT = 65432 # 服务器使用的端口 - The port used by the server with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) message = "你好,服务器!" # Hello, Server! s.sendall(message.encode('utf-8')) data = s.recv(1024) print(f"接收到: {data.decode('utf-8')}") # Received: {data.decode('utf-8')} ``` **Chinese Translation of the `mcstatus` example:** ```python from mcstatus import JavaServer server = JavaServer.lookup("example.com:25565") # 替换为你的服务器地址 - Replace with your server address status = server.status() print(f"服务器有 {status.players.online} 个玩家在线") # The server has {status.players.online} players online ``` **Important Notes about the Chinese Translations:** * I've tried to provide accurate and natural-sounding translations. * The comments are translated to help understand the code's purpose. * Remember to replace `"example.com:25565"` with the actual address of the Minecraft server you want to connect to. This should give you a good starting point. Remember to install the `mcstatus` library if you want to use the Minecraft server status example: `pip install mcstatus`. Good luck!
Remote MCP Server on Cloudflare
simctl-mcp
Terminal MCP Server
This request is a bit ambiguous. "MCP server" could refer to a few things, and the desired functionality isn't entirely clear. Here are a few possible interpretations and their corresponding Chinese translations, along with explanations: **Interpretation 1: A server that allows you to remotely execute terminal commands on a machine running Claude Desktop.** This is the most likely interpretation. You want a server component that can receive commands from Claude Desktop and execute them on the host machine's terminal. * **Chinese Translation:** 用于通过 Claude Desktop 执行终端命令的 MCP 服务器 (Yòng yú tōngguò Claude Desktop zhíxíng zhōngduān mìnglìng de MCP fúwùqì) * **Breakdown:** * 用于 (yòng yú): used for * 通过 (tōngguò): through, via * Claude Desktop: Claude Desktop (no translation needed) * 执行 (zhíxíng): to execute, to run * 终端命令 (zhōngduān mìnglìng): terminal commands * 的 (de): possessive particle (of) * MCP 服务器 (MCP fúwùqì): MCP server **Interpretation 2: A server that *is* Claude Desktop, and it allows you to execute terminal commands.** This is less likely, as Claude Desktop is primarily an interface to a large language model. However, if you're thinking of Claude Desktop *itself* acting as the server. * **Chinese Translation:** 作为 Claude Desktop 的服务器,用于执行终端命令 (Zuòwéi Claude Desktop de fúwùqì, yòng yú zhíxíng zhōngduān mìnglìng) * **Breakdown:** * 作为 (zuòwéi): as, acting as * Claude Desktop: Claude Desktop (no translation needed) * 的 (de): possessive particle (of) * 服务器 (fúwùqì): server * 用于 (yòng yú): used for * 执行 (zhíxíng): to execute, to run * 终端命令 (zhōngduān mìnglìng): terminal commands **Interpretation 3: MCP refers to a specific technology or protocol, and you want a server implementing that protocol for terminal command execution via Claude Desktop.** If "MCP" has a specific technical meaning in your context, please provide more details. Without that context, I can't provide a more accurate translation. For example, if MCP is a messaging protocol: * **Chinese Translation (Example - assuming MCP is a messaging protocol):** 使用 MCP 协议通过 Claude Desktop 执行终端命令的服务器 (Shǐyòng MCP xiéyì tōngguò Claude Desktop zhíxíng zhōngduān mìnglìng de fúwùqì) * **Breakdown:** * 使用 (shǐyòng): to use * MCP 协议 (MCP xiéyì): MCP protocol * 通过 (tōngguò): through, via * Claude Desktop: Claude Desktop (no translation needed) * 执行 (zhíxíng): to execute, to run * 终端命令 (zhōngduān mìnglìng): terminal commands * 的 (de): possessive particle (of) * 服务器 (fúwùqì): server **Important Considerations and Questions for Clarification:** * **Security:** Executing arbitrary terminal commands from a remote source is a *major* security risk. You need to carefully consider authentication, authorization, and input sanitization. * **What is "MCP"?** Knowing what "MCP" refers to is crucial for a precise answer. * **How does Claude Desktop interact with the server?** What protocol (e.g., HTTP, gRPC, custom protocol) will be used for communication? * **What operating system is the server running on?** (Windows, Linux, macOS) This affects the specific terminal commands that can be executed. * **What is the purpose of executing terminal commands?** Understanding the use case will help determine the best approach. To get the most accurate translation and helpful advice, please provide more context about what you're trying to achieve.
MCP Server Boilerplate
这是一个 Model Context Protocol (MCP) 服务器的简单样板实现。
MCP Documentation Project
为我的瞄准镜摄像头项目准备的 MCP 服务器。
Agent.ai MCP Server
MCP Anthropic Server (
一个 MCP 服务器,提供与 Anthropic 的提示工程 API 交互的工具,允许用户根据任务描述和反馈生成、改进和模板化提示。
MCP Server
X(Twitter) V2 MCP Server
一个 MCP 服务器实现,提供用于与 [Twitter/X API v2] 交互的工具。
bilibili-api-mcp-server
一个用于哔哩哔哩 API 的 MCP 服务器
AiSpire
针对 Vectric Aspire/V-Carve 的 MCP 服务器和插件
GRID MCP Server
一个 MCP 服务器,用于直接从 Claude 桌面版使用 GRID API。 (Yī gè MCP fúwùqì, yòng yú zhíjiē cóng Claude zhuōmiàn bǎn shǐyòng GRID API.)
MCP Go SDK
这个 SDK 提供了机器控制协议 (MCP) 的 Go 语言实现,支持客户端和服务器之间的双向通信,用于工具执行、资源访问和提示处理。基于...
神岛引擎开放接口
Here is the translation of the English text into Chinese: **A series of OpenAPI MCP (Model Context Protocol) tools are provided for the Shen Island Engine to help AI call engine interfaces more efficiently.** **Translation:** **提供了一系列用于神岛引擎的 OpenAPI MCP (模型上下文协议) 工具,以帮助 AI 更高效地调用引擎接口。** **Explanation of Choices:** * **"Shen Island Engine"** is translated as **"神岛引擎"** (Shén dǎo yǐnqíng). I'm assuming "Shen Island" is a proper noun and should be transliterated. * **"OpenAPI MCP (Model Context Protocol)"** is translated as **"OpenAPI MCP (模型上下文协议)"** (OpenAPI MCP (Móxíng shàngxiàwén xiéyì)). I kept "OpenAPI MCP" as is, as it's likely a standard acronym. "Model Context Protocol" is translated as "模型上下文协议" which is a literal and accurate translation. * **"to help AI call engine interfaces more efficiently"** is translated as **"以帮助 AI 更高效地调用引擎接口"** (Yǐ bāngzhù AI gèng gāoxiào de diàoyòng yǐnqíng jiēkǒu). This is a clear and concise way to express the purpose of the tools. "以" means "in order to". "更高效" means "more efficiently". "调用引擎接口" means "call engine interfaces". This translation is accurate, natural-sounding, and uses common terminology in the context of AI and software development.
Mcp Server Demo
Claude MCP Get
用于在 Windows 系统上安装和配置模型上下文协议 (MCP) 服务器的综合工具包
linuxSshMcpServer
Okay, here's a breakdown of how to establish an SSH connection and send shell commands or files to a target Linux server, along with examples and explanations: **1. Prerequisites:** * **SSH Client:** You need an SSH client installed on your local machine. Most Linux and macOS systems have one built-in (`ssh` in the terminal). For Windows, you can use PuTTY, OpenSSH (available in recent Windows versions), or other SSH clients. * **SSH Server:** The target Linux server must have an SSH server running (usually `sshd`). It's typically enabled by default on most Linux distributions. * **Credentials:** You need a valid username and password (or, preferably, an SSH key pair) for an account on the target server. Using SSH keys is much more secure than passwords. * **Network Connectivity:** Your local machine must be able to reach the target server over the network (e.g., the server's IP address or hostname must be resolvable). **2. Basic SSH Connection (Password Authentication):** Open your terminal or command prompt and use the following command: ```bash ssh username@server_address ``` * `username`: The username of the account on the target server. * `server_address`: The IP address or hostname of the target server. Example: ```bash ssh john.doe@192.168.1.100 ``` You'll be prompted for the password for the `john.doe` account. Type it in and press Enter. (Note: You won't see the password as you type it.) **3. SSH Connection with SSH Key Authentication (Recommended):** This is the more secure method. If you don't have an SSH key pair, you'll need to generate one first. * **Generate SSH Key Pair (if you don't have one):** ```bash ssh-keygen -t rsa -b 4096 ``` This command will: * Generate a new RSA key pair with a key size of 4096 bits (a good standard). * Prompt you for a file to save the key. The default (`~/.ssh/id_rsa`) is usually fine. * Prompt you for a passphrase. A passphrase adds an extra layer of security. You can leave it blank for no passphrase, but it's generally recommended to use one. * **Copy the Public Key to the Target Server:** There are several ways to do this. The easiest (if you have password access initially) is to use `ssh-copy-id`: ```bash ssh-copy-id username@server_address ``` You'll be prompted for the password for the `username` account. This command will append your public key (`~/.ssh/id_rsa.pub`) to the `~/.ssh/authorized_keys` file on the target server. Alternatively, if `ssh-copy-id` isn't available, you can manually copy the public key: 1. **Copy the public key:** ```bash cat ~/.ssh/id_rsa.pub ``` Copy the entire output of this command. 2. **Connect to the server using password authentication:** ```bash ssh username@server_address ``` 3. **Edit the `authorized_keys` file:** ```bash mkdir -p ~/.ssh chmod 700 ~/.ssh nano ~/.ssh/authorized_keys # Or use your preferred text editor (vi, vim, etc.) ``` 4. **Paste the public key** into the `authorized_keys` file. Make sure it's all on one line. Save the file. 5. **Set correct permissions:** ```bash chmod 600 ~/.ssh/authorized_keys ``` * **Connect using SSH Key Authentication:** Now, when you try to connect: ```bash ssh username@server_address ``` You should *not* be prompted for a password (unless you used a passphrase when generating the key, in which case you'll be prompted for the passphrase). **4. Sending Shell Commands:** You can execute a single shell command on the remote server directly from your local machine: ```bash ssh username@server_address "command to execute" ``` Example: ```bash ssh john.doe@192.168.1.100 "ls -l /home/john.doe" ``` This will execute the `ls -l /home/john.doe` command on the remote server and display the output in your local terminal. You can chain commands using `&&` or `;`: ```bash ssh john.doe@192.168.1.100 "mkdir -p /tmp/test && touch /tmp/test/file.txt" ``` **5. Sending Files (using `scp`):** `scp` (Secure Copy) is used to securely transfer files between your local machine and the remote server. * **Copy a file from your local machine to the server:** ```bash scp local_file username@server_address:remote_directory ``` Example: ```bash scp my_script.sh john.doe@192.168.1.100:/home/john.doe/scripts/ ``` This will copy the `my_script.sh` file from your current directory on your local machine to the `/home/john.doe/scripts/` directory on the remote server. * **Copy a file from the server to your local machine:** ```bash scp username@server_address:remote_file local_directory ``` Example: ```bash scp john.doe@192.168.1.100:/home/john.doe/data.txt ./ ``` This will copy the `data.txt` file from the `/home/john.doe/` directory on the remote server to your current directory on your local machine. **6. Sending Files (using `sftp`):** `sftp` (Secure File Transfer Protocol) provides an interactive file transfer session. ```bash sftp username@server_address ``` Once connected, you can use commands similar to `ftp`: * `put local_file remote_file`: Upload a file. * `get remote_file local_file`: Download a file. * `ls`: List files on the remote server. * `cd`: Change directory on the remote server. * `lcd`: Change directory on the local machine. * `exit`: Close the connection. **7. Sending a File as Input to a Command (using redirection):** You can use input redirection to send the contents of a local file as input to a command executed on the remote server: ```bash ssh username@server_address "cat > remote_file.txt" < local_file.txt ``` This will: 1. `cat > remote_file.txt`: On the remote server, this command will create (or overwrite) a file named `remote_file.txt` and redirect standard input to it. 2. `< local_file.txt`: On your local machine, this redirects the contents of `local_file.txt` to standard input. 3. The SSH connection pipes the standard input from your local machine to the standard input of the `cat` command on the remote server. **8. Using `bash` script to execute multiple commands:** ```bash #!/bin/bash # Server details USERNAME="your_username" SERVER="your_server_address" # Commands to execute COMMANDS=( "mkdir -p /tmp/test" "touch /tmp/test/file1.txt" "echo 'Hello from remote server' > /tmp/test/file1.txt" "ls -l /tmp/test" ) # Loop through the commands and execute them for CMD in "${COMMANDS[@]}"; do echo "Executing: $CMD" ssh "$USERNAME@$SERVER" "$CMD" if [ $? -ne 0 ]; then echo "Command failed: $CMD" exit 1 # Exit the script if a command fails fi done echo "All commands executed successfully." ``` **Important Security Considerations:** * **Use SSH Keys:** Always prefer SSH key authentication over password authentication. It's much more secure. * **Disable Password Authentication (if possible):** Once you have SSH key authentication set up, consider disabling password authentication in the `sshd_config` file on the server (`/etc/ssh/sshd_config`). Set `PasswordAuthentication no` and restart the SSH service. This prevents brute-force password attacks. * **Firewall:** Make sure your server's firewall is configured to only allow SSH connections from trusted IP addresses or networks. * **Keep SSH Software Updated:** Regularly update your SSH client and server software to patch security vulnerabilities. * **Be Careful with Sudo:** If you need to run commands with `sudo` on the remote server, be very careful about what commands you're executing. Avoid running arbitrary commands with `sudo` unless absolutely necessary. * **Permissions:** Pay attention to file permissions on the remote server. Make sure files and directories have appropriate permissions to prevent unauthorized access. **Chinese Translation of Key Terms:** * SSH: 安全外壳协议 (Ānquán Wàiké Xiéyì) * Server: 服务器 (Fúwùqì) * Client: 客户端 (Kèhùduān) * Username: 用户名 (Yònghùmíng) * Password: 密码 (Mìmǎ) * SSH Key: SSH 密钥 (SSH Mìyào) * Public Key: 公钥 (Gōngyào) * Private Key: 私钥 (Sīyào) * File: 文件 (Wénjiàn) * Directory: 目录 (Mùlù) or 文件夹 (Wénjiànjiā) * Command: 命令 (Mìnglìng) * `scp`: 安全拷贝 (Ānquán Kǎobèi) * `sftp`: 安全文件传输协议 (Ānquán Wénjiàn Chuánshū Xiéyì) * Firewall: 防火墙 (Fánghuǒqiáng) This comprehensive guide should help you establish SSH connections and send commands or files to your target Linux server securely. Remember to prioritize security best practices.
MCP Server for Ollama
将 Claude Desktop 连接到 Ollama LLM 服务器的 MCP 服务器
CrewAI MCP Server
将 CrewAI 与 Claude 连接到 MCP 服务器的集成服务
mcp-sentry: A Sentry MCP Server
与 Sentry 交互的 MCP 服务器