Cline - 中文版 Docs
  • Cline Documentation
  • 入门指南
    • 快速开始
    • What is Cline?
  • Basics
    • Cline - 中文版胜算 说明文档
      • Cline 和模型上下文协议 (MCP) 服务器:提升 AI 能力
      • Interactive blocks
        • OpenAPI
      • Integrations
        • Cloud Provider Integration
        • Security Concerns
      • .clineignore 功能支持
  • Cline - 中文版胜算 说明文档
    • 什么是Cline - 胜算云增强版
    • 对于新程序员
    • 安装 Cline-胜算云增强版
    • 安装 Dev Essentials
    • 我们最喜欢的技术栈
    • 上下文管理
    • 型号选择指南
  • Getting Started
    • What is Cline?
    • For New Coders
    • Installing Cline
    • Installing Dev Essentials
    • Our Favorite Tech Stack
    • Context Management
    • Model Selection Guide
  • 提高提示技巧
    • 提示工程指南
    • Cline-胜算云增强版 内存库
  • Improving Your Prompting Skills
    • Prompt Engineering Guide
    • Cline Memory Bank
  • 探索 Cline 的工具
    • Cline-胜算云增强版 工具指南
  • 检查站
  • 计划与行动模式:有效人工智能发展指南
  • 新建任务工具
  • Remote Browser 支持
  • Exploring Cline's Tools
    • Cline Tools Guide
    • Checkpoints
    • Plan & Act Modes: A Guide to Effective AI Development
    • New Task Tool
  • Remote Browser Support
  • 企业解决方案
    • 安全问题
  • 云提供商集成
  • MCP 服务器
  • 自定义说明
  • Security Concerns
    • Security Concerns
  • Cloud Provider Integration
  • MCP Servers
  • Custom Instructions
  • MCP服务器
    • MCP概述
    • MCP市场
  • 从 GitHub 添加 MCP 服务器
  • 配置 MCP 服务器
  • 连接到远程服务器
  • MCP 传输机制
  • MCP 服务器开发协议
  • MCP Servers
    • MCP Overview
  • MCP Marketplace
  • Adding MCP Servers from GitHub
  • Configuring MCP Servers
  • Connecting to a Remote Server
  • MCP Transport Mechanisms
  • MCP Server Development Protocol
  • 自定义模型配置
    • 带有凭证身份验证的 AWS Bedrock
    • 带配置文件身份验证的 AWS Bedrock
    • GCP Vertex AI
  • LiteLLM 和 Cline-胜算云增强版(使用 Codestral)
  • Custom Model Configs
    • AWS Bedrock w/ Credentials Authentication
  • AWS Bedrock w/ Profile Authentication
  • GCP Vertex AI
  • LiteLLM & Cline (using Codestral)
  • 本地运行模型
    • 请先阅读
    • Ollama
    • LM 工作室
  • Ollama
  • LM Studio
  • Running Models Locally
  • More Info
    • Telemetry
    • 遥测
Powered by GitBook
On this page

MCP Transport Mechanisms

PreviousConnecting to a Remote ServerNextMCP Server Development Protocol

Last updated 2 months ago

Model Context Protocol (MCP) supports two primary transport mechanisms for communication between Cline and MCP servers: Standard Input/Output (STDIO) and Server-Sent Events (SSE). Each has distinct characteristics, advantages, and use cases.

STDIO Transport

STDIO transport runs locally on your machine and communicates via standard input/output streams.

How STDIO Transport Works

  1. The client (Cline) spawns an MCP server as a child process

  2. Communication happens through process streams: client writes to server's STDIN, server responds to STDOUT

  3. Each message is delimited by a newline character

  4. Messages are formatted as JSON-RPC 2.0

Copy

Client                    Server
  |                         |
  |<---- JSON message ----->| (via STDIN)
  |                         | (processes request)
  |<---- JSON message ------| (via STDOUT)
  |                         |

STDIO Characteristics

  • Locality: Runs on the same machine as Cline

  • Performance: Very low latency and overhead (no network stack involved)

  • Simplicity: Direct process communication without network configuration

  • Relationship: One-to-one relationship between client and server

  • Security: Inherently more secure as no network exposure

STDIO transport is ideal for:

  • Local integrations and tools running on the same machine

  • Security-sensitive operations

  • Low-latency requirements

  • Single-client scenarios (one Cline instance per server)

  • Command-line tools or IDE extensions

Copy

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

const server = new Server({name: 'local-server', version: '1.0.0'});
// Register tools...

// Use STDIO transport
const transport = new StdioServerTransport(server);
transport.listen();

Server-Sent Events (SSE) transport runs on a remote server and communicates over HTTP/HTTPS.

  1. The client (Cline) connects to the server's SSE endpoint via HTTP GET request

  2. This establishes a persistent connection where the server can push events to the client

  3. For client-to-server communication, the client makes HTTP POST requests to a separate endpoint

  4. Communication happens over two channels:

    • Event Stream (GET): Server-to-client updates

    • Message Endpoint (POST): Client-to-server requests

Copy

Client                             Server
  |                                  |
  |---- HTTP GET /events ----------->| (establish SSE connection)
  |<---- SSE event stream -----------| (persistent connection)
  |                                  |
  |---- HTTP POST /message --------->| (client request)
  |<---- SSE event with response ----| (server response)
  |                                  |
  • Remote Access: Can be hosted on a different machine from your Cline instance

  • Scalability: Can handle multiple client connections concurrently

  • Protocol: Works over standard HTTP (no special protocols needed)

  • Persistence: Maintains a persistent connection for server-to-client messages

  • Authentication: Can use standard HTTP authentication mechanisms

SSE transport is better for:

  • Remote access across networks

  • Multi-client scenarios

  • Public services

  • Centralized tools that many users need to access

  • Integration with web services

Copy

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';
import express from 'express';

const app = express();
const server = new Server({name: 'remote-server', version: '1.0.0'});
// Register tools...

// Use SSE transport
const transport = new SSEServerTransport(server);
app.use('/mcp', transport.requestHandler());
app.listen(3000, () => {
  console.log('MCP server listening on port 3000');
});

The choice between STDIO and SSE transports directly impacts how you'll deploy and manage your MCP servers.

STDIO servers run locally on the same machine as Cline, which has several important implications:

  • Installation: The server executable must be installed on each user's machine

  • Distribution: You need to provide installation packages for different operating systems

  • Updates: Each instance must be updated separately

  • Resources: Uses the local machine's CPU, memory, and disk

  • Access Control: Relies on the local machine's filesystem permissions

  • Integration: Easy integration with local system resources (files, processes)

  • Execution: Starts and stops with Cline (child process lifecycle)

  • Dependencies: Any dependencies must be installed on the user's machine

A local file search tool using STDIO would:

  • Run on the user's machine

  • Have direct access to the local filesystem

  • Start when needed by Cline

  • Not require network configuration

  • Need to be installed alongside Cline or via a package manager

SSE servers can be deployed to remote servers and accessed over the network:

  • Installation: Installed once on a server, accessed by many users

  • Distribution: Single deployment serves multiple clients

  • Updates: Centralized updates affect all users immediately

  • Resources: Uses server resources, not local machine resources

  • Access Control: Managed through authentication and authorization systems

  • Integration: More complex integration with user-specific resources

  • Execution: Runs as an independent service (often continuously)

  • Dependencies: Managed on the server, not on user machines

A database query tool using SSE would:

  • Run on a central server

  • Connect to databases with server-side credentials

  • Be continuously available for multiple users

  • Require proper network security configuration

  • Be deployed using container or cloud technologies

Some scenarios benefit from a hybrid approach:

  1. STDIO with Network Access: A local STDIO server that acts as a proxy to remote services

  2. SSE with Local Commands: A remote SSE server that can trigger operations on the client machine through callbacks

  3. Gateway Pattern: STDIO servers for local operations that connect to SSE servers for specialized functions

Choosing Between STDIO and SSE

Consideration
STDIO
SSE

Location

Local machine only

Local or remote

Clients

Single client

Multiple clients

Performance

Lower latency

Higher latency (network overhead)

Setup Complexity

Simpler

More complex (requires HTTP server)

Security

Inherently secure

Requires explicit security measures

Network Access

Not needed

Required

Scalability

Limited to local machine

Can distribute across network

Deployment

Per-user installation

Centralized installation

Updates

Distributed updates

Centralized updates

Resource Usage

Uses client resources

Uses server resources

Dependencies

Client-side dependencies

Server-side dependencies

When to Use STDIO

STDIO Implementation Example

SSE Transport

How SSE Transport Works

SSE Characteristics

When to Use SSE

SSE Implementation Example

Local vs. Hosted: Deployment Aspects

STDIO: Local Deployment Model

Practical Example

SSE: Hosted Deployment Model

Practical Example

Hybrid Approaches

Configuring Transports in Cline

For detailed information on configuring STDIO and SSE transports in Cline, including examples, .

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
see Configuring MCP Servers